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

---
 pages/home/home.js |  686 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 552 insertions(+), 134 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index d0a7f0b..f6cf3e9 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -4,6 +4,7 @@
   get,
   post
 } = require('../../api/request.js');
+const app = getApp();
 Page({
 
   /**
@@ -15,8 +16,8 @@
     myItem: {},
     waterIntakeName: "",
     image: "/images/ic_head_bg.jpg",
-    userPhone: "158****0723",
-    userName: "寮犱笁",
+    userPhone: "鏈櫥褰�",
+    userName: "鐐瑰嚮鐧诲綍",
     scrollViewHeight: 0,
     listData: [],
     isRefreshing: false,
@@ -28,13 +29,26 @@
     },
     errorDialogTitle: "鍏抽榾閿欒",
     showForceConfirm: false, //鏄惁寮哄埗寮�闃�
-    lastIntakeName: ""
+    lastIntakeName: "",
+    isLogin: false, //鏄惁宸茬粡鐧诲綍
+    showInfoDialog: false,
+    showTipDialog: false,
+    options: '',
+    showUnBind: false,
+    useTestData: false  // 鏂板锛氭槸鍚︿娇鐢ㄦ祴璇曟暟鎹殑鏍囧織
   },
 
   openValve: function (e) {
-    wx.navigateTo({
-      url: '/pages/waterIntake/waterIntake',
-    })
+    if (this.data.isLogin) {
+      wx.navigateTo({
+        url: '/pages/waterIntake/waterIntake',
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
   },
   calculateScrollViewHeight: function () {
     wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => {
@@ -45,16 +59,29 @@
     }).exec();
   },
   startPullDownRefresh() {
-    if (!this.data.isWXRefreshing) {
-      var self = this;
-      console.log(this.data.isRefreshing);
+    if (this.data.useTestData) {
       this.setData({
         isRefreshing: true
       });
       this.getOpenList();
-
+      return;
     }
-
+    
+    if (this.data.isLogin) {
+      if (!this.data.isWXRefreshing) {
+        var self = this;
+        console.log(this.data.isRefreshing);
+        this.setData({
+          isRefreshing: true
+        });
+        this.getOpenList();
+      }
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
   },
   //鑾峰彇鐢ㄦ埛鏁版嵁
   getUserData() {
@@ -68,61 +95,135 @@
         console.error('Failed to fetch data:', error);
       });
   },
-
-
-
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
-    //鍒ゆ柇鏈湴鏄惁淇濆瓨sessionId
-
-
-    // 浣跨敤 wx.nextTick 绛夊緟椤甸潰娓叉煋瀹屾垚
-    wx.nextTick(() => {
-      this.calculateScrollViewHeight();
-    });
     //褰撳紑闃�鎴愬姛鍚庤皟鐢ㄥ埛鏂�
     console.log("onLoad锛�" + options.param);
-    if (options.param) {
-      wx.showToast({
-        title: '寮�闃�鎴愬姛',
-        icon: 'success',
-        duration: 3000
+    if (options.param === "1" || options.param === "2") {
+      this.setData({
+        options: options,
+        isLogin: true,
       })
-      this.getOpenList();
     }
-    this.initData();
+
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
   onReady() {
+    // 鐩存帴鍔犺浇娴嬭瘯鏁版嵁
+    if (this.data.useTestData) {
+      this.setData({
+        isLogin: true, // 璁剧疆涓哄凡鐧诲綍鐘舵�佷互渚胯兘鐪嬪埌娴嬭瘯鏁版嵁
+        userName: "娴嬭瘯鐢ㄦ埛",
+        userPhone: "135****6789"
+      });
+      this.getOpenList();
+      return;
+    }
+
+    //鍒ゆ柇鏈湴鏄惁淇濆瓨sessionId
+    if (storage.isHasKeySync("sessionId")) {
+      const app = getApp();
+      storage.getItem('sessionId').then((data) => {
+        app.globalData.sessionId = data;
+        this.setData({
+          isLogin: true
+        })
+        if (app.globalData.sessionId) {
+          this.getUserDataBySession();
+        }
+      }).catch((err) => {});
+      storage.getItem('clientId').then((data) => {
+        app.globalData.clientId = data;
+        this.getOpenList();
+      }).catch((err) => {});
+    } else {
+      //鏈湴娌℃湁缂撳瓨寰俊鐧诲綍
+      this.wxLogin();
+    }
+    if (this.data.options.param === "1") {
+      this.setData({
+        showTipDialog: true,
+        tipData: "寮�闃�鍛戒护涓嬪彂鎴愬姛锛屽洜寮�闃�闇�瑕佹椂闂达紝绾�20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�"
+      })
+      setTimeout(() => {
+        this.getOpenList();
+      }, 20000)
+
+    } else if (this.data.options.param === "2") {
+      this.setData({
+        showTipDialog: true,
+        tipData: "棰勭害寮�闃�鍛戒护涓嬪彂鎴愬姛锛屽綋鍒拌揪棰勭害鏃堕棿骞朵笖鎴愬姛寮�闃�鍚庡揩閫熷叧闃�鍒楄〃浼氭樉绀烘湭鍏抽榾璁板綍"
+      })
+      this.getOpenList();
+    }
+  },
+  wxLogin() {
+    // if (!this.data.isLogin) {
+      const that = this;
+      wx.login({
+        success: function (res) {
+          if (res.code) {
+            var code = res.code;
+            console.log(code);
+            // 灏哻ode鍙戦�佸埌鏈嶅姟鍣ㄨ幏鍙杘penid
+            that.codeLogin(code);
+          } else {
+            console.log('鐧诲綍澶辫触锛�' + res.errMsg);
+          }
+        }
+      });
+    // }
 
   },
+  //寰俊code鐧诲綍
+  codeLogin(codeData) {
+    wx.showLoading({
+      title: '姝e湪鐧诲綍璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      code: codeData, //涓存椂鐧诲綍鍑瘉
+    };
+    post({
+      url: "wx/client/code_login",
+      data: data,
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      if (response.code === "0001") {
+        //鍋囧涓虹┖鍒欒烦杞埌缁戝畾鐣岄潰
+        if (response.content.client.clientId === "") {
+          wx.navigateTo({
+            url: '/pages/wxbind/wxbind'
+          })
+        } else {
+          //缂撳瓨鍦ㄦ湰鍦�
+          this.setData({
+            isLogin: true
+          })
+          getApp().globalData.sessionId = response.content.client.sessionId
+          storage.setItem("sessionId", response.content.client.sessionId)
+          getApp().globalData.clientId = response.content.client.clientId
+          storage.setItem("clientId", response.content.client.clientId)
+          this.initData();
+        }
+      } else {
 
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
-   */
-  onShow() {
-
+      }
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+    });
   },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
-   */
-  onUnload() {
-
-  },
-
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
@@ -137,43 +238,45 @@
     // 鏁版嵁璇锋眰瀹屾垚鍚庯紝鍋滄涓嬫媺鍒锋柊鐨勫姩鐢�
     this.getOpenList();
   },
-
-  /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom() {
-
-  },
-
-  /**
-   * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
-   */
-  onShareAppMessage() {
-
-  },
+  // 鍏呭��
   recharge() {
-    // wx.navigateTo({
-    //   url: '/pages/rechargeCard/rechargeCard',
-    // })
-    wx.showToast({
-      title: '鏆傛湭寮�鏀�',
-      icon: 'none'
-    })
+    if (this.data.isLogin) {
+      wx.navigateTo({
+        url: '/pages/rechargeCard/rechargeCard',
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
   },
+  //寮�鍏抽榾璁板綍
   openValveList() {
-    // wx.navigateTo({
-    //   url: '/pages/valveList/valveList',
-    // })
-    wx.showToast({
-      title: '鏆傛湭寮�鏀�',
-      icon: 'none'
-    })
+    if (this.data.isLogin) {
+      wx.navigateTo({
+        url: '/pages/valveList/valveList',
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
+
   },
+  //闂鍙嶉
   feedBack() {
-    wx.showToast({
-      title: '鏆傛湭寮�鏀�',
-      icon: 'none'
-    })
+    if (this.data.isLogin) {
+      wx.navigateTo({
+        url: '/pages/feedback/feedback',
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
   },
   handleChange(e) {
     const item = e.currentTarget.dataset.item;
@@ -189,13 +292,16 @@
     this.setData({
       showConfirm: false,
       showErrorDialog: false,
-      showForceConfirm: false
+      showForceConfirm: false,
+      showTipDialog: false
     });
   },
   cancelDialog() {
     this.setData({
       showForceConfirm: false,
-      showConfirm: false
+      showConfirm: false,
+      showTipDialog: false,
+      showUnBind: false
     });
   },
   /**
@@ -229,11 +335,23 @@
       // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
       wx.hideLoading();
       this.getOpenList();
-      wx.showToast({
-        title: '鍏抽榾鎴愬姛',
-        icon: 'success',
-        duration: 3000
-      })
+      if (response.content.data.success) {
+        this.setData({
+          isLogin: true,
+          showTipDialog: true,
+          tipData: "鍏抽榾鍛戒护涓嬪彂鎴愬姛锛岀害20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�"
+        })
+        setTimeout(() => {
+          this.getOpenList();
+        }, 40000)
+      } else {
+        wx.showToast({
+          title: '鍛戒护鎵ц澶辫触',
+          icon: 'error',
+          duration: 3000
+        })
+      }
+
     }).catch(error => {
       wx.hideLoading();
       this.setData({
@@ -243,38 +361,123 @@
       })
       // 澶勭悊閿欒鍝嶅簲
       console.error('璇锋眰澶辫触:', error);
-
     });
+  },
+  /**
+   * 鐢熸垚娴嬭瘯鏁版嵁 - 鏂板鍑芥暟
+   */
+  generateTestData() {
+    const now = new Date();
+    const year = now.getFullYear();
+    const month = String(now.getMonth() + 1).padStart(2, '0');
+    const day = String(now.getDate()).padStart(2, '0');
+    const hours = String(now.getHours()).padStart(2, '0');
+    const minutes = String(now.getMinutes()).padStart(2, '0');
+    const seconds = String(now.getSeconds()).padStart(2, '0');
+
+    const dateString = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+    const orderBase = `TEST-${year}${month}${day}-`;
+
+    const testData = [
+      {
+        intakeNum: "鍙栨按鍙�1",
+        isOnLine: true,
+        dt: dateString,
+        waterInstant: "1.23",
+        orderNo: orderBase + "001",
+        rtuAddr: "TEST-RTU-001",
+        vcNum: "TEST-VC-001",
+        planned: false,
+        time: this.extractTime(dateString),
+        deleteText: "鍒犻櫎",
+        displayText: "鍏抽榾",
+        isOpen: true
+      },
+      {
+        intakeNum: "鍙栨按鍙�2",
+        isOnLine: false,
+        dt: dateString,
+        waterInstant: "2.45",
+        orderNo: orderBase + "002",
+        rtuAddr: "TEST-RTU-002",
+        vcNum: "TEST-VC-002",
+        planned: false,
+        time: this.extractTime(dateString),
+        deleteText: "鍒犻櫎",
+        displayText: "鍏抽榾",
+        isOpen: true
+      },
+      {
+        intakeNum: "鍙栨按鍙�3",
+        isOnLine: true,
+        dt: dateString,
+        waterInstant: "3.67",
+        orderNo: orderBase + "003",
+        rtuAddr: "TEST-RTU-003",
+        vcNum: "TEST-VC-003",
+        planned: true,
+        time: this.extractTime(dateString),
+        deleteText: "鍒犻櫎",
+        displayText: "鍙栨秷",
+        isOpen: true
+      }
+    ];
+    return testData;
   },
   /**
    * 鑾峰彇涓哄叧闃�璁板綍
    */
   getOpenList() {
-    const app = getApp();
-    const params = {
-      url: 'wx/valve/get',
-      data: {
-        operator: app.globalData.sessionId
+    if (this.data.isLogin) {
+      // 濡傛灉璁剧疆浜嗕娇鐢ㄦ祴璇曟暟鎹紝鍒欑洿鎺ヤ娇鐢ㄦ祴璇曟暟鎹�
+      if (this.data.useTestData) {
+        const testData = this.generateTestData();
+        this.setData({
+          listData: testData,
+          isRefreshing: false,
+          isWXRefreshing: false,
+        });
+        this.updateDisplayText();
+        return;
       }
-    };
-    get(params).then(data => {
-      this.setData({
-        listData: data.content,
-        isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-        isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-      })
-    }).catch(err => {
-      // 閿欒鍥炶皟
-      this.setData({
-        isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-        isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
-      })
+
+      const app = getApp();
+      const params = {
+        url: 'wx/valve/get',
+        data: {
+          operator: app.globalData.clientId
+        }
+      };
+      get(params).then(data => {
+        this.setData({
+          listData: data.content,
+          isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+          isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+        })
+        this.updateDisplayText();
+      }).catch(err => {
+        // 閿欒鍥炶皟
+        this.setData({
+          isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+          isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+        })
+        wx.showToast({
+          title: err.msg,
+          icon: 'error',
+          duration: 3000
+        })
+      });
+    } else {
       wx.showToast({
-        title: err.msg,
-        icon: 'error',
-        duration: 3000
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
       })
-    });
+      this.setData({
+        isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+        isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+      })
+    }
+
   },
   /**
    * 纭鍏抽棴鍥炶皟
@@ -284,6 +487,30 @@
     this.setData({
       showConfirm: false
     });
+    if (this.data.useTestData) {
+      // 娴嬭瘯鏁版嵁妯″紡涓嬶紝妯℃嫙鍏抽榾鎿嶄綔
+      wx.showLoading({
+        title: '姝e湪鍏抽榾璇风◢鍊�...', 
+        mask: true
+      });
+      
+      // 妯℃嫙璇锋眰寤惰繜
+      setTimeout(() => {
+        wx.hideLoading();
+        
+        // 浠庡垪琛ㄤ腑绉婚櫎琚叧闂殑闃�闂�
+        const updatedList = this.data.listData.filter(item => 
+          item.orderNo !== this.data.myItem.orderNo
+        );
+        
+        this.setData({
+          listData: updatedList,
+          showTipDialog: true,
+          tipData: "鍏抽榾鍛戒护涓嬪彂鎴愬姛锛岀害20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�"
+        });
+      }, 1500);
+      return;
+    }
     this.postCloseValaue(this.data.myItem.orderNo, this.data.myItem.rtuAddr, this.data.myItem.vcNum);
   },
   //鏍规嵁session鑾峰彇鍐滄埛淇℃伅
@@ -298,7 +525,8 @@
     get(params).then(data => {
       this.setData({
         userName: data.content.clientName,
-        userPhone: this.maskPhoneNumber(data.content.phone)
+        userPhone: this.maskPhoneNumber(data.content.phone),
+        isLogin: true
       })
     }).catch(err => {
       // 閿欒鍥炶皟
@@ -327,28 +555,36 @@
    * 鎵爜寮�闃�
    */
   scenCode() {
-    const that = this;
-    wx.scanCode({
-      success(res) {
-        console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result  
-        if (res.result.startsWith("content://")) {
-          let jsonStr = res.result.replace("content://", "")
-          try {
-
-            that.saveData(jsonStr)
-          } catch (error) {
-            console.error('Error parsing JSON:', error);
+    if (this.data.isLogin) {
+      const that = this;
+      wx.scanCode({
+        success(res) {
+          console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result  
+          if (res.result.startsWith("content://")) {
+            let jsonStr = res.result.replace("content://", "")
+            try {
+              that.saveData(jsonStr)
+            } catch (error) {
+              console.error('Error parsing JSON:', error);
+            }
+          } else {
+            wx.navigateTo({
+              url: '/pages/openCard/openCard?intakeName=' + res.result,
+            })
+            // that.postOppenValva()
           }
-
-        } else {
-          that.postOppenValva(res.result)
+        },
+        fail(err) {
+          console.error(err);
         }
+      })
+    } else {
+      wx.showToast({
+        title: '璇峰厛鐧诲綍',
+        icon: 'error'
+      })
+    }
 
-      },
-      fail(err) {
-        console.error(err);
-      }
-    })
   },
   confirmForceDialog() {
     console.log("confirmForceDialog");
@@ -358,7 +594,7 @@
     this.postOppenValva(this.data.lastIntakeName, true)
   },
   /**
-   * 
+   * 鎵爜寮�闃�璋冪敤寮�闃�鎺ュ彛
    * @param {*} intakeName 
    */
   postOppenValva(intakeName, isforce) {
@@ -421,8 +657,7 @@
   //杩涘叆鐣岄潰鑾峰彇鐣岄潰鏁版嵁
   initData() {
     const app = getApp();
-    console.log("tag>>>>:" +app.globalData.tag)
- 
+    console.log("tag>>>>:" + app.globalData.tag)
     if (storage.isHasKeySync("userData")) {
       storage.getItem('userData').then((data) => {
         let jsonObj = JSON.parse(data);
@@ -439,6 +674,189 @@
       this.getOpenList();
       console.log('Failed to load parameter:false');
     }
-  
+
+  },
+  //寮哄埗鍒犻櫎
+  onDelete(e) {
+    const item = e.currentTarget.dataset.item;
+    const that = this;
+    
+    if (this.data.useTestData) {
+      // 娴嬭瘯鏁版嵁妯″紡涓嬶紝妯℃嫙鍒犻櫎鎿嶄綔
+      wx.showLoading({
+        title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', 
+        mask: true 
+      });
+      
+      // 妯℃嫙璇锋眰寤惰繜
+      setTimeout(() => {
+        wx.hideLoading();
+        
+        // 浠庡垪琛ㄤ腑绉婚櫎琚垹闄ょ殑椤�
+        const updatedList = this.data.listData.filter(listItem => 
+          listItem.orderNo !== item.orderNo
+        );
+        
+        this.setData({
+          listData: updatedList
+        });
+        
+        wx.showToast({
+          title: '鍒犻櫎鎴愬姛',
+          icon: 'success',
+          duration: 2000
+        });
+      }, 1500);
+      return;
+    }
+    
+    wx.showLoading({
+      title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      vcNum: item.vcNum, //鍙栨按鍙D
+      rtuAddr: item.rtuAddr, //闃�鎺у櫒鍦板潃
+    };
+    post({
+      url: "wx/valve/deleteUnclosed",
+      data: data,
+      timeout: 180000
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      //閲嶆柊鑾峰彇鍒楄〃鍒锋柊鏁版嵁
+      this.getOpenList();
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+    });
+  },
+  //淇敼鎸夐挳鏂囧瓧
+  updateDisplayText() {
+    const updatedList = this.data.listData.map(item => {
+      let displayText = '';
+      if (item.planned) {
+        displayText = '鍙栨秷';
+      } else {
+        displayText = "鍏抽榾"
+      }
+      let deleteText = "鍒犻櫎"
+      let time;
+      if (!item.dt) {
+        time = "鏆傛棤"
+      } else {
+        time = this.extractTime(item.dt)
+      }
+      if (item.waterInstant===null) {
+        item.waterInstant = "鏆傛棤"
+      }
+
+      return {
+        ...item,
+        displayText,
+        deleteText,
+        time
+      }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁
+    });
+    // 鏇存柊鍒楄〃鏁版嵁
+    this.setData({
+      listData: updatedList
+    });
+  },
+  //瑙g粦
+  unbind() {
+    this.setData({
+      showUnBind: true
+    })
+  },
+  //纭瑙g粦
+  unBindPost() {
+    this.setData({
+      showUnBind: false
+    })
+    wx.showLoading({
+      title: '姝e湪瑙g粦璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      sessionId: getApp().globalData.sessionId //鍙栨按鍙D
+    };
+    post({
+      url: 'wx/client/unbind',
+      data: data,
+      useParams: true
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      //娓呯┖鏁版嵁
+      this.setData({
+        userPhone: "璇风櫥褰�",
+        userName: "鏈櫥褰�",
+        listData: [],
+        isLogin: false
+      })
+      app.globalData.sessionId = "";
+      app.globalData.clientId = ""
+      storage.removeItem("sessionId")
+      storage.removeItem("clientId")
+      wx.showToast({
+        title: '瑙g粦鎴愬姛',
+        icon: 'success',
+        duration: 3000
+      })
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+      wx.showToast({
+        title: '瑙g粦澶辫触',
+        icon: 'error',
+        duration: 3000
+      })
+    });
+  },
+  //鐐瑰嚮鎻愮ず鎸夐挳
+  infoShow() {
+    this.setData({
+      showInfoDialog: true
+    })
+  },
+  //鎻愮ず绐楃‘璁ゆ寜閽�
+  confirmBtnInfoDialog() {
+    this.setData({
+      showInfoDialog: false
+    })
+  },
+  //澶勭悊鏃堕棿鍘绘帀骞存湀鏃�
+  extractTime(datetimeString) {
+    const formattedDate = datetimeString.replace(" ", "T");
+    const date = new Date(formattedDate);
+    // 鑾峰彇灏忔椂銆佸垎閽熷拰绉�
+    const hours = date.getHours().toString().padStart(2, '0');
+    const minutes = date.getMinutes().toString().padStart(2, '0');
+    const seconds = date.getSeconds().toString().padStart(2, '0');
+    return `${hours}:${minutes}:${seconds}`;
+  },
+  onShareAppMessage: function (options) {
+    // 璁剧疆鍒嗕韩鍐呭
+    return {
+      title: '澶х鐏屾簤鍔╂墜', // 鍒嗕韩鏍囬
+      path: '/pages/home/home', // 鍒嗕韩璺緞锛岃璺緞闇�瑕佹槸褰撳墠灏忕▼搴忓瓨鍦ㄧ殑椤甸潰璺緞
+      imageUrl: '/images/logo2.jpg', // 鍒嗕韩鍥炬爣锛屽彲浠ユ槸缃戠粶鍥剧墖璺緞鎴栨湰鍦板浘鐗囪矾寰�
+      success: function (res) {
+        // 鍒嗕韩鎴愬姛鐨勫洖璋冨嚱鏁�
+      },
+      fail: function (res) {
+        // 鍒嗕韩澶辫触鐨勫洖璋冨嚱鏁�
+      }
+    };
   }
 })
\ No newline at end of file

--
Gitblit v1.8.0