知识付费微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

313 lines
6.0 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="index">
  3. <view class="top">
  4. <view class="content">
  5. <image class="content-img" :src="shopInfo.image" />
  6. <view class="content-left">
  7. <u-row style="margin: 10rpx;">
  8. <u-col>{{ shopInfo.title }}</u-col>
  9. </u-row>
  10. <u-row justify="space-between" style="margin: 20rpx; font-size: 12px;">
  11. <u-col span="6">
  12. 级别:初级
  13. </u-col>
  14. <u-col span="6">
  15. {{ shopInfo.num }}人学习
  16. </u-col>
  17. </u-row>
  18. <u-row justify="space-between" style="margin: 10rpx; font-size: 16px;">
  19. <u-col span="4">
  20. <view style="color: #ff7800;font-size: 45rpx;">
  21. {{ shopInfo.price }}
  22. </view>
  23. </u-col>
  24. <u-col span="4" style="text-decoration:line-through">
  25. <view class="icon">
  26. <u-number-box style="margin: 0 auto;" v-model="registerForm.num" :min="1">
  27. <view slot="minus" class="minus">
  28. <u-icon name="minus" size="12" color="#fff"></u-icon>
  29. </view>
  30. <template v-slot:input>
  31. <text style="width: 50px;text-align: center;" class="input">
  32. {{ registerForm.num }}
  33. </text>
  34. </template>
  35. <view slot="plus" class="plus">
  36. <u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
  37. </view>
  38. </u-number-box>
  39. </view>
  40. </u-col>
  41. </u-row>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="cell">
  46. <view class="cell-box">
  47. <view>
  48. 无法查看资源内容请购买!
  49. </view>
  50. </view>
  51. </view>
  52. <view class="book">
  53. <view class="book-text">
  54. <view style="padding-top: 20rpx;font-size: 14px;">资源介绍</view>
  55. <uv-parse :content="shopInfo.content"></uv-parse>
  56. </view>
  57. </view>
  58. <view class="bottom-flex">
  59. <view class="icon">
  60. <u-icon name="server-man" size="40rpx"></u-icon>
  61. 客服
  62. </view>
  63. <view class="button">
  64. <view class="button-right">
  65. <view @click="createPayOrder">
  66. 立即购买 ({{ shopInfo.price * registerForm.num }})
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. // wxf173d7bec0f1bbe0
  75. export default {
  76. data() {
  77. return {
  78. registerForm: {
  79. num: 1
  80. },
  81. shopInfo: {}, //商品信息
  82. }
  83. },
  84. onLoad() {
  85. this.getShopInfo()
  86. },
  87. methods: {
  88. //获取商品信息
  89. getShopInfo() {
  90. this.$api('getPayShopOne', res => {
  91. this.shopInfo = res.result
  92. })
  93. },
  94. //创建订单、支付
  95. createPayOrder() {
  96. this.registerForm.shopId = this.shopInfo.id
  97. this.$api('createPayOrder', this.registerForm, res => {
  98. if(res.code == 200){
  99. uni.requestPayment({
  100. provider: 'wxpay', // 服务提提供商
  101. timeStamp: res.result.timeStamp, // 时间戳
  102. nonceStr: res.result.nonceStr, // 随机字符串
  103. package: res.result.packageValue,
  104. signType: res.result.signType, // 签名算法
  105. paySign: res.result.paySign, // 签名
  106. success: function (res) {
  107. console.log('支付成功',res);
  108. uni.switchTab({
  109. url: '/pages/center/center'
  110. })
  111. },
  112. fail: function (err) {
  113. console.log('支付失败',err);
  114. uni.showToast({
  115. icon:'none',
  116. title:"支付失败"
  117. })
  118. }
  119. });
  120. }
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .index {
  128. background-color: #ccc;
  129. .bottom-flex {
  130. position: fixed;
  131. left: 0;
  132. bottom: 0;
  133. width: 100%;
  134. display: flex;
  135. height: 100rpx;
  136. padding: 10rpx 0;
  137. background-color: #fff;
  138. justify-content: space-between;
  139. box-sizing: border-box;
  140. padding: 0rpx 20rpx;
  141. .icon {
  142. font-size: 26rpx;
  143. display: flex;
  144. flex-direction: column;
  145. justify-content: center;
  146. align-items: center;
  147. }
  148. }
  149. }
  150. .top {
  151. padding-top: var(--status-bar-height);
  152. position: relative;
  153. height: 230rpx;
  154. background-color: #000;
  155. }
  156. .content {
  157. position: absolute;
  158. top: 20rpx;
  159. width: 100%;
  160. height: 250rpx;
  161. }
  162. .content-img {
  163. position: absolute;
  164. top: 20rpx;
  165. left: 20rpx;
  166. width: 220rpx;
  167. height: 160rpx;
  168. border-radius: 10rpx;
  169. }
  170. .content-left {
  171. position: absolute;
  172. color: #fff;
  173. font-size: 14px;
  174. left: 35%;
  175. top: 20rpx;
  176. line-height: 50rpx;
  177. }
  178. .cell {
  179. display: flex;
  180. justify-content: center;
  181. align-items: center;
  182. height: 140rpx;
  183. background-color: #fff;
  184. width: 100%;
  185. }
  186. .cell-box {
  187. display: flex;
  188. width: 90%;
  189. background-color: rgb(253, 194, 4);
  190. height: 70rpx;
  191. border-radius: 10rpx;
  192. font-size: 12px;
  193. justify-content: center;
  194. align-items: center;
  195. }
  196. /deep/ .book {
  197. margin-top: 20rpx;
  198. min-height: 600rpx;
  199. background-color: #fff;
  200. img {
  201. width: 100% !important;
  202. }
  203. }
  204. /deep/ .book-text {
  205. width: 94%;
  206. margin-left: 3%;
  207. min-height: 700rpx;
  208. font-size: 13px;
  209. line-height: 40rpx;
  210. padding-bottom: 100rpx;
  211. img {
  212. width: 100% !important;
  213. }
  214. }
  215. .book-img {
  216. padding-top: 20rpx;
  217. width: 100%;
  218. height: 300rpx;
  219. }
  220. .button {
  221. position: relative;
  222. display: flex;
  223. top: 10rpx;
  224. width: 350rpx;
  225. height: 80%;
  226. font-size: 12px;
  227. }
  228. .button-left {
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. flex: 1;
  233. height: 100%;
  234. background-color: rgb(253, 194, 5);
  235. // border-top-left-radius: 50rpx;
  236. // border-bottom-left-radius: 50rpx;
  237. }
  238. .button-right {
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. flex: 1;
  243. height: 100%;
  244. background-color: rgb(51, 51, 51);
  245. // border-top-right-radius: 50rpx;
  246. // border-bottom-right-radius: 50rpx;
  247. border-radius: 50rpx;
  248. color: #fff;
  249. }
  250. // 步进器
  251. .minus {
  252. width: 22px;
  253. height: 22px;
  254. border-width: 1px;
  255. border-color: white;
  256. border-style: solid;
  257. border-top-left-radius: 100px;
  258. border-top-right-radius: 100px;
  259. border-bottom-left-radius: 100px;
  260. border-bottom-right-radius: 100px;
  261. @include flex;
  262. justify-content: center;
  263. align-items: center;
  264. }
  265. .input {
  266. padding: 0 10px;
  267. margin: 0 10rpx;
  268. }
  269. .plus {
  270. width: 22px;
  271. height: 22px;
  272. background-color: rgb(253, 194, 5);
  273. border-radius: 50%;
  274. /* #ifndef APP-NVUE */
  275. display: flex;
  276. /* #endif */
  277. justify-content: center;
  278. align-items: center;
  279. }
  280. </style>