bayi 1 år sedan
förälder
incheckning
b7532d3283
3 ändrade filer med 45 tillägg och 46 borttagningar
  1. 0 1
      pages/my/index.less
  2. 2 45
      pages/reading/buyVip/index.js
  3. 43 0
      pages/reading/index.js

+ 0 - 1
pages/my/index.less

@@ -217,7 +217,6 @@
             letter-spacing: 2rpx;
         }
     }
-
     .payBox2 {
         background: url(http://reader-wx.ai160.com/images/reader/v3/learn/2-2.png);
         background-size: cover;

+ 2 - 45
pages/reading/buyVip/index.js

@@ -1,9 +1,7 @@
 import {
     getProducts
 } from '~/api/global'
-import {
-    buyVip,
-} from '~/api/user'
+
 Component({
     /**
      * 组件的属性列表
@@ -40,48 +38,7 @@ Component({
                 show: false
             })
         },
-        async toBuy({
-            currentTarget
-        }) {
-            wx.showLoading({
-                title: '提交中',
-                mask: true
-            })
-            let res = await buyVip({
-                productId: currentTarget.dataset.id
-            }).finally(() => {
-                wx.hideLoading()
-            })
-            let {
-                timeStamp,
-                nonceStr,
-                signType,
-                paySign
-            } = res
-            // package保留字
-            wx.requestPayment({
-                timeStamp,
-                nonceStr,
-                package: res.package,
-                signType,
-                paySign,
-                success: (res) => {
-                    this.selectComponent('#vipModal').open({
-                        type: 'svip'
-                    })
-                    setTimeout(() => {
-                        this.setUserInfo()
-                    }, 1500)
-                },
-                fail(res) {
-                    wx.showToast({
-                        title: "支付失败",
-                        icon: "none",
-                        duration: 3000
-                    })
-                }
-            })
-        },
+ 
         async getProducts() {
             let {
                 productList: products,

+ 43 - 0
pages/reading/index.js

@@ -8,6 +8,7 @@ import {
     postWorksScore
 } from '~/api/works'
 import {
+    buyVip,
     getVipInfo
 } from '~/api/user'
 import {
@@ -666,6 +667,48 @@ Page({
             url: `/pages/otherWork/index?exampleId=${this.data.videoInfo.userRead.exampleId}`
         })
     },
+    async toBuy({
+        currentTarget
+    }) {
+        wx.showLoading({
+            title: '提交中',
+            mask: true
+        })
+        let res = await buyVip({
+            productId: currentTarget.dataset.id
+        }).finally(() => {
+            wx.hideLoading()
+        })
+        let {
+            timeStamp,
+            nonceStr,
+            signType,
+            paySign
+        } = res
+        // package保留字
+        wx.requestPayment({
+            timeStamp,
+            nonceStr,
+            package: res.package,
+            signType,
+            paySign,
+            success: (res) => {
+                this.selectComponent('#vipModal').open({
+                    type: 'svip'
+                })
+                setTimeout(() => {
+                    this.setUserInfo()
+                }, 1500)
+            },
+            fail(res) {
+                wx.showToast({
+                    title: "支付失败",
+                    icon: "none",
+                    duration: 3000
+                })
+            }
+        })
+    },
     creatShare() {
         return new Promise((resolve, reject) => {
             let video = this.data.videoInfo