| | |
| | | }) |
| | | } |
| | | }, |
| | | calculateScrollViewHeight: function () { |
| | | wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { |
| | | let totalHeight = rects.reduce((sum, rect) => sum + rect.height, 0); |
| | | this.setData({ |
| | | scrollViewHeight: totalHeight, |
| | | }); |
| | | }).exec(); |
| | | }, |
| | | // calculateScrollViewHeight: function () { |
| | | // wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { |
| | | // let totalHeight = rects.reduce((sum, rect) => sum + rect.height, 0); |
| | | // this.setData({ |
| | | // scrollViewHeight: totalHeight, |
| | | // }); |
| | | // }).exec(); |
| | | // }, |
| | | startPullDownRefresh() { |
| | | if (getApp().globalData.isLoggedIn) { |
| | | if (!this.data.isWXRefreshing) { |
| | |
| | | }) |
| | | }, |
| | | openValveList() { |
| | | // wx.navigateTo({ |
| | | // url: '/pages/valveList/valveList', |
| | | // }) |
| | | wx.showToast({ |
| | | title: '暂未开放', |
| | | icon: 'none' |
| | | const app = getApp(); |
| | | if (app.globalData.isLoggedIn) { |
| | | wx.navigateTo({ |
| | | url: '/pages/valveList/valveList', |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | }, |
| | | feedBack() { |
| | | wx.showToast({ |
| | |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }); |
| | | this.updateDisplayText(); |
| | | |
| | | // 成功获取数据后刷新UI高度 |
| | | setTimeout(() => { |
| | | this.calculateScrollViewHeight(); |
| | | }, 200); |
| | | }).catch(err => { |
| | | console.error('获取列表数据失败:', err); |
| | | // 错误回调 |
| | |
| | | console.log('continueInitPage: 从页面数据中检测到isFromLogin=true'); |
| | | fromLogin = true; |
| | | } |
| | | |
| | | // 判断本地是否保存sessionId |
| | | // 使用 wx.nextTick 等待页面渲染完成 |
| | | wx.nextTick(() => { |
| | | this.calculateScrollViewHeight(); |
| | | }); |
| | | |
| | | // 当开阀成功后调用刷新 |
| | | if (options && options.param) { |
| | | console.log("开阀成功参数:", options.param); |
| | |
| | | showInfoDialog: false |
| | | }) |
| | | }, |
| | | //强制删除 |
| | | onDelete(e) { |
| | | const item = e.currentTarget.dataset.item; |
| | | const that = this; |
| | | |
| | | if (this.data.useTestData) { |
| | | // 测试数据模式下,模拟删除操作 |
| | | wx.showLoading({ |
| | | title: '正在强制删除请稍候...', |
| | | 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: '正在强制删除请稍候...', // 加载提示文字 |
| | | mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false |
| | | }); |
| | | const data = { |
| | | vcNum: item.vcNum, //取水口ID |
| | | 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 |
| | | }); |
| | | }, |
| | | //处理时间去掉年月日 |
| | | 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}`; |
| | | }, |
| | | |
| | | }) |