kk.shi 3 rokov pred
rodič
commit
e6d069ee77

+ 8 - 1
api/welfareMall.js

@@ -27,7 +27,14 @@ class WelfareMall extends request {
    * 订单退款
    */
   static orderRefund(params) {
-    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/refund`, params, true)
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/order/refund`, params);
+  }
+
+   /**
+   * 获得订单支付参数
+   */
+  static getPayParams(params) {
+    return this.postRequest(`${this.BASE_URL}open/welfare-mall/activity/get-pay-params`, params);
   }
 
 }

+ 45 - 4
pages/welfareMall/order/orderCompletion.js

@@ -34,7 +34,11 @@ Page({
   }
   },
 
-  // 订单数据
+  
+  /**
+   * 
+   * 订单数据
+   */
   getOrder: function(data) {
     WelfareMall.getOrder({
       mobile: getMobileCache(),
@@ -63,7 +67,10 @@ Page({
     })
   }, 
 
-  // 取消订单
+  /**
+   * 
+   * 取消订单
+   */ 
   toCancelOrder(e) {
     wx.showModal({
       title: '取消订单',
@@ -86,7 +93,8 @@ Page({
                     title: '取消订单成功',
                     icon: 'none',
                     duration: 1500
-                  })
+                  });
+                  this.onLoad(this.options);
                 }
                 this.data.lock = false
             }).catch(_ => {
@@ -100,7 +108,40 @@ Page({
        },//接口调用失败的回调函数 
     })
     
-},
+  },
+
+    /**
+   * 获取订单参数
+   */
+  async goPay() {
+      let res = await WelfareMall.getPayParams({
+        mobile: getMobileCache(),
+        orderSn: this.data.orderSn,
+        openId: wx.getStorageSync('loginInfo').openId,
+        thirdPartyName: 'coupon-activity',
+        payCode: "HSAY-COUPON",
+      });
+      console.log(res);
+      // res = res.wxPrePayVo
+      wx.requestPayment({
+        timeStamp: res.wxPrePayVo.timeStamp,
+        package: res.wxPrePayVo.pack,
+        nonceStr: res.wxPrePayVo.nonceStr,
+        signType: res.wxPrePayVo.signType,
+        paySign: res.wxPrePayVo.paySign,
+        success: function (res) {
+          //支付成功,跳转领取成功页面
+          wx.reLaunch({
+            url: '/pages/couponSuccess/couponSuccess'
+          })
+        },
+        fail: function (res) {
+          console.log('payerror')
+          console.log(res);
+        }
+      })
+
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 1 - 1
pages/welfareMall/order/orderCompletion.wxml

@@ -53,7 +53,7 @@
       <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 1}}" catchtap="toCancelOrder">
         <view class="lower-order-text">取消订单</view>
       </view>
-      <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 1}}">
+      <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 1}}" catchtap="goPay">
         <view class="lower-order-text">去支付</view>
       </view>
       <view class="order-refund flex-row" wx:if="{{orderDetail.status.value == 2 || orderDetail.status.value == 5}}">