Jelajahi Sumber

页面问题处理

QAQ 陈 4 bulan lalu
induk
melakukan
ce982acfa1

+ 8 - 5
app.js

@@ -1,8 +1,8 @@
 // app.js
 const utils = require('/utils/util.js')
 // const baseIp= "http://localhost:9747"
-// const baseIp= "https://www.izilaishui.com:9000/zhsw"
-const baseIp = "http://192.168.0.215:9000/zhsw"
+const baseIp= "https://www.izilaishui.com:9000/zhsw"
+// const baseIp = "http://192.168.0.215:9000/zhsw"
 // 图片预览地址
 
 App({
@@ -116,10 +116,13 @@ App({
       updateRadstateStatusAll: baseIp+  '/wechat/account/readStatusAll',//全部消息已读
     },
     // 微信静态文件预览方式 使用二开服务的使用次方法
-    weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
+    // weChatImgPreviewUrl: "http://192.168.0.215:8020/wechat/",
+    weChatImgPreviewUrl: "https://www.izilaishui.com:8020/wechat/",
+
     // 平台
-    imgPreviewUrl:"http://192.168.0.215:9000/common/sys/sysfile/preview/",
-   
+    // imgPreviewUrl:"http://192.168.0.215:9000/common/sys/sysfile/preview/",
+    imgPreviewUrl:"https://www.izilaishui.com:9000/common/sys/sysfile/preview/",
+
     // 统一管理图片路径
     images: {
       logo: '/static_file/logo.png',

+ 21 - 2
pages/FirstBangDing/FirstBangDing.js

@@ -1,5 +1,6 @@
 // pages/FirstBangDing/FirstBangDing.js
 const app = getApp()
+const utils = require('../../utils/util.js')
 
 Page({
 
@@ -103,8 +104,26 @@ Page({
   },
 
   goToBindHuhao() {
+    // 设置标记表示将要进行户号绑定
+    wx.setStorageSync('goingToBindNewAccount', true);
+    // 预先设置refresh标记,这样homepage在加载时就会刷新数据
+    app.globalData.refresh = 1;
+    
+    // 提前将justBoundNewAccount标记设为true
+    // 这样即使从huhaobangding直接跳转到homepage也能正确加载数据
+    wx.setStorageSync('justBoundNewAccount', true);
+    
+    // 跳转到户号绑定页面
     wx.navigateTo({
-      url: '/pages/huhaobangding/huhaobangding'
-    })
+      url: '/pages/huhaobangding/huhaobangding',
+      fail: function(err) {
+        console.error('跳转失败:', err);
+        // 如果跳转失败,清除标记
+        wx.removeStorageSync('goingToBindNewAccount');
+        wx.removeStorageSync('justBoundNewAccount');
+        
+        utils.simleInfo('跳转失败,请稍后再试');
+      }
+    });
   }
 })

+ 102 - 28
pages/homepage/homepage.js

@@ -123,29 +123,48 @@ Page({
         success(res) {
           wx.hideLoading();
           let apiReturnData = res.data;
-          apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
-            data.publishtime = data.publishtime.slice(0, 10);
-          })
-          // 所有的通知公告
-          app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
+          
+          // 处理轮播通知数据
+          if (apiReturnData.data && apiReturnData.data.swNotificationAnnouncementDos) {
+            // 处理日期格式
+            apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
+              if (data.publishtime) {
+                data.publishtime = data.publishtime.slice(0, 10);
+              }
+            });
+            
+            // 所有的通知公告
+            app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
+            
+            // 需要轮播的公告
+            let noticeData = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
+              return data.homepageslider == '1';
+            });
+            
+            // 更新轮播通知数据
+            _this.setData({
+              noticeList: noticeData,
+              isScrolling: noticeData && noticeData.length > 0
+            });
+            
+            // 如果有轮播数据,立即开始轮播
+            if (noticeData && noticeData.length > 0) {
+              _this.startNoticeScroll();
+            }
+          }
+          
           // 该用户所有的消息通知
           app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
-          // 需要轮播的公告
-          let data = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
-            return data.homepageslider == '1';
-          });
+          
+          // 计算未读消息数
           if (app.globalData.userNoticesList) {
-            // 假设 userNoticesList 中有一个 isRead 属性表示消息是否已读
             const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
             _this.setData({
               unreadCount: unreadCount
             });
-          } else {
-            _this.setData({
-              unreadCount: 0
-            });
           }
-
+          
+          // 更新页面数据
           _this.setData({
             billInfo: {
               totalAmount: apiReturnData.data.duFees ?? 0, // 总计应缴
@@ -156,10 +175,8 @@ Page({
               name: apiReturnData.data.username,
               accountNumber: apiReturnData.data.usernumber,
               address: apiReturnData.data.address
-            },
-            noticeList: data,
-            isScrolling: true,
-          })
+            }
+          });
         },
         fail(error) {
           wx.hideLoading()
@@ -256,8 +273,47 @@ Page({
       success(res) {
         wx.hideLoading();
         let apiReturnData = res.data;
+        
+        // 处理轮播通知数据
+        if (apiReturnData.data && apiReturnData.data.swNotificationAnnouncementDos) {
+          // 处理日期格式
+          apiReturnData.data.swNotificationAnnouncementDos.forEach(data => {
+            if (data.publishtime) {
+              data.publishtime = data.publishtime.slice(0, 10);
+            }
+          });
+          
+          // 所有的通知公告
+          app.globalData.notices = apiReturnData.data.swNotificationAnnouncementDos;
+          
+          // 需要轮播的公告
+          let noticeData = apiReturnData.data.swNotificationAnnouncementDos.filter(data => {
+            return data.homepageslider == '1';
+          });
+          
+          // 更新轮播通知数据
+          _this.setData({
+            noticeList: noticeData,
+            isScrolling: noticeData && noticeData.length > 0
+          });
+          
+          // 如果有轮播数据,立即开始轮播
+          if (noticeData && noticeData.length > 0) {
+            _this.startNoticeScroll();
+          }
+        }
+        
         // 该用户所有的消息通知
         app.globalData.userNoticesList = apiReturnData.data.sysNotifyAnnounceUserDos;
+        
+        // 计算未读消息数
+        if (app.globalData.userNoticesList) {
+          const unreadCount = app.globalData.userNoticesList.filter(notice => notice.readstate === '2').length;
+          _this.setData({
+            unreadCount: unreadCount
+          });
+        }
+        
         // 更新页面数据
         _this.setData({
           billInfo: {
@@ -269,7 +325,7 @@ Page({
             name: apiReturnData.data.username,
             accountNumber: apiReturnData.data.usernumber,
             address: apiReturnData.data.address
-          },
+          }
         });
       },
       fail(error) {
@@ -365,18 +421,36 @@ Page({
   },
 
   startNoticeScroll: function () {
-    if (this.data.noticeList.length == 0) {
+    // 检查是否有通知数据
+    if (!this.data.noticeList || this.data.noticeList.length === 0) {
+      console.log('无轮播通知数据');
       return;
     }
-    let data = (this.data.noticeList || []).filter(data => {
+    
+    // 过滤需要轮播的公告
+    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;
-    const duration = (title.length + content.length) * 0.5;
-
+    
+    // 如果没有需要轮播的公告,直接返回
+    if (!data || data.length === 0) {
+      console.log('没有需要轮播的公告');
+      return;
+    }
+    
+    // 确保currentIndex在有效范围内
+    const safeIndex = this.data.currentIndex < data.length ? this.data.currentIndex : 0;
+    
+    // 获取当前公告内容和标题
+    const content = data[safeIndex].scrollingcontent || '';
+    const title = data[safeIndex].noticetitle || '';
+    
+    // 计算滚动时长,基于内容长度
+    const duration = Math.max(3, (title.length + content.length) * 0.5);
+    
+    // 更新数据
     this.setData({
+      currentIndex: safeIndex,
       scrollDuration: duration,
       isScrolling: true,
     });
@@ -696,4 +770,4 @@ Page({
       }
     });
   }
-})
+})

+ 24 - 9
pages/huhaobangding/huhaobangding.js

@@ -19,7 +19,7 @@ Page({
     showWaterCompanyPicker: false,
     
     huHao: '',
-    huMing: '',
+    // huMing: '',
     phone: '',  // 添加手机号字段
     customTag: '',
     tagLength: 0,
@@ -221,13 +221,13 @@ Page({
   },
 
   // 户名输入
-  onHuMingInput: function(e) {
-    // 使用正则表达式去除所有空格
-    const value = e.detail.value.replace(/\s/g, '');
-    this.setData({
-      huMing: value
-    });
-  },
+  // onHuMingInput: function(e) {
+  //   // 使用正则表达式去除所有空格
+  //   const value = e.detail.value.replace(/\s/g, '');
+  //   this.setData({
+  //     huMing: value
+  //   });
+  // },
 
   // 手机号输入
   onPhoneInput: function(e) {
@@ -315,7 +315,7 @@ Page({
     const bindingData = {
       bindWaterCompany: this.data.waterCompanyList[this.data.waterCompanyIndex[0]].id,
       accountNum: this.data.huHao,
-      accountName: this.data.huMing,
+      // accountName: this.data.huMing,
       phoneNum: this.data.phone,  // 添加手机号字段
       groupType: finalTag,  // 使用处理后的标签值
       openId: app.globalData.userWxInfo.openid,
@@ -365,10 +365,17 @@ Page({
           // 设置全局刷新标记
           app.globalData.refresh = 1;
           
+          // 确保homepage能够正确加载轮播通知数据
+          // 增加适当的延迟,确保数据能够正确加载
           setTimeout(function(){
             // 使用reLaunch确保homepage完全重新加载
             wx.reLaunch({
               url: '/pages/homepage/homepage',
+              success: function() {
+                // 当跳转成功后,确保homepage可以正确加载数据
+                // 再次设置justBoundNewAccount标记,确保onLoad和onShow都能正确处理
+                wx.setStorageSync('justBoundNewAccount', true);
+              }
             });
           },2000)
         }else{
@@ -393,6 +400,14 @@ Page({
   },
 
   onLoad: function() {
+    // 检查是否从FirstBangDing页面跳转过来
+    const goingToBindNewAccount = wx.getStorageSync('goingToBindNewAccount');
+    if (goingToBindNewAccount) {
+      // 清除标记
+      wx.removeStorageSync('goingToBindNewAccount');
+      // 不需要额外处理,因为FirstBangDing已经设置了必要的标记
+    }
+    
     // 延迟设置导航栏,确保页面已完全加载
     setTimeout(() => {
       wx.setNavigationBarTitle({

+ 2 - 2
pages/huhaobangding/huhaobangding.wxml

@@ -44,10 +44,10 @@
       <text class="label">手机号<text class="required">*</text></text>
       <input type="number" maxlength="11" placeholder="请输入手机号" placeholder-class="placeholder" bindinput="onPhoneInput" value="{{phone}}" />
     </view>
-    <view class="form-item">
+    <!-- <view class="form-item">
       <text class="label">户名<text class="optional"></text></text>
       <input type="text" maxlength="30" placeholder="请输入户名" placeholder-class="placeholder" bindinput="onHuMingInput" value="{{huMing}}" />
-    </view>
+    </view> -->
   </view>
 
   <view class="group-select">

+ 3 - 3
pages/lijijiaofei/lijijiaofei.js

@@ -88,7 +88,7 @@ Page({
   // 计算默认实缴金额
   calculateDefaultAmount: function() {
     const { actualAmount, balance } = this.data;
-    const difference = actualAmount - balance;
+    const difference = (actualAmount - balance).toFixed(2);
     
     if (difference <= 0) {
       this.setData({
@@ -96,7 +96,7 @@ Page({
       });
     } else {
       this.setData({
-        amount: difference
+        amount: parseFloat(difference)
       });
     }
   },
@@ -136,7 +136,7 @@ Page({
     }
 
     if (actualAmount > 0 && amount + balance < actualAmount) {
-      const minPayment = actualAmount - balance;
+      const minPayment = (actualAmount - balance).toFixed(2);
       wx.showToast({
         title: '最低缴费金额:'+ minPayment + '元',
         icon: 'none'

+ 5 - 2
pages/tongzhiList/tongzhiList.wxss

@@ -8,14 +8,14 @@
 .custom-nav {
   display: flex;
   align-items: center;
-  height: 120rpx;
+  height: 140rpx;
   margin-bottom: 20rpx;
   background-color: #2E82FF;
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
-  z-index: 1000;
+  z-index: 99;
   padding: 0 20rpx;
   padding-top: 44px;
 }
@@ -124,6 +124,7 @@
   align-items: center;
   border-bottom: 1rpx solid #eee;
   background-color: rgba(46, 130, 255, 1);
+  z-index: 999;
 }
 
 .tab-item {
@@ -141,6 +142,8 @@
   font-size: 32rpx;
   font-weight: 400;
   color: white;
+
+  z-index: 9;
 }
 
 .tab-right {

+ 1 - 1
project.private.config.json

@@ -3,7 +3,7 @@
   "projectname": "zhsw_wechat",
   "setting": {
     "compileHotReLoad": true,
-    "urlCheck": false,
+    "urlCheck": true,
     "coverView": true,
     "lazyloadPlaceholderEnable": false,
     "skylineRenderEnable": false,