知识付费微信小程序
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.

377 lines
7.7 KiB

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