فهرست منبع

页面问题处理

QAQ 陈 4 ماه پیش
والد
کامیت
f53228289f

+ 246 - 79
pages/homepage/homepage.js

@@ -2,14 +2,14 @@ const app = getApp();
 Page({
   data: {
     images: {
-       logo:'/static_file/logo.png',
-        background:'/static_file/background.png',
-        card:'/static_file/card.png',
-        tzd:'/static_file/backgrountzdd.png',
-        phone:'/static_file/phone.png',
-        yl:'/static_file/background.yl',
-        jcsfcjtzd:'/static_file/jcsfcjtzd.png',
-        kapiantubiao:'/static_file/kapiantubiao.png'
+      logo: '/static_file/logo.png',
+      background: '/static_file/background.png',
+      card: '/static_file/card.png',
+      tzd: '/static_file/backgrountzdd.png',
+      phone: '/static_file/phone.png',
+      yl: '/static_file/background.yl',
+      jcsfcjtzd: '/static_file/jcsfcjtzd.png',
+      kapiantubiao: '/static_file/kapiantubiao.png'
     },
     // 用户信息
     userInfo: {
@@ -20,13 +20,12 @@ Page({
 
     // 账单信息
     billInfo: {
-      totalAmount: "",  // 总计应缴
-      waterUsage: "",      // 用水量
-      balance: ""       // 账户余额
+      totalAmount: "", // 总计应缴
+      waterUsage: "", // 用水量
+      balance: "" // 账户余额
     },
     // 功能按钮配置
-    functionList: [
-      {
+    functionList: [{
         icon: '/static_file/zdlb.png',
         text: '账单列表',
         url: '/pages/zhangdanlist/zhangdanlist'
@@ -57,8 +56,8 @@ Page({
         url: '/pages/tousujianyi/tousujianyi'
       }
     ],
-    currentIndex:0,
-    noticeList:[],
+    currentIndex: 0,
+    noticeList: [],
     // 活动信息
     activity: {
       title: '净水器活动',
@@ -70,39 +69,70 @@ Page({
   },
 
   onLoad() {
-    let refresh= app.globalData.refresh;
-    if(refresh==1){
+    // 检查是否刚刚绑定了新户号
+    const justBoundNewAccount = wx.getStorageSync('justBoundNewAccount');
+    if (justBoundNewAccount) {
+      // 清除标记
+      wx.removeStorageSync('justBoundNewAccount');
+      // 直接加载页面数据
+      this.loadPageData();
+      return;
+    }
+    
+    // 检查是否所有户号已解绑
+    const allAccountsUnbound = wx.getStorageSync('allAccountsUnbound');
+    if (allAccountsUnbound) {
+      // 清除标记
+      wx.removeStorageSync('allAccountsUnbound');
+      // 跳转到首次绑定页面
+      wx.redirectTo({
+        url: '/pages/FirstBangDing/FirstBangDing',
+      });
+      return;
+    }
+
+    // 检查全局用户信息是否存在
+    if (!app.globalData.currentAccountInfo || 
+        !app.globalData.currentAccountInfo.usernumber || 
+        app.globalData.userWxInfo.currentDsKey === "") {
+      wx.redirectTo({
+        url: '/pages/FirstBangDing/FirstBangDing',
+      });
+      return;
+    }
+
+    let refresh = app.globalData.refresh;
+    if (refresh == 1) {
       wx.showLoading({
         title: '加载中...',
       });
-      if(!app.globalData.userWxInfo.token){
+      if (!app.globalData.userWxInfo.token) {
         wx.hideLoading();
         return;
       }
       const _this = this;
       wx.request({
-        url: app.globalData.interfaceUrls.homePageInfo+app.globalData.currentAccountInfo.usernumber,
+        url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
         method: 'GET',
         header: {
           'content-type': 'application/json', // 默认值
-          'token':app.globalData.userWxInfo.token,
-          'source':"wc",
-          '!SAAS_LOGIN_TOKEN_!':app.globalData.currentAccountInfo.dsKey
+          'token': app.globalData.userWxInfo.token,
+          'source': "wc",
+          '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
         },
-        success (res) {
-          debugger
+        success(res) {
           wx.hideLoading();
-          let apiReturnData=res.data;
-          apiReturnData.data.swNotificationAnnouncementDos.forEach(data=>{
-            data.publishtime=data.publishtime.slice(0,10);
+          let apiReturnData = res.data;
+          apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
+            data.publishtime = data.publishtime.slice(0, 10);
           })
           // 所有的通知公告
-          app.globalData.notices= apiReturnData.data.swNotificationAnnouncementDos;
+          app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
           // 该用户所有的消息通知
           app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
           // 需要轮播的公告
-          let data= apiReturnData.data.swNotificationAnnouncementDos.filter(data=>{
-            return data.homepageslider=='1';
+          let data = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
+            return data.homepageslider == '1';
           });
           if (app.globalData.userNoticesList) {
             // 假设 userNoticesList 中有一个 isRead 属性表示消息是否已读
@@ -118,16 +148,16 @@ Page({
 
           _this.setData({
             billInfo: {
-              totalAmount: apiReturnData.data.duFees ?? 0,         // 总计应缴
+              totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
               waterUsage: apiReturnData.data.waterConsumption ?? 0, // 用水量
-              balance: apiReturnData.data.accountbalance ?? 0      // 账户余额
+              balance: apiReturnData.data.accountbalance ?? 0 // 账户余额
             },
-            userInfo:{
+            userInfo: {
               name: apiReturnData.data.username,
               accountNumber: apiReturnData.data.usernumber,
               address: apiReturnData.data.address
             },
-            noticeList :data,
+            noticeList: data,
             isScrolling: true,
           })
         },
@@ -141,6 +171,26 @@ Page({
     this.loadAccountInfo();
   },
   onShow() {
+    // 检查是否刚刚绑定了新户号
+    const justBoundNewAccount = wx.getStorageSync('justBoundNewAccount');
+    if (justBoundNewAccount) {
+      // 清除标记
+      wx.removeStorageSync('justBoundNewAccount');
+      // 直接加载页面数据
+      this.loadPageData();
+      return;
+    }
+    
+    // 首先检查全局用户信息是否存在,如果没有则跳转到首次绑定页面
+    if (!app.globalData.currentAccountInfo || 
+        !app.globalData.currentAccountInfo.usernumber || 
+        app.globalData.userWxInfo.currentDsKey === "") {
+      wx.redirectTo({
+        url: '/pages/FirstBangDing/FirstBangDing',
+      });
+      return;
+    }
+    
     // 检查是否需要刷新
     const needRefresh = wx.getStorageSync('needRefreshHomepage');
     if (needRefresh) {
@@ -148,7 +198,7 @@ Page({
       wx.removeStorageSync('needRefreshHomepage');
       this.loadPageData();
     }
-    
+
     // 检查是否从户号管理页面返回
     const backFromHuHao = wx.getStorageSync('backFromHuHao');
     if (backFromHuHao) {
@@ -161,17 +211,39 @@ Page({
     }
   },
 
-  loadPageData: function() {
+  loadPageData: function () {
     const _this = this;
     wx.showLoading({
       title: '加载中...',
     });
 
-    // 检查token是否存在
-    if(!app.globalData.userWxInfo.token){
+    // 检查token和账户信息是否存在
+    if (!app.globalData.userWxInfo.token || 
+        !app.globalData.currentAccountInfo || 
+        !app.globalData.currentAccountInfo.usernumber || 
+        !app.globalData.userWxInfo.currentDsKey) {
       wx.hideLoading();
+      console.error('缺少必要的账户信息');
+      
+      // 尝试从本地存储恢复账户信息
+      const storedHuHao = wx.getStorageSync('currentHuHao');
+      if (storedHuHao && storedHuHao.usernumber) {
+        app.globalData.currentAccountInfo = storedHuHao;
+        app.globalData.userWxInfo.currentDsKey = storedHuHao.dsKey;
+        // 重新尝试加载
+        setTimeout(() => {
+          this.loadPageData();
+        }, 100);
+        return;
+      }
+      
+      // 如果无法恢复,则跳转到首次绑定页面
+      wx.redirectTo({
+        url: '/pages/FirstBangDing/FirstBangDing',
+      });
       return;
     }
+    
     wx.request({
       url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
       method: 'GET',
@@ -179,7 +251,7 @@ Page({
         'content-type': 'application/json',
         'token': app.globalData.userWxInfo.token,
         'source': "wc",
-        '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
+        '!SAAS_LOGIN_TOKEN_!': app.globalData.userWxInfo.currentDsKey
       },
       success(res) {
         wx.hideLoading();
@@ -189,9 +261,9 @@ Page({
         // 更新页面数据
         _this.setData({
           billInfo: {
-            totalAmount: apiReturnData.data.duFees ?? 0,         // 总计应缴
+            totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
             waterUsage: apiReturnData.data.waterConsumption ?? 0, // 用水量
-            balance: apiReturnData.data.accountbalance ?? 0      // 账户余额
+            balance: apiReturnData.data.accountbalance ?? 0 // 账户余额
           },
           userInfo: {
             name: apiReturnData.data.username,
@@ -214,7 +286,7 @@ Page({
   // 切换户号
   handleSwitchMeter() {
     wx.navigateTo({
-       url: '/pages/huhaoguanli/huhaoguanli'
+      url: '/pages/huhaoguanli/huhaoguanli'
     })
   },
 
@@ -233,7 +305,7 @@ Page({
     if (item && item.url) {
       wx.navigateTo({
         url: item.url,
-        fail: function(err) {
+        fail: function (err) {
           console.error('页面跳转失败:', err)
           wx.showToast({
             title: '功能开发中',
@@ -266,7 +338,7 @@ Page({
   },
 
   // 添加或修改立即缴费按钮点击事件
-  goToPayment: function(e) {
+  goToPayment: function (e) {
     // 获取当前账单信息
     debugger
     // const billInfo = {
@@ -285,14 +357,14 @@ Page({
   },
 
   // 跳转到通知公告列表页面
-  goToNoticeList: function() {
+  goToNoticeList: function () {
     wx.navigateTo({
       url: '/pages/tongzhiList/tongzhiList'
     })
   },
 
   // 跳转到通知详情页面
-  goToNoticeDetail: function() {
+  goToNoticeDetail: function () {
     const currentNotice = this.data.noticeList[this.data.currentIndex];
 
     wx.navigateTo({
@@ -300,17 +372,17 @@ Page({
     });
   },
 
-  onReady: function() {
+  onReady: function () {
     this.startNoticeScroll();
   },
 
-  startNoticeScroll: function() {
-    if(this.data.noticeList.length==0){
+  startNoticeScroll: function () {
+    if (this.data.noticeList.length == 0) {
       return;
     }
-    let data= (this.data.noticeList||[]).filter(data=>{
-       return data.homepageslider=='1';
-     });
+    let data = (this.data.noticeList || []).filter(data => {
+      return data.homepageslider == '1';
+    });
 
     const content = data[this.data.currentIndex].scrollingcontent;
     const title = data[this.data.currentIndex].noticetitle;
@@ -322,7 +394,7 @@ Page({
     });
   },
 
-  onScrollComplete: function() {
+  onScrollComplete: function () {
     this.setData({
       isScrolling: false
     });
@@ -339,29 +411,124 @@ Page({
   },
 
   // 加载账户和账单信息
-  loadAccountInfo: function() {
+  loadAccountInfo: function () {
     const accountInfo = app.globalData.currentAccountInfo || {};
+    
+    // 检查账户信息是否为空(解绑后返回的情况)
+    if (!accountInfo || !accountInfo.usernumber) {
+      // 检查是否已全部解绑
+      const allAccountsUnbound = wx.getStorageSync('allAccountsUnbound');
+      if (allAccountsUnbound) {
+        // 清除标记
+        wx.removeStorageSync('allAccountsUnbound');
+        // 跳转到首次绑定页面
+        wx.redirectTo({
+          url: '/pages/FirstBangDing/FirstBangDing',
+        });
+        return;
+      }
+      
+      // 尝试请求账户列表,查看是否有其他账户
+      this.checkAndFetchAccounts();
+      return;
+    }
+    
     // 检查是否是首次加载
     const isFirstLoad = wx.getStorageSync('isFirstLoad') !== 'false';
+    // 检查是否在户号管理页面切换过账户
+    const hasUserSwitchedAccount = wx.getStorageSync('hasUserSwitchedAccount') === true;
     
-    if (isFirstLoad) {
-      // 首次加载,查找并设置默认账户
+    if (isFirstLoad && !hasUserSwitchedAccount) {
+      // 首次加载且未切换过账户,查找并设置默认账户
       this.loadDefaultAccount();
       // 设置标记,表示已不是首次加载
       wx.setStorageSync('isFirstLoad', 'false');
     } else {
-      this.setData({
-        currentAccountInfo: accountInfo
-      });
+      if (!isFirstLoad && hasUserSwitchedAccount) {
+        // 未切换过账户,查找并设置默认账户
+        this.loadDefaultAccount();
+      } else {
+        // 非首次加载或已在户号管理中切换过账户,直接使用当前账户
+        this.setData({
+          currentAccountInfo: accountInfo
+        });
+
+        // 如果是从户号管理页面切换了账户,需要清除该标记
+        if (hasUserSwitchedAccount) {
+          wx.removeStorageSync('hasUserSwitchedAccount');
+        }
+      }
     }
   },
   
-  // 加载默认账户
-  loadDefaultAccount: function() {
+  // 检查并获取账户列表
+  checkAndFetchAccounts: function() {
     if (!app.globalData.userWxInfo.token) {
+      // 没有token,直接跳转到首次绑定页面
+      wx.redirectTo({
+        url: '/pages/FirstBangDing/FirstBangDing',
+      });
       return;
     }
+
+    const _this = this;
+    wx.showLoading({
+      title: '加载中...',
+    });
     
+    wx.request({
+      url: app.globalData.interfaceUrls.accountList,
+      method: 'GET',
+      header: {
+        'content-type': 'application/json',
+        'token': app.globalData.userWxInfo.token,
+        'source': "wc"
+      },
+      success(res) {
+        wx.hideLoading();
+        if (res.data && res.data.data && res.data.data.length > 0) {
+          // 找到了账户,设置默认账户
+          const defaultAccount = res.data.data.find(account => account.defaultAccount === "0") || res.data.data[0];
+          
+          // 更新全局账户信息
+          app.globalData.currentAccountInfo = defaultAccount;
+          app.globalData.userWxInfo.currentDsKey = defaultAccount.dsKey;
+          app.globalData.userWxInfo.username = defaultAccount.username;
+          app.globalData.userWxInfo.usernumber = defaultAccount.usernumber;
+          app.globalData.userWxInfo.address = defaultAccount.address;
+          app.globalData.userWxInfo.groupName = defaultAccount.groupName;
+          
+          // 保存到本地存储
+          wx.setStorageSync('currentHuHao', defaultAccount);
+          
+          // 更新页面数据并加载详细信息
+          _this.setData({
+            currentAccountInfo: defaultAccount
+          });
+          _this.loadPageData();
+        } else {
+          // 没有找到任何账户,跳转到首次绑定页面
+          wx.redirectTo({
+            url: '/pages/FirstBangDing/FirstBangDing',
+          });
+        }
+      },
+      fail(error) {
+        wx.hideLoading();
+        // 请求失败,跳转到首次绑定页面
+        wx.redirectTo({
+          url: '/pages/FirstBangDing/FirstBangDing',
+        });
+      }
+    });
+  },
+
+  // 加载默认账户
+  loadDefaultAccount: function () {
+    if (!app.globalData.userWxInfo.token) {
+      return;
+    }
+
     const _this = this;
     wx.showLoading({
       title: '加载中...',
@@ -379,14 +546,14 @@ Page({
         if (res.data && res.data.data) {
           // 查找 defaultAccount 为 0 的账户
           const defaultAccount = res.data.data.find(account => account.defaultAccount === "0");
-        
+          debugger
           if (defaultAccount) {
             // 设置为当前账户
             app.globalData.currentAccountInfo = defaultAccount;
             _this.setData({
               currentAccountInfo: defaultAccount
             });
-            
+
             // 加载该默认账户的详细信息
             _this.loadPageData();
           } else {
@@ -412,13 +579,13 @@ Page({
     });
   },
 
-  onPullDownRefresh: function() {
+  onPullDownRefresh: function () {
     // 刷新数据
     this.refreshData();
   },
 
   // 修改刷新数据的函数
-  refreshData: function() {
+  refreshData: function () {
     console.log('正在刷新数据...');
     this.loadPageData();
     // 刷新完成后停止下拉刷新动画
@@ -434,7 +601,7 @@ Page({
   },
 
   // 获取未读消息数量的方法
-  getUnreadNoticeCount: function() {
+  getUnreadNoticeCount: function () {
     const _this = this;
     // 从服务器获取最新的消息通知数据
     if (app.globalData.userWxInfo.token && app.globalData.currentAccountInfo) {
@@ -467,17 +634,17 @@ Page({
   },
 
   // 新增方法:加载主页全部数据(包括消息通知)
-  loadHomepageData: function() {
+  loadHomepageData: function () {
     const _this = this;
     wx.showLoading({
       title: '加载中...',
     });
-    
-    if(!app.globalData.userWxInfo.token){
+
+    if (!app.globalData.userWxInfo.token) {
       wx.hideLoading();
       return;
     }
-    
+
     wx.request({
       url: app.globalData.interfaceUrls.homePageInfo + app.globalData.currentAccountInfo.usernumber,
       method: 'GET',
@@ -491,24 +658,24 @@ Page({
         wx.hideLoading();
         if (res.data && res.data.data) {
           let apiReturnData = res.data;
-          
+
           // 更新消息通知数据
           apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
-            data.publishtime = data.publishtime.slice(0,10);
+            data.publishtime = data.publishtime.slice(0, 10);
           });
-          
+
           // 更新全局数据
           app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
           app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
-          
+
           // 需要轮播的公告
           let data = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
             return data.homepageslider == '1';
           });
-          
+
           // 更新未读消息数
           _this.getUnreadNoticeCount();
-          
+
           // 更新页面数据
           _this.setData({
             billInfo: {
@@ -524,9 +691,9 @@ Page({
             noticeList: data,
             isScrolling: true
           });
-          
+
           // 如果有轮播公告,重新开始轮播
-          if(data && data.length > 0) {
+          if (data && data.length > 0) {
             _this.startNoticeScroll();
           }
         }
@@ -541,4 +708,4 @@ Page({
       }
     });
   }
-})
+})

+ 2 - 2
pages/homepage/homepage.wxml

@@ -17,12 +17,12 @@
         </view>
 
         <view class="info-row">
-          <text class="label">户号信息</text>
+          <text class="label">户号</text>
           <text class="value">{{userInfo.accountNumber}}</text>
         </view>
 
         <view class="info-row address-row">
-          <text class="label">住址信息</text>
+          <text class="label">住址</text>
           <text class="value address-value">{{userInfo.address}}</text>
         </view>
       </view>

+ 1 - 1
pages/homepage/homepage.wxss

@@ -52,7 +52,7 @@
   color: rgba(163, 163, 163, 1);
   font-size: 30rpx;
   font-weight: 400;
-  width: 140rpx;
+  width: 100rpx;
   margin-right: 30rpx;
 }
 

+ 170 - 33
pages/huhaobangding/huhaobangding.js

@@ -92,10 +92,32 @@ Page({
 
   // 显示水站公司选择器
   showWaterCompanyPicker: function() {
+    // 检查水务公司列表是否已加载
+    if (!this.data.waterCompanyList || this.data.waterCompanyList.length === 0) {
+      // 如果列表为空,尝试重新获取全局数据
+      if (app.globalData.waterCompanys && app.globalData.waterCompanys.length > 0) {
+        this.setData({
+          waterCompanyList: app.globalData.waterCompanys
+        });
+      } else {
+        wx.showToast({
+          title: '水务公司数据加载中,请稍后再试',
+          icon: 'none'
+        });
+        return;
+      }
+    }
+    
+    // 确保waterCompanyIndex的有效性
+    let currentIndex = this.data.waterCompanyIndex;
+    if (!Array.isArray(currentIndex) || currentIndex.length === 0 || 
+        currentIndex[0] >= this.data.waterCompanyList.length) {
+      currentIndex = [0];
+    }
     
     this.setData({
       showWaterCompanyPicker: true,
-      waterCompanyIndex: this.data.waterCompanyIndex
+      waterCompanyIndex: currentIndex
     });
   },
 
@@ -108,29 +130,82 @@ Page({
 
   // 水站公司选择变化
   onWaterCompanyChange: function(e) {
+    // 确保传入的值是有效的
+    if (!e || !e.detail || !e.detail.value) {
+      console.error('水务公司选择变化事件数据无效:', e);
+      return;
+    }
+    
+    // 确保索引在有效范围内
+    let newIndex = e.detail.value;
+    if (!Array.isArray(newIndex) || newIndex.length === 0) {
+      newIndex = [0];
+    }
+    
+    // 验证索引是否超出范围
+    if (newIndex[0] >= this.data.waterCompanyList.length) {
+      newIndex = [0];
+      console.error('水务公司索引超出范围,已重置为0');
+    }
     
     this.setData({
-      waterCompanyIndex: e.detail.value
+      waterCompanyIndex: newIndex
     });
   },
 
   // 确认水站公司选择
   confirmWaterCompany: function(e) {
     const index = this.data.waterCompanyIndex[0];
+    // 确保水站公司数据已加载
+    if (!this.data.waterCompanyList || this.data.waterCompanyList.length === 0 || index >= this.data.waterCompanyList.length) {
+      wx.showToast({
+        title: '数据加载中,请稍后再试',
+        icon: 'none'
+      });
+      this.hideWaterCompanyPicker();
+      return;
+    }
+    
+    // 获取选中的水务公司信息
+    const selectedCompany = this.data.waterCompanyList[index];
+    if (!selectedCompany) {
+      wx.showToast({
+        title: '选择的水务公司无效',
+        icon: 'none'
+      });
+      this.hideWaterCompanyPicker();
+      return;
+    }
+    
+    // 使用固定的本地图片地址,而不是动态获取
+    const yltUrl = '/static_file/jcsfcjtzd.jpg';
+    
+    // 获取营业点数据
+    let phoneList = [];
+    try {
+      if (selectedCompany.businessPoint && Array.isArray(selectedCompany.businessPoint)) {
+        phoneList = selectedCompany.businessPoint.map((data, index) => {
+          return {
+            id: index + 1,
+            name: index + 1 + '、' + data.address,
+            phone: data.contactphone,
+            time: data.worktime
+          };
+        });
+      }
+    } catch (error) {
+      console.error('处理营业点数据时出错:', error);
+    }
+
+    debugger
+    
+    // 更新数据状态
     this.setData({
-      waterCompanyIndex: this.data.waterCompanyIndex,
-      waterCompany: this.data.waterCompanyList[index].name,
+      waterCompanyIndex: [index],
+      waterCompany: selectedCompany.name,
       showWaterCompanyPicker: false,
-      phoneQueryList:  this.data.waterCompanyList[index].businessPoint.map((data,index)=>{
-        return  {
-          id: index+1,
-          name:  index+1+'、'+data.address,
-          phone: data.contactphone,
-          time: data.worktime
-        }
-      }),
-      ylt:app.globalData.imgPreviewUrl+"pagePart/"+this.data.waterCompanyList[index].swCompanyInfo.overduenoticeimage.split("-;-")[0]
-      
+      phoneQueryList: phoneList,
+      ylt: yltUrl
     });
   },
 
@@ -244,10 +319,28 @@ Page({
         if(apiReturnData.code=='200'){
           wx.hideLoading();
           utils.simleInfo('绑定成功')
-          app.globalData.currentAccountInfo=apiReturnData.data[0];
+          
+          // 确保正确更新全局数据
+          const boundAccount = apiReturnData.data[0];
+          app.globalData.currentAccountInfo = boundAccount;
+          app.globalData.userWxInfo.currentDsKey = boundAccount.dsKey;
+          app.globalData.userWxInfo.username = boundAccount.username;
+          app.globalData.userWxInfo.usernumber = boundAccount.usernumber;
+          app.globalData.userWxInfo.address = boundAccount.address;
+          app.globalData.userWxInfo.groupName = boundAccount.groupName;
+          
+          // 保存到本地存储
+          wx.setStorageSync('currentHuHao', boundAccount);
+          // 设置标记表示需要刷新首页
+          wx.setStorageSync('needRefreshHomepage', true);
+          // 设置标记表示已绑定新户号
+          wx.setStorageSync('justBoundNewAccount', true);
+          
+          // 设置全局刷新标记
+          app.globalData.refresh = 1;
+          
           setTimeout(function(){
-            app.globalData.refresh=1;
-            // 使用重定向而不是switchTab,确保homepage完全重新加载
+            // 使用reLaunch确保homepage完全重新加载
             wx.reLaunch({
               url: '/pages/homepage/homepage',
             });
@@ -256,7 +349,7 @@ Page({
           wx.showToast({
             title: apiReturnData.msg,
             icon: 'error',
-            duration: 2000
+            duration: 4000
           })
           wx.hideLoading();
           that.setData({ isBinding: false }); // 重置绑定状态
@@ -281,22 +374,60 @@ Page({
         backgroundColor: '#0066FF'
       });
     }, 100);
+    
+    // 设置固定的预览图地址
+    this.setData({
+      ylt: '/static_file/jcsfcjtzd.jpg'
+    });
+    
+    // 确保水务公司列表已加载
+    if (!this.data.waterCompanyList || this.data.waterCompanyList.length === 0) {
+      if (app.globalData.waterCompanys && app.globalData.waterCompanys.length > 0) {
+        this.setData({
+          waterCompanyList: app.globalData.waterCompanys
+        });
+      } else {
+        console.error('水务公司数据未加载');
+        // 可以在这里添加重试逻辑或者提示用户刷新页面
+      }
+    }
+    
     if(app.globalData.launchPara){
+      // 在设置数据前检查水务公司是否存在
+      const companyIndex = app.globalData.waterCompanys.findIndex(data => data.id == app.globalData.launchPara);
+      if (companyIndex === -1) {
+        console.error('未找到指定的水务公司');
+        return;
+      }
+      
+      const company = app.globalData.waterCompanys[companyIndex];
+      if (!company) {
+        console.error('水务公司数据无效');
+        return;
+      }
+      
+      // 获取营业点数据
+      let phoneList = [];
+      try {
+        if (company.businessPoint && Array.isArray(company.businessPoint)) {
+          phoneList = company.businessPoint.map((data, index) => {
+            return {
+              id: index+1,
+              name: data.address,
+              phone: data.contactphone,
+              time: data.worktime
+            };
+          });
+        }
+      } catch (error) {
+        console.error('处理营业点数据时出错:', error);
+      }
+      
       this.setData({
-        waterCompanyIndex:[app.globalData.waterCompanys.findIndex(data=>data.id==app.globalData.launchPara)],
-        waterCompany: app.globalData.waterCompanys.filter(data=>data.id==app.globalData.launchPara)[0].name,
-        isChange:false,
-        phoneQueryList: app.globalData.waterCompanys.filter(data=>data.id==app.globalData.launchPara)[0].businessPoint.map((data,index)=>{
-          return  {
-            id: index+1,
-            name: data.address,
-            phone: data.contactphone,
-            time: data.worktime
-          }
-        }),
-        ylt:app.globalData.imgPreviewUrl+
-        app.globalData.currentAccountInfo.dsId+"?fileId="
-        +app.globalData.waterCompanys.filter(data=>data.id==app.globalData.launchPara)[0].swCompanyInfo.overduenoticeimage.split("-;-")[1]
+        waterCompanyIndex: [companyIndex],
+        waterCompany: company.name,
+        isChange: false,
+        phoneQueryList: phoneList
       });
     }
   },
@@ -334,8 +465,14 @@ Page({
     });
   },
 
+  // 防止抽屉中非列表区域滚动引起整个页面滚动
+  preventNonListScroll: function(e) {
+    // 由于现在使用scroll-view,我们只需阻止非滚动区域的默认滚动
+    return true;
+  },
+  
+  // 防止蒙层触摸事件
   preventTouchMove: function(e) {
-    // 阻止蒙层的触摸移动事件传递,但允许drawer内部滚动
     return false;
   }
 });

+ 18 - 10
pages/huhaobangding/huhaobangding.wxml

@@ -95,7 +95,7 @@
 </view>
 
 <view class="drawer-mask" wx:if="{{showDrawer}}" bindtap="hideDrawer" catchtouchmove="preventTouchMove"></view>
-<view class="drawer-container {{showDrawer ? 'show' : ''}}" catchtouchmove="{{showDrawer ? 'true' : 'false'}}">
+<view class="drawer-container {{showDrawer ? 'show' : ''}}" catchtouchmove="preventNonListScroll">
   <view class="drawer-close"></view>
   <view class="drawer-title">获取户号方式</view>
 
@@ -118,22 +118,30 @@
     </view>
   </view>
   
-  <view class="phone-query-list">
-    <view class="phone-query-item" wx:for="{{phoneQueryList}}" wx:key="id">
-      <view class="phone-query-name">{{item.name}}</view>
-      <view class="phone-query-contact">
-        <text>联系电话:{{item.phone}}</text>
-        <view class="call-btn" data-phone="{{item.phone}}" bindtap="makePhoneCall">拨打电话</view>
+  <view class="phone-query-container">
+    <scroll-view class="phone-query-scroll" 
+                 scroll-y="true" 
+                 enhanced="true" 
+                 show-scrollbar="true" 
+                 bounces="true" 
+                 fast-deceleration="true"
+                 data-id="phoneQueryList">
+      <view class="phone-query-item" wx:for="{{phoneQueryList}}" wx:key="id">
+        <view class="phone-query-name">{{item.name}}</view>
+        <view class="phone-query-contact">
+          <text>联系电话:{{item.phone}}</text>
+          <view class="call-btn" data-phone="{{item.phone}}" bindtap="makePhoneCall">拨打电话</view>
+        </view>
+        <view class="phone-query-time">客服在线时间:{{item.time}}</view>
       </view>
-      <view class="phone-query-time">客服在线时间:{{item.time}}</view>
-    </view>
+    </scroll-view>
   </view>
 </view>
 
 <!-- 修改预览模态框部分 -->
 <view class="preview-modal {{showPreview ? 'show' : ''}}" bindtap="closePreview" catchtouchmove="preventTouchMove">
   <view class="preview-content" catchtap="preventBubble">
-    <image class="preview-image" src="{{ylt}}" mode="widthFix"></image>
+    <image class="preview-image" src="/static_file/jcsfcjtzd.jpg" mode="widthFix"></image>
     <view class="close-preview-btn" bindtap="closePreview">关闭</view>
   </view>
 </view>

+ 55 - 24
pages/huhaobangding/huhaobangding.wxss

@@ -274,6 +274,11 @@ input {
   padding: 40rpx 30rpx;
   transform: translateY(100%);
   transition: transform 0.3s ease-out;
+  max-height: 80vh;
+  display: flex;
+  flex-direction: column;
+  overflow-y: visible;
+  overflow-x: hidden;
 }
 
 .drawer-container.show {
@@ -545,11 +550,45 @@ input {
   color: #FF4D4F;
 }
 
+/* 电话查询容器 */
+.phone-query-container {
+  display: flex;
+  flex-direction: column;
+  height: 350rpx;
+  position: relative;
+  background-color: #fff;
+  border-radius: 8rpx;
+  margin-top: 10rpx;
+  margin-left: -24rpx;
+  box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.05);
+  overflow: hidden;
+}
+
 /* 电话查询列表样式 */
 .phone-query-list {
-  padding: 0 0rpx;
-  max-height: 400rpx;
-  overflow-y: auto;
+  flex: 1;
+  padding: 0;
+  height: 350rpx;
+  position: relative;
+}
+
+.phone-query-scroll {
+  height: 100%;
+  width: 100%;
+}
+
+/* 移除原有的滚动条样式,使用更适合移动端的简洁样式 */
+.phone-query-scroll::-webkit-scrollbar {
+  width: 4rpx;
+}
+
+.phone-query-scroll::-webkit-scrollbar-thumb {
+  background-color: rgba(46, 130, 255, 0.3);
+  border-radius: 2rpx;
+}
+
+.phone-query-scroll::-webkit-scrollbar-track {
+  background-color: transparent;
 }
 
 .phone-query-item {
@@ -571,13 +610,19 @@ input {
 .phone-query-contact {
   display: flex;
   align-items: center;
-  justify-content: space-between;
   font-size: 28rpx;
   color: #2E82FF;
   margin-bottom: 10rpx;
   padding-left: 60rpx;
 }
 
+.phone-query-contact text {
+  flex: 1;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+
 .phone-query-time {
   font-size: 26rpx;
   color: #999;
@@ -592,30 +637,16 @@ input {
   padding: 10rpx 30rpx;
   border-radius: 30rpx;
   margin-left: 20rpx;
+  white-space: nowrap;
+  flex-shrink: 0;
 }
 
-/* 调整电话查询联系方式样式 */
-.phone-query-contact {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
+
+.scroll-arrow {
   font-size: 28rpx;
+  margin-left: 8rpx;
   color: #2E82FF;
-  margin-bottom: 10rpx;
-  padding-left: 60rpx;
-}
-
-/* 确保按钮在小屏幕上也能正常显示 */
-@media screen and (max-width: 375px) {
-  .phone-query-contact {
-    flex-direction: column;
-    align-items: flex-start;
-  }
-  
-  .call-btn {
-    margin-left: 0;
-    margin-top: 10rpx;
-  }
+  font-weight: bold;
 }
 
 /* 隐藏滚动条但保留功能(可选) */

+ 19 - 3
pages/huhaoguanli/huhaoguanli.js

@@ -85,8 +85,21 @@ Page({
           const isCurrentAccount = unbindInfo.usernumber === app.globalData.currentAccountInfo.usernumber;
           
           if (otherInfo.length == 0) {
+            // 清除全局数据
             app.globalData.currentAccountInfo = [];
             app.globalData.userWxInfo.currentDsKey = "";
+            app.globalData.userWxInfo.username = "";
+            app.globalData.userWxInfo.usernumber = "";
+            app.globalData.userWxInfo.address = "";
+            app.globalData.userWxInfo.groupName = "";
+            
+            // 清除本地存储的户号信息
+            wx.removeStorageSync('currentHuHao');
+            
+            // 设置标记表示所有户号已解绑
+            wx.setStorageSync('allAccountsUnbound', true);
+            
+            // 跳转到首次绑定页面
             wx.redirectTo({
               url: '/pages/FirstBangDing/FirstBangDing',
             })
@@ -157,6 +170,8 @@ debugger
     app.globalData.currentAccountInfo = huHaoInfo;
     // 将新选择的户号信息保存到本地存储
     wx.setStorageSync('currentHuHao', huHaoInfo);
+    // 设置标记表示已在用户管理中切换过账户
+    wx.setStorageSync('hasUserSwitchedAccount', true);
     wx.showToast({
       title: '户号切换成功',
       icon: 'success',
@@ -279,9 +294,10 @@ debugger
             return a.defaultAccount === '0' ? -1 : 1;
           }
           // 如果defaultAccount相同,则按是否是当前户号排序
-          if (a.usernumber === currentUsernumber) return -1;
-          if (b.usernumber === currentUsernumber) return 1;
-          return 0;
+          // if (a.usernumber === currentUsernumber) return -1;
+          // if (b.usernumber === currentUsernumber) return 1;
+          // 如果都不是当前户号,则按照户号(usernumber)排序,保证列表顺序稳定
+          return a.usernumber.localeCompare(b.usernumber);
         });
 
         _this.setData({

+ 5 - 10
pages/jiaofeiList/jiaofeiList.js

@@ -159,7 +159,7 @@ Page({
   // 生成近20年的年份数据
   generateYears: function() {
     const currentYear = new Date().getFullYear();
-    let years = ['全部']; // 添加"全部"选项
+    let years = [];
     
     for (let i = 0; i < 20; i++) {
       years.push(String(currentYear - i));
@@ -167,7 +167,8 @@ Page({
     
     this.setData({
       years: years,
-      yearPickerValue: [0] // 默认选中"全部"
+      yearPickerValue: [0], // 默认选中当年
+      selectedYear: String(currentYear) // 默认设置为当年
     });
   },
   
@@ -204,7 +205,7 @@ Page({
     const selectedYear = this.data.years[selectedIndex];
     
     this.setData({
-      selectedYear: selectedYear === '全部' ? '' : selectedYear,
+      selectedYear: selectedYear,
       showYearPicker: false
     });
     
@@ -214,13 +215,7 @@ Page({
   
   // 修改年份筛选功能
   filterBillsByYear: function() {
-    const { selectedYear, originalBillList } = this.data;
-    
-    if (!selectedYear) {
-      // 重新获取所有数据
-      this.getBillList();
-      return;
-    }
+    const { selectedYear } = this.data;
     
     // 通过接口重新获取指定年份的数据
     wx.showLoading({

+ 1 - 1
pages/jiaofeiList/jiaofeiList.wxml

@@ -27,7 +27,7 @@
   <view class="search-container">
     <view class="search-button" bindtap="showYearPicker">
       <image src="/static_file/search.png" class="search-icon"></image>
-      <text>{{selectedYear || '全部账单'}}</text>
+      <text>{{selectedYear || '全部缴费'}}</text>
     </view>
   </view>
   

+ 17 - 0
pages/jiaofeixiangqing/jiaofeixiangqing.js

@@ -12,6 +12,18 @@ Page({
       if (options.billInfo) {
         // 解析从URL参数传递的JSON字符串获取完整账单数据
         const billDetail = JSON.parse(decodeURIComponent(options.billInfo));
+        // 格式化bills数组中的每个thismeterreadingdate字段
+        if (billDetail.bills && Array.isArray(billDetail.bills)) {
+          billDetail.bills.forEach(bill => {
+            if (bill.thismeterreadingdate) {
+              // 将ISO日期格式转换为年月日格式
+              const date = new Date(bill.thismeterreadingdate);
+              bill.thismeterreadingdate = date.getFullYear() + '-' + 
+                                         this.padZero(date.getMonth() + 1) + '-' + 
+                                         this.padZero(date.getDate());
+            }
+          });
+        }
         // 设置页面数据
         this.setData({
           billData: billDetail,
@@ -43,6 +55,11 @@ Page({
     return amount.toFixed(2);
   },
 
+  // 补零函数
+  padZero: function(num) {
+    return num < 10 ? '0' + num : num;
+  },
+
   // 返回上一页
   goBack: function() {
     wx.navigateBack();

+ 2 - 2
pages/jiaofeixiangqing/jiaofeixiangqing.wxml

@@ -68,8 +68,8 @@
               <text class="bill-number">{{item.billnumber}}</text>
               <text class="due-date">抄表日 {{item.thismeterreadingdate}}</text>
             </view>
-            <view class="payment-status-tag {{item.status === '3' ? 'unpaid-tag' : 'paid-tag'}}">
-              {{item.status === '3' ? '未缴费' : '已缴费'}}
+            <view class="payment-status-tag {{item.status === '3' ? 'paid-tag' : 'unpaid-tag'}}">
+              {{item.status === '3' ? '已缴费' : '未缴费'}}
             </view>
           </view>
 

+ 8 - 2
pages/jiaofeixiangqing/jiaofeixiangqing.wxss

@@ -128,7 +128,7 @@
 .bill-list-container {
   height: calc(100vh - 800rpx);
   padding-bottom: 60rpx;
-  padding: 310rpx 0rpx 0rpx 0rpx;
+  padding: 350rpx 0rpx 0rpx 0rpx;
   z-index: 999;
 }
 
@@ -181,9 +181,15 @@
 /* 支付状态标签 */
 .payment-status-tag {
   font-size: 22rpx;
-  width: 90rpx;
+  min-width: 70rpx; /* 使s用min-width而不是width */
   padding: 4rpx 24rpx;
   border-radius: 20rpx;
+  display: inline-flex; /* 使用flex布局确保居中 */
+  justify-content: center; /* 水平居中 */
+  align-items: center; /* 垂直居中 */
+  white-space: nowrap; /* 禁止文字换行 */
+  box-sizing: border-box; /* 确保padding不影响总宽度 */
+  line-height: 1.5; /* 设置行高 */
 }
 
 .unpaid-tag {

+ 2 - 1
pages/tousujianyiList/tousujianyiList.wxss

@@ -3,6 +3,7 @@
   flex-direction: column;
   height: 100vh;
   background-color: #f5f5f5;
+  position: relative;
 }
 
 .custom-nav {
@@ -38,7 +39,7 @@
 
 .notice-list {
   width: 100%;
-  /* height: calc(100vh - 120rpx); */
+  height: calc(100vh - 88rpx);
   padding: 20rpx;
   padding-top: 190rpx; 
   box-sizing: border-box;

+ 7 - 3
pages/tzxq/tzxq.js

@@ -8,9 +8,9 @@ Page({
 
   onLoad: function (options) {
     const app = getApp();
+    debugger
     if (options.noticeData) {
       const parsedNotice = JSON.parse(decodeURIComponent(options.noticeData));
-      
       // 确保数据格式正确,映射字段到正确的显示名称
       const processedNotice = {
         ...parsedNotice,
@@ -34,9 +34,13 @@ Page({
     // 如果只传入了id,则从全局notices中获取
     if (options.id) {
       const noticeDetail = app.globalData.notices.find(notice => notice.id === options.id);
-      
+      const processedNotice = {
+        ...noticeDetail,
+        title: noticeDetail.title || noticeDetail.noticetitle || '',
+        content: noticeDetail.roption || noticeDetail.noticecontent || ''
+      };
       this.setData({
-        noticeDetail
+        noticeDetail: processedNotice
       });
     }
   },

+ 42 - 22
pages/zhangdanlist/zhangdanlist.js

@@ -82,6 +82,7 @@ Page({
           '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
         },
         success(res) {
+          debugger
           wx.hideLoading();
           let apiReturnData = res.data;
           _this.setData({
@@ -166,7 +167,7 @@ Page({
   // 生成近20年的年份数据
   generateYears: function() {
     const currentYear = new Date().getFullYear();
-    let years = ['全部']; // 添加"全部"选项
+    let years = [];
     
     for (let i = 0; i < 20; i++) {
       years.push(String(currentYear - i));
@@ -174,7 +175,8 @@ Page({
     
     this.setData({
       years: years,
-      yearPickerValue: [0] // 默认选中"全部"
+      yearPickerValue: [0], // 默认选中当年
+      selectedYear: String(currentYear) // 默认设置为当年
     });
   },
   
@@ -211,34 +213,52 @@ Page({
     const selectedYear = this.data.years[selectedIndex];
     
     this.setData({
-      selectedYear: selectedYear === '全部' ? '' : selectedYear,
+      selectedYear: selectedYear,
       showYearPicker: false
     });
     
-    // 根据选择的年份筛选账单
-    this.filterBillsByYear();
+    // 根据选择的年份获取账单
+    this.getBillListByYear();
   },
   
-  // 根据年份筛选账单
-  filterBillsByYear: function() {
-    const { selectedYear, originalBillList } = this.data;
+  // 根据年份获取账单
+  getBillListByYear: function() {
+    const { selectedYear } = this.data;
     
-    if (!selectedYear) {
-      // 如果选择"全部",显示所有账单
-      this.setData({
-        billList: originalBillList
-      });
-      return;
-    }
-    
-    // 根据年份筛选账单
-    const filteredBills = originalBillList.filter(bill => {
-      // 假设 billDate 格式为 "YYYY/MM/DD" 或 "YYYY-MM-DD"
-      return bill.billDate.startsWith(selectedYear) || bill.billDate.startsWith(selectedYear + '-');
+    const _this = this;
+    wx.showLoading({
+      title: '获取中...',
+      mask: true,
     });
     
-    this.setData({
-      billList: filteredBills
+    wx.request({
+      url: app.globalData.interfaceUrls.billList,
+      method: 'POST',
+      data: {
+        accountNum: app.globalData.currentAccountInfo.usernumber,
+        year: selectedYear
+      },
+      header: {
+        'content-type': 'application/json',
+        'token': app.globalData.userWxInfo.token,
+        'source': "wc",
+        '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
+      },
+      success(res) {
+        wx.hideLoading();
+        let apiReturnData = res.data;
+        _this.setData({
+          billList: apiReturnData.data,
+          originalBillList: apiReturnData.data
+        });
+      },
+      fail(error) {
+        wx.hideLoading();
+        wx.showToast({
+          title: '获取账单失败,请稍后再试',
+          icon: 'none'
+        });
+      }
     });
   }
 })

BIN
static_file/logo.png


+ 16 - 0
utils/util.js

@@ -38,6 +38,22 @@ const simleInfoWithBack = msg => {
     }
   })
 }
+
+function formatDateToYMD(dateString) {
+  if (!dateString) return '';
+  
+  try {
+    const date = new Date(dateString);
+    const year = date.getFullYear();
+    const month = String(date.getMonth() + 1).padStart(2, '0');
+    const day = String(date.getDate()).padStart(2, '0');
+    return `${year}年${month}月${day}日`;
+  } catch (e) {
+    console.error('日期格式化错误:', e);
+    return dateString; // 返回原字符串或自定义错误提示
+  }
+}
+
 module.exports = {
   simleInfo: simleInfo,
   simleInfoWithBack: simleInfoWithBack,