| | |
| | | showForceConfirm: false, //是否强制开阀 |
| | | lastIntakeName: "", |
| | | isLogin: false, //是否已经登录 |
| | | showInfoDialog: false, |
| | | showTipDialog: false, |
| | | options: '', |
| | | }, |
| | | |
| | | openValve: function (e) { |
| | |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | calculateScrollViewHeight: function () { |
| | | wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { |
| | |
| | | }).exec(); |
| | | }, |
| | | startPullDownRefresh() { |
| | | if(this.data.isLogin){ |
| | | if (this.data.isLogin) { |
| | | if (!this.data.isWXRefreshing) { |
| | | var self = this; |
| | | console.log(this.data.isRefreshing); |
| | |
| | | }); |
| | | this.getOpenList(); |
| | | } |
| | | }else{ |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | |
| | | }, |
| | | //获取用户数据 |
| | | getUserData() { |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | // 使用 wx.nextTick 等待页面渲染完成 |
| | | wx.nextTick(() => { |
| | | this.calculateScrollViewHeight(); |
| | | }); |
| | | //当开阀成功后调用刷新 |
| | | console.log("onLoad:" + options.param); |
| | | if (options.param) { |
| | | wx.showToast({ |
| | | title: '开阀成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | this.setData({ |
| | | options: options, |
| | | isLogin: true, |
| | | }) |
| | | this.getOpenList(); |
| | | } |
| | | |
| | | }, |
| | |
| | | const app = getApp(); |
| | | storage.getItem('sessionId').then((data) => { |
| | | app.globalData.sessionId = data; |
| | | this.setData({ |
| | | isLogin: true |
| | | }) |
| | | if (app.globalData.sessionId) { |
| | | this.getOpenList(); |
| | | this.getUserDataBySession(); |
| | |
| | | } else { |
| | | //本地没有缓存微信登录 |
| | | this.wxLogin(); |
| | | } |
| | | if (this.data.options.param) { |
| | | this.setData({ |
| | | |
| | | showTipDialog: true, |
| | | tipData: "开阀命令下发成功,稍后请刷新快速关阀列表查看执行结果。" |
| | | }) |
| | | this.getOpenList(); |
| | | } |
| | | }, |
| | | wxLogin() { |
| | |
| | | this.setData({ |
| | | showConfirm: false, |
| | | showErrorDialog: false, |
| | | showForceConfirm: false |
| | | showForceConfirm: false, |
| | | showTipDialog: false |
| | | }); |
| | | }, |
| | | cancelDialog() { |
| | | this.setData({ |
| | | showForceConfirm: false, |
| | | showConfirm: false |
| | | showConfirm: false, |
| | | showTipDialog: false |
| | | }); |
| | | }, |
| | | /** |
| | |
| | | wx.hideLoading(); |
| | | this.getOpenList(); |
| | | if (response.content.data.success) { |
| | | wx.showToast({ |
| | | title: '关阀成功', |
| | | icon: 'success', |
| | | duration: 3000 |
| | | this.setData({ |
| | | isLogin: true, |
| | | showTipDialog: true, |
| | | tipData: "关阀命令下发成功,稍后请刷新快速关阀列表查看执行结果。" |
| | | }) |
| | | this.getOpenList(); |
| | | } else { |
| | | wx.showToast({ |
| | | title: '关阀失败', |
| | | title: '命令执行失败', |
| | | icon: 'error', |
| | | duration: 3000 |
| | | }) |
| | |
| | | * 获取为关阀记录 |
| | | */ |
| | | getOpenList() { |
| | | const app = getApp(); |
| | | const params = { |
| | | url: 'wx/valve/get', |
| | | data: { |
| | | operator: app.globalData.sessionId |
| | | } |
| | | }; |
| | | get(params).then(data => { |
| | | this.setData({ |
| | | listData: data.content, |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | this.updateDisplayText(); |
| | | }).catch(err => { |
| | | // 错误回调 |
| | | this.setData({ |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | if (this.data.isLogin) { |
| | | const app = getApp(); |
| | | const params = { |
| | | url: 'wx/valve/get', |
| | | data: { |
| | | operator: app.globalData.sessionId |
| | | } |
| | | }; |
| | | get(params).then(data => { |
| | | this.setData({ |
| | | listData: data.content, |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | this.updateDisplayText(); |
| | | }).catch(err => { |
| | | // 错误回调 |
| | | this.setData({ |
| | | isRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为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, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | isWXRefreshing: false, // 将triggered属性设置为false,表示下拉刷新已完成 |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | /** |
| | | * 确认关闭回调 |
| | |
| | | * 扫码开阀 |
| | | */ |
| | | 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); |
| | | } |
| | | }, |
| | | fail(err) { |
| | | console.error(err); |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: '请先登录', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | confirmForceDialog() { |
| | | console.log("confirmForceDialog"); |
| | |
| | | unbind() { |
| | | //清空数据 |
| | | this.setData({ |
| | | userPhone: "请登录", |
| | | userName: "未登录", |
| | | userPhone: "未登录", |
| | | userName: "请登录", |
| | | listData: [] |
| | | }) |
| | | wx.showLoading({ |
| | |
| | | userPhone: "请登录", |
| | | userName: "未登录", |
| | | listData: [], |
| | | isLogin:false |
| | | isLogin: false |
| | | }) |
| | | app.globalData.sessionId = ""; |
| | | app.globalData.clientId = "" |
| | |
| | | // 处理错误响应 |
| | | console.error('请求失败:', error); |
| | | }); |
| | | }, |
| | | //点击提示按钮 |
| | | infoShow() { |
| | | this.setData({ |
| | | showInfoDialog: true |
| | | }) |
| | | }, |
| | | //提示窗确认按钮 |
| | | confirmBtnInfoDialog() { |
| | | this.setData({ |
| | | showInfoDialog: false |
| | | }) |
| | | } |
| | | }) |