Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	pages/lijijiaofei/lijijiaofei.js
QAQ 陈 vor 4 Monaten
Ursprung
Commit
3e528f7357
1 geänderte Dateien mit 63 neuen und 37 gelöschten Zeilen
  1. 63 37
      pages/lijijiaofei/lijijiaofei.js

+ 63 - 37
pages/lijijiaofei/lijijiaofei.js

@@ -36,7 +36,7 @@ Page({
       this.setData({
         amount: billInfo.amount, // 默认实缴金额为应缴金额
         actualAmount: billInfo.amountDue, // 设置应缴金额
-        balance: billInfo.balance   //余额 
+        balance: billInfo.balance   //余额
       });
     }
 
@@ -50,12 +50,11 @@ Page({
         yl:'/static_file/background.yl',
         jcsfcjtzd:'/static_file/jcsfcjtzd.png',
         kapiantubiao:'/static_file/kapiantubiao.png'
-        
+
       }
     })
     // 获取状态栏高度
     const systemInfo = wx.getSystemInfoSync();
-    debugger
     this.setData({
       statusBarHeight: systemInfo.statusBarHeight
     });
@@ -77,26 +76,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(() => {
-          //   url: '/pages/jiaofeiSuccess/jiaofeiSuccess'
-            
-          // }, 2000);
-          wx.navigateTo({
-            url: '/pages/jiaofeiSuccess/jiaofeiSuccess'
-          });
-        }
-      });
-    }, 1500);
+    // setTimeout(() => {
+    //   wx.hideLoading();
+    //   wx.showToast({
+    //     title: '缴费成功',
+    //     icon: 'success',
+    //     duration: 2000,
+    //     success: () => {
+    //       // 支付成功后返回首页
+    //       setTimeout(() => {
+    //         wx.navigateBack();
+    //       }, 2000);
+    //     }
+    //   });
+    // }, 1500);
   },
 
   // 返回上一页
@@ -121,7 +147,7 @@ Page({
   // 添加切换水表的方法
   switchMeter: function() {
     wx.navigateTo({
-      url: '/pages/switchMeter/switchMeter', 
+      url: '/pages/switchMeter/switchMeter',
     })
   },
 
@@ -162,28 +188,28 @@ Page({
       }
     });
   },
-  
+
   // 输入数字
   inputNumber: function(e) {
     const number = e.currentTarget.dataset.number;
     let amount = this.data.amount;
-    
+
     // 处理小数点
     if (number === '.' && amount.includes('.')) {
       return;
     }
-    
+
     // 限制小数点后两位
     if (amount.includes('.') && amount.split('.')[1].length >= 2 && number !== '.') {
       return;
     }
-    
+
     // 更新金额
     this.setData({
       amount: amount === '0' ? number : amount + number
     });
   },
-  
+
   // 删除数字
   deleteNumber: function() {
     let amount = this.data.amount;
@@ -197,7 +223,7 @@ Page({
       });
     }
   },
-  
+
   // 确认输入
   confirmInput: function() {
     this.setData({
@@ -208,29 +234,29 @@ Page({
   // 添加自定义金额输入处理函数
   onCustomAmountInput: function(e) {
     let value = e.detail.value;
-    
+
     // 只允许数字和小数点,且小数点后最多两位
     if (value) {
       // 移除非数字和小数点字符
       value = value.replace(/[^\d.]/g, '');
-      
+
       // 确保只有一个小数点
       const parts = value.split('.');
       if (parts.length > 2) {
         value = parts[0] + '.' + parts.slice(1).join('');
       }
-      
+
       // 限制小数点后最多两位
       if (parts.length === 2 && parts[1].length > 2) {
         value = parts[0] + '.' + parts[1].substring(0, 2);
       }
-      
+
       // 限制总长度小于8位(包含小数点)
       if (value.length > 7) {
         value = value.substring(0, 7);
       }
     }
-    
+
     this.setData({
       customAmount: value,
       selectedAmount: 0, // 清除其他金额选择
@@ -245,7 +271,7 @@ Page({
       selectedAmount: null // 取消快捷金额的选中状态
     });
   },
-  
+
   // 输入框失去焦点
   onInputBlur: function() {
     this.setData({
@@ -265,10 +291,10 @@ Page({
     //     });
     //   }
     // });
-    
+
     // this.setData({
     //   amountDue: 150.00,
     //   balance: 200.50
     // });
   },
-}) 
+})