From f66a9a2c565966e98720be5e20604c6f75030f82 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 28 十月 2024 17:40:13 +0800
Subject: [PATCH] 1.首页添加使用说明。2.修改扫码开阀功能。3.问题反馈功能相关

---
 pages/rechargeCard/rechargeCard.js |  244 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 190 insertions(+), 54 deletions(-)

diff --git a/pages/rechargeCard/rechargeCard.js b/pages/rechargeCard/rechargeCard.js
index 56a094a..9377c0c 100644
--- a/pages/rechargeCard/rechargeCard.js
+++ b/pages/rechargeCard/rechargeCard.js
@@ -1,4 +1,5 @@
 // pages/rechargeCard/rechargeCard.js
+//铏氭嫙鍗″垪琛�
 const {
   get,
   post
@@ -9,25 +10,58 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    confirmBtn: { content: '纭', variant: 'base' },
+    confirmBtn: {
+      content: '纭'
+    },
     currentTab: 0, // 褰撳墠鏄剧ず鐨勮〃鏍硷紝榛樿涓虹涓�涓〃鏍�
     allCardPoints: [],
-    allWaterPoints:[],
-    showDialog:false
+    allWaterPoints: [{
+      "id": "string",
+      "inUse": 1,
+      "inUseName": "string",
+      "money": 110,
+      "vcNum": "200030000000"
+    }, {
+      "id": "string",
+      "inUse": 1,
+      "inUseName": "string",
+      "money": 110,
+      "vcNum": "200030000000"
+    }, {
+      "id": "string",
+      "inUse": 1,
+      "inUseName": "string",
+      "money": 110,
+      "vcNum": "200030000000"
+    }, {
+      "id": "string",
+      "inUse": 1,
+      "inUseName": "string",
+      "money": 110,
+      "vcNum": "200030000000"
+    }, {
+      "id": "string",
+      "inUse": 1,
+      "inUseName": "string",
+      "money": 110,
+      "vcNum": "200030000000"
+    }],
+    showDialog: false,
+    isWXRefreshing: false
   },
- // 鍒囨崲 Tabs
- switchTab: function (e) {
-  const tab = parseInt(e.currentTarget.dataset.tab);
-  this.setData({
-    currentTab: tab
-  });
-},
+  // 鍒囨崲 Tabs
+  switchTab: function (e) {
+    const tab = parseInt(e.currentTarget.dataset.tab);
+    this.setData({
+      currentTab: tab
+    });
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
     this.getCardList();
-    this.getWaterCardList();
+    // this.getWaterCardList();
   },
 
   /**
@@ -62,7 +96,10 @@
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
   onPullDownRefresh() {
-
+    this.setData({
+      isWXRefreshing: true
+    })
+    this.getCardList();
   },
 
   /**
@@ -77,60 +114,159 @@
    */
   onShareAppMessage() {
 
-  },//鑾峰彇铏氭嫙鍗″垪琛�
-  getCardList(){
-    get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: {
-      operator: getApp().globalData.sessionId
-    }})
-    .then((data) => {
-      if(data.success&&data.code==="0001"){
+  }, //鑾峰彇铏氭嫙鍗″垪琛�
+  getCardList() {
+    get({
+        url: 'wx/virtual_card/get',
+        data: {
+          clientId: getApp().globalData.clientId
+        }
+      })
+      .then((data) => {
         this.setData({
-          allCardPoints:  data.content
+          isWXRefreshing: false
         });
-      }else{
-        wx.showToast({
-          title: data.msg,
-        })
-      }
-      console.log('Failed to add item:');
-    })
-    .catch((error) => {
-      console.error('Failed to add item:', error);
-    });
-  },
-  getWaterCardList(){
-    get({url:'https://d4x9787456.vicp.fun/sell/virtual_card/get', data: {
-      operator: getApp().globalData.sessionId
-    }})
-    .then((data) => {
-      if(data.success&&data.code==="0001"){
+        if (data.success && data.code === "0001") {
+          this.setData({
+            allCardPoints: data.content
+          });
+        } else {
+          wx.showToast({
+            title: data.msg,
+          })
+        }
+        console.log('Failed to add item:');
+      })
+      .catch((error) => {
         this.setData({
-          allWaterPoints:  data.content
+          isWXRefreshing: false
         });
-      }else{
-        wx.showToast({
-          title: data.msg,
-        })
-      }
-      console.log('Failed to add item:');
-    })
-    .catch((error) => {
-      console.error('Failed to add item:', error);
-    });
+        console.error('Failed to add item:', error);
+      });
   },
-  rechargeCard(item){
+  getWaterCardList() {
+    get({
+        url: 'https://d4x9787456.vicp.fun/sell/virtual_card/get',
+        data: {
+          operator: getApp().globalData.sessionId
+        }
+      })
+      .then((data) => {
+        if (data.success && data.code === "0001") {
+          this.setData({
+            allWaterPoints: data.content
+          });
+        } else {
+          wx.showToast({
+            title: data.msg,
+          })
+        }
+        console.log('Failed to add item:');
+      })
+      .catch((error) => {
+        console.error('Failed to add item:', error);
+      });
+  },
+  rechargeCard(event) {
     wx.navigateTo({
-      url: '/pages/rechargeMoney/rechargMoney' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
+      url: '/pages/rechargeMoney/rechargMoney?vcId='+event.currentTarget.dataset.item.id // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
     });
   },
-  ruinCard(){
+  ruinCard(item) {
+    const mItem = item.currentTarget.dataset.item;
 
+    if (mItem.money > 0) {
+      //閲戦澶т簬0涓嶈兘閿�鍗�
+      this.setData({
+        showDialog: true
+      })
+    } else {
+      //閲戦绛変簬0鎵嶅彲閿�鍗�
+      this.deleteID(mItem.id);
+    }
   },
-  closeDialog(){
+  closeDialog() {
     this.setData({
-      showDialog:false
+      showDialog: false
     })
-  }
+  },
+  //娣诲姞铏氭嫙鍗�
+  handleClick() {
+    wx.showLoading({
+      title: '姝e湪娣诲姞璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      clientId: getApp().globalData.clientId, //涓存椂鐧诲綍鍑瘉
+    };
+    post({
+      url: "wx/virtual_card/add_vc",
+      data: data,
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      if (response.code === "0001") {
+        wx.showToast({
+          title: '娣诲姞鎴愬姛',
+          icon: 'success',
+          duration: 3000
+        })
+        this.getCardList();
+      }
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+      wx.showToast({
+        title: '娣诲姞澶辫触',
+        icon: 'error',
+        duration: 2000
+      })
+    });
+  },
+  //娉ㄩ攢铏氭嫙鍗�
+  deleteID(vcId) {
+    wx.showLoading({
+      title: '姝e湪閿�鍗¤绋嶅��...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      clientId: getApp().globalData.clientId, //涓存椂鐧诲綍鍑瘉
+      vcId: vcId //铏氭嫙鍗d
+    };
+    post({
+      url: "wx/virtual_card/cancel",
+      data: data,
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      if (response.code === "0001") {
+        wx.showToast({
+          title: '閿�鍗℃垚鍔�',
+          icon: 'success',
+          duration: 3000
+        })
+        this.getCardList();
+      }
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+      wx.showToast({
+        title: '娉ㄩ攢澶辫触',
+        icon: 'error',
+        duration: 2000
+      })
+    });
+  },
+
+  
 
 
 })
\ No newline at end of file

--
Gitblit v1.8.0