Browse Source

开发vip购买

bayi 1 year ago
parent
commit
f68bfc2b0a

+ 1 - 1
components/vipModal/index.less

@@ -1,6 +1,6 @@
 .activationModal {
     position: fixed;
-    z-index: 2;
+    z-index: 12;
     left: 0rpx;
     top: 0rpx;
     width: 100vw;

+ 1 - 1
components/vipModal/index.wxss

@@ -1,6 +1,6 @@
 .activationModal {
   position: fixed;
-  z-index: 2;
+  z-index: 12;
   left: 0rpx;
   top: 0rpx;
   width: 100vw;

+ 6 - 1
pages/reading/buyVip/index.js

@@ -38,7 +38,6 @@ Component({
                 show: false
             })
         },
- 
         async getProducts() {
             let {
                 productList: products,
@@ -47,5 +46,11 @@ Component({
                 products,
             })
         },
+        triggerPay({
+            currentTarget
+        }) {
+            console.log(currentTarget.dataset.goods);
+            this.triggerEvent('toBuy', currentTarget.dataset.goods)
+        }
     }
 })

+ 2 - 2
pages/reading/buyVip/index.wxml

@@ -5,9 +5,9 @@
             <view>选择下面的会员卡开通后使用!</view>
         </view>
         <view wx:if="{{!vipTime}}">
-            <view class="payBox" bindtap="toBuy" data-id="{{products[0].id}}">
+            <view class="payBox" bindtap="triggerPay" data-goods="{{products[0]}}">
             </view>
-            <view class="payBox payBox2" bindtap="toBuy" data-id="{{products[1].id}}">
+            <view class="payBox payBox2" bindtap="triggerPay" data-goods="{{products[1]}}">
                 <!--    <view class="buyBtn" bindtap="toBuy" data-id="{{products[1].id}}" wx:if="{{!vipTime}}">立即开通
                 </view>
                 <view class="buyBtn" style="font-size: 22rpx;" wx:else>

+ 10 - 7
pages/reading/index.js

@@ -103,6 +103,7 @@ Page({
                 pkData: 'pkData'
             },
             actions: {
+                setUser: 'setUser',
                 setReadDetail: 'setReadDetail'
             }
         })
@@ -192,10 +193,10 @@ Page({
     },
     // 获取是否vip
     async getVipInfo() {
-        let isVip = await getVipInfo()
-        console.log(isVip, '111');
+        let vipTime = await getVipInfo()
+        console.log(vipTime, '111');
         this.setData({
-            isVip
+            isVip: vipTime != ''
         })
     },
     // 获取阅读内容
@@ -668,14 +669,15 @@ Page({
         })
     },
     async toBuy({
-        currentTarget
+        detail
     }) {
+        console.log(detail);
         wx.showLoading({
             title: '提交中',
             mask: true
         })
         let res = await buyVip({
-            productId: currentTarget.dataset.id
+            productId: detail.id
         }).finally(() => {
             wx.hideLoading()
         })
@@ -693,11 +695,12 @@ Page({
             signType,
             paySign,
             success: (res) => {
+                this.selectComponent('#buyVip').close()
                 this.selectComponent('#vipModal').open({
-                    type: 'svip'
+                    type: detail.payType == 'LIFELONG' ? 'sip' : 'vip'
                 })
                 setTimeout(() => {
-                    this.setUserInfo()
+                    this.getVipInfo()
                 }, 1500)
             },
             fail(res) {

+ 1 - 1
pages/reading/index.wxml

@@ -146,7 +146,7 @@
             </view>
         </view>
     </page-container>
-    <buyVip id="buyVip" />
+    <buyVip id="buyVip" bind:toBuy="toBuy" />
     <canvas id='share' type="2d"> </canvas>
     <vipModal id="vipModal"></vipModal>
     <canvas id='vip' type="2d"> </canvas>