From 4a33335da6f6ccbb13427d317d23b0c74d019fbb Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 14 四月 2025 17:56:16 +0800
Subject: [PATCH] 新增测试数据功能,允许在首页和取水口页面使用模拟数据进行测试,优化用户体验。

---
 pages/rechargeMoney/rechargMoney.js |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/pages/rechargeMoney/rechargMoney.js b/pages/rechargeMoney/rechargMoney.js
index 88e106e..1d9d079 100644
--- a/pages/rechargeMoney/rechargMoney.js
+++ b/pages/rechargeMoney/rechargMoney.js
@@ -23,6 +23,7 @@
     pageSize: 20, //鍏呭�艰褰曟瘡椤佃褰曟暟
     loading: false, //鏄惁姝e湪鍔犺浇
     hasMore: true,
+    moneyList:[]//鍏呭�奸噾棰�
   },
 
   /**
@@ -38,7 +39,8 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
   onReady() {
-    this.getRechargList()
+    this.getRechargList();
+    this. getMorneyList();
   },
 
   /**
@@ -67,9 +69,9 @@
    */
   onPullDownRefresh() {
     this.setData({
-      pageCurr: 1
+      pageCurr: 1,
     })
-    this.getRechargList()
+    this.getRechargList(true)
   },
 
   /**
@@ -103,7 +105,7 @@
     const data = {
       sessionId: getApp().globalData.sessionId,
       vcId: this.data.vcId, //铏氭嫙鍗D
-      rechargeAmount: 1 //锛堝崟浣嶆槸鍒嗭級
+      rechargeAmount: this.data.moneyList[this.data.activeIndex].rechargeAmount//锛堝崟浣嶆槸鍏冿級
     };
     console.log("postCloseValaue" + data);
     post({
@@ -136,7 +138,13 @@
         signType: data.content.signType,
         paySign: data.content.paySign,
         success(res) {
+          wx.showToast({
+            title: "鍏呭�兼垚鍔�",
+            icon: 'success',
+            duration: 3000
+          })
           console.log('鏀粯鎴愬姛', res);
+          this. getRechargList(true);
         },
         fail(err) {
           console.log('鏀粯澶辫触', err);
@@ -151,7 +159,7 @@
     });
   },
   //鑾峰彇鍏呭�艰褰�
-  getRechargList() {
+  getRechargList(isRefresh) {
     const params = {
       url: 'wx/virtual_card/getVcRechargeRecords',
       data: {
@@ -162,10 +170,10 @@
     };
     get(params).then(data => {
       this.setData({
-        allRechargeList:this.data.allRechargeList.concat( data.content.obj),
+        allRechargeList: isRefresh ? data.content.obj : this.data.allRechargeList.concat(data.content.obj),
         isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
         loading: false,
-        hasMore: !data.content.obj.pageTotal === this.data.pageCurr
+        hasMore: this.data.pageCurr < data.content.pageTotal
       })
       this.updateDisplayText();
     }).catch(err => {
@@ -181,12 +189,7 @@
       })
     });
   },
-  // 鐢熸垚鏀粯绛惧悕鐨勫嚱鏁�
-  generatePaySign(params) {
-    const sortedKeys = Object.keys(params).sort();
-    const stringToSign = sortedKeys.map(key => `${key}=${params[key]}`).join('&') + `&key=your-mch-key`;
-    return md5(stringToSign).toUpperCase();
-  },
+
   //鍔犺浇鏇村
   loadMore() {
     if (this.data.hasMore && !this.data.loading) {
@@ -197,9 +200,10 @@
       this.getRechargList();
     }
   },
+  //澶勭悊鍏呭�艰褰曠殑鏁版嵁
   updateDisplayText() {
     const updatedList = this.data.allRechargeList.map(item => {
-      let morny = item.rechargeAmount / 100 + "鍏�"
+      let morny = item.rechargeAmount  + "鍏�"
       return {
         ...item,
         morny
@@ -209,5 +213,23 @@
     this.setData({
       allRechargeList: updatedList
     });
+  },
+  //鑾峰彇閲戦
+  getMorneyList(){
+    const params = {
+      url: 'wx/virtual_card/gerRechargeProfiles'
+    };
+    get(params).then(data => {
+      this.setData({
+        moneyList: data.content ,
+      })
+    }).catch(err => {
+      // 閿欒鍥炶皟
+      wx.showToast({
+        title: err.msg,
+        icon: 'error',
+        duration: 3000
+      })
+    });
   }
 })
\ No newline at end of file

--
Gitblit v1.8.0