Forráskód Böngészése

微信支付测试

sola 4 hónapja
szülő
commit
5dd3460d38
1 módosított fájl, 46 hozzáadás és 17 törlés
  1. 46 17
      pages/lijijiaofei/lijijiaofei.js

+ 46 - 17
pages/lijijiaofei/lijijiaofei.js

@@ -32,7 +32,6 @@ Page({
     // 接收从homepage传递的账单信息
     if (options.billInfo) {
       const billInfo = JSON.parse(decodeURIComponent(options.billInfo));
-      debugger
       this.setData({
         amount: billInfo.amount, // 默认实缴金额为应缴金额
         actualAmount: billInfo.amountDue, // 设置应缴金额
@@ -55,7 +54,6 @@ Page({
     })
     // 获取状态栏高度
     const systemInfo = wx.getSystemInfoSync();
-    debugger
     this.setData({
       statusBarHeight: systemInfo.statusBarHeight
     });
@@ -77,22 +75,53 @@ Page({
     wx.showLoading({
       title: '处理中',
     });
-    
+    wx.request({
+      url: app.globalData.interfaceUrls.prepayOrder,
+      method: 'POST',
+      header: {
+        'content-type': 'application/json',
+        'token': app.globalData.userWxInfo.token,
+        'source': "wc",
+        '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
+      },
+      data: {
+        openId: app.globalData.userWxInfo.openid,
+        totalAmount: 1,
+        description: '测试订单',
+      },
+      success: res => {
+        wx.hideLoading();
+        console.log('预下单', res);
+        wx.requestPayment({
+          timeStamp: res.data.data.timeStamp,
+          nonceStr: res.data.data.nonceStr,
+          package: res.data.data.packageVal,
+          signType: 'RSA',
+          paySign: res.data.data.paySign,
+          success: res => {
+            console.log('支付结果', res)
+          }, 
+          complete: () => {
+
+          }
+        })
+      }
+    })
     // 模拟支付
-    setTimeout(() => {
-      wx.hideLoading();
-      wx.showToast({
-        title: '缴费成功',
-        icon: 'success',
-        duration: 2000,
-        success: () => {
-          // 支付成功后返回首页
-          setTimeout(() => {
-            wx.navigateBack();
-          }, 2000);
-        }
-      });
-    }, 1500);
+    // setTimeout(() => {
+    //   wx.hideLoading();
+    //   wx.showToast({
+    //     title: '缴费成功',
+    //     icon: 'success',
+    //     duration: 2000,
+    //     success: () => {
+    //       // 支付成功后返回首页
+    //       setTimeout(() => {
+    //         wx.navigateBack();
+    //       }, 2000);
+    //     }
+    //   });
+    // }, 1500);
   },
 
   // 返回上一页