Pārlūkot izejas kodu

feat(卡券):暂时屏蔽支付参数

zhoumuhao 3 gadi atpakaļ
vecāks
revīzija
bede398b88
2 mainītis faili ar 68 papildinājumiem un 6 dzēšanām
  1. 15 0
      api/activity.js
  2. 53 6
      pages/couponReceive/couponReceive.js

+ 15 - 0
api/activity.js

@@ -30,6 +30,21 @@ class activity extends request {
 
     return res.data
   }
+  /**
+   * 获取支付参数
+   * @param {*} orderSn 
+   */
+  static async getOrderParams(orderSn,activityName='') {
+    let params = {
+      orderSn:orderSn,
+      source:"FREE_MINI_APP",
+      thirdPartyName:activityName,
+      openId:wx.getStorageSync('loginInfo').openId,
+      payCode:'',
+    };
+    const res = await this.postRequest(`${this.BASE_URL}open/activity/get-order-params`, params)
+    return res.data
+  }
 
   /**
    * 获取活动详情

+ 53 - 6
pages/couponReceive/couponReceive.js

@@ -68,6 +68,9 @@ Page({
     try {
       let order = await activity.createOrder(_self.data.activityId,_self.data.memberMobile);
       let orderSn = order.orderSn;
+      _self.setData({
+        orderSn:orderSn
+      })
       let codeId = _self.data.codeId;
       try {
         //插入 订单 和 codeId  bind-share-code
@@ -75,12 +78,24 @@ Page({
       }catch(e) {
           console.log(e)
       }
-      //领取成功
-     app.showToast('领取成功','success',1000,function(){
-      wx.redirectTo({
-        url: '/pages/myCoupons/myCoupons?mobile='+_self.data.memberMobile,
-      })
-     })
+      if (_self.data.activityInfo.isPay == 1 && orderSn) {
+        console.log(22222)
+        //TODO::暂时屏蔽
+        // _self.goPay();
+        app.showToast('领取成功','success',1000,function(){
+          wx.redirectTo({
+            url: '/pages/myCoupons/myCoupons?mobile='+_self.data.memberMobile,
+          })
+        })
+      } else {
+        //领取成功
+        app.showToast('领取成功','success',1000,function(){
+          wx.redirectTo({
+            url: '/pages/myCoupons/myCoupons?mobile='+_self.data.memberMobile,
+          })
+        })
+      }
+     
       
     }catch(e) {
 
@@ -88,6 +103,38 @@ Page({
   
   },
 
+  /**
+   * 获取订单参数
+   */
+  async goPay() {
+    var _self = this;
+    try {
+      let res = await activity.getOrderParams(_self.data.orderSn,_self.activityInfo.name);
+      console.log(res);
+      res = res.wxPrePayVo
+      wx.requestPayment({
+        timeStamp: res.timeStamp,
+        package: res.pack,
+        nonceStr: res.nonceStr,
+        signType: res.signType,
+        paySign: res.paySign,
+        success: function (res) {
+          //领取成功
+          app.showToast('领取成功','success',1000,function(){
+            wx.redirectTo({
+              url: '/pages/myCoupons/myCoupons?mobile='+_self.data.memberMobile,
+            })
+          })
+        },
+        fail: function (res) {
+
+        }
+      })
+    } catch (err) {
+      console.log(err)
+    }
+  },
+
   //获取手机号
   getPhoneNumber(e) {
     let _self = this;