// pages/index/showBoxDetail/showBoxDetail.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { rtuCode: '', openId: null, rtuName: '', orgName: '', agreement: '', lastTime: '', spaceTime: '', relay: '', relayIp: '', masterIp: '', items: ['远程指令', '基本参数', '运行参数'], commandView: true, baseSettingView: false, runSettingView: false, baseSetting: { newRtuCode: "", ip1: "", ip1port: "", ip2: "", ip2port: "", ip3: "", ip3port: "", ip4: "", ip4port: "" }, runSetting: { datagramTimes: [{ value: '00', name: '5分钟' }, { value: '01', name: '1小时', checked: true }, { value: '02', name: '2小时' }, { value: '03', name: '3小时' }, { value: '04', name: '4小时' }, { value: '06', name: '6小时' }, { value: '08', name: '8小时' }, { value: '12', name: '12小时' }, { value: '24', name: '24小时' } ], addWaterUpValue: "", //sw waterLevelCorrectValue: "", //sw waterLevelBase: "", //sw addIntervalTime: "", //sw intervalTime: "01", //sw agreement: "", szy_intervalTime_setting_00: "", //szy szy_intervalTime_setting_01: "", //szy szy_intervalTime_setting_02: "", //szy szy_intervalTime_setting_03: "", //szy szy_intervalTime_setting_04: "", //szy szy_intervalTime_setting_05: "", //szy szy_intervalTime_setting_06: "", //szy szy_intervalTime_setting_07: "", //szy szy_intervalTime_setting_08: "", //szy szy_intervalTime_setting_09: "", //szy szy_intervalTime_setting_10: "", //szy szy_intervalTime_setting_10: "", //szy szy_intervalTime_setting_11: "", //szy szy_intervalTime_setting_12: "", //szy szy_intervalTime_setting_13: "", //szy } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const rtuCode = options.rtuCode; console.log(rtuCode); const openId = options.openId; const agreement = options.agreement; var runSetting = this.data.runSetting; runSetting.agreement = agreement; this.setData({ rtuCode: rtuCode, openId: openId, agreement: agreement, runSetting: runSetting }) }, waterLevelInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.szy_intervalTime_setting_01 = e.detail.value; this.setData({ runSetting: runSetting }) }, flowRateInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.szy_intervalTime_setting_02 = e.detail.value; this.setData({ runSetting: runSetting }) }, flowSpeedInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.szy_intervalTime_setting_03 = e.detail.value; this.setData({ runSetting: runSetting }) }, addDatagramInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.addIntervalTime = e.detail.value; this.setData({ runSetting: runSetting }) }, waterBaseValueInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.waterLevelBase = e.detail.value; this.setData({ runSetting: runSetting }) }, waterCorrectValueInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.waterLevelCorrectValue = e.detail.value; this.setData({ runSetting: runSetting }) }, upWaterLevelInputHandle: function (e) { var runSetting = this.data.runSetting; runSetting.addWaterUpValue = e.detail.value; this.setData({ runSetting: runSetting }) }, bindNewRtuCodeInput: function (e) { var baseSetting = this.data.baseSetting; baseSetting.newRtuCode = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp1Input: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip1 = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp2Input: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip2 = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp3Input: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip3 = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp4Input: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip4 = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp1portInput: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip1port = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp2portInput: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip2port = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp3portInput: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip3port = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindIp4portInput: function (e) { var baseSetting = this.data.baseSetting; baseSetting.ip4port = e.detail.value; this.setData({ baseSetting: baseSetting }) }, bindWaterHighTimeInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindFlowRateTimeInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindFlowSpeedTimeInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindAddDatagramTimeInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindWaterBaseCorrectValueInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindwaterBaseValueInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, bindUpWaterHightValueInput: function (e) { this.setData({ rtuCode: e.detail.value }) }, onGetRtuVersion: function (event) { wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Setting/" + that.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openId: that.data.openId }, header: { "Content-Type": "json" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { } else { wx.showToast({ title: 'RTU版本号查询失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) }, onGetRtuClock: function (event) { wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Setting/" + that.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openId: that.data.openId }, header: { "Content-Type": "json" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { } else { wx.showToast({ title: 'RTU时钟查询失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) }, onRtuClockSet: function (event) { const that = this; wx.showModal({ title: '提示', content: '确定同步RTU时钟?', success: function (res) { if (res.confirm) { //这里是点击了确定以后 wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Clock/" + that.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openId: that.data.openId }, header: { "Content-Type": "json" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { wx.showToast({ title: 'RTU时钟同步指令已成功发送!', icon: 'none', duration: 1000 //持续的时间 }) } else { wx.showToast({ title: 'RTU时钟同步指令发送失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) } else { //这里是点击了取消以后 //console.log('用户点击取消') } } }) }, onRtuReset: function (event) { const that = this; wx.showModal({ title: '提示', content: '确定恢复RTU出厂设置?', success: function (res) { if (res.confirm) { //这里是点击了确定以后 wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Reset/" + that.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openId: that.data.openId }, header: { "Content-Type": "json" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { wx.showToast({ title: '恢复RTU出厂设置指令已成功发送!', icon: 'none', duration: 1000 //持续的时间 }) } else { wx.showToast({ title: '恢复RTU出厂设置指令发送失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) } else { //这里是点击了取消以后 //console.log('用户点击取消') } } }) }, onRtuReboot: function (event) { const that = this; wx.showModal({ title: '提示', content: '确定重启RTU设备?', success: function (res) { if (res.confirm) { //这里是点击了确定以后 wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Reboot/" + that.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openId: that.data.openId }, header: { "Content-Type": "json" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { wx.showToast({ title: 'RTU设备重启指令已成功发送!', icon: 'none', duration: 1000 //持续的时间 }) } else { wx.showToast({ title: 'RTU设备重启指令发送失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) } else { //这里是点击了取消以后 //console.log('用户点击取消') } } }) }, submitRunsetting: function (e) { const that = this; wx.showModal({ title: '提示', content: '确定提交配置?', success: function (res) { if (res.confirm) { //这里是点击了确定以后 wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Runsetting/" + that.data.rtuCode; wx.request({ url: url, method: 'POST', data: { openId: that.data.openId, runSetting: JSON.stringify(that.data.runSetting) }, header: { "Content-Type": "application/x-www-form-urlencoded" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { wx.showToast({ title: '配置指令已成功发送!', icon: 'none', duration: 1000 //持续的时间 }) } else { wx.showToast({ title: '配置指令发送失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) } else { //这里是点击了取消以后 //console.log('用户点击取消') } } }) }, submitBasesetting: function (e) { const that = this; wx.showModal({ title: '提示', content: '确定提交配置?', success: function (res) { if (res.confirm) { //这里是点击了确定以后 wx.showNavigationBarLoading() var url = app.globalData.cloudBase + "/Wx/Rtu/Basesetting/" + that.data.rtuCode; wx.request({ url: url, method: 'POST', data: { openId: that.data.openId, baseSetting: JSON.stringify(that.data.baseSetting) }, header: { "Content-Type": "application/x-www-form-urlencoded" }, success: function (res) { wx.hideNavigationBarLoading(); if (res.data.code === "0") { wx.showToast({ title: '配置指令已成功发送!', icon: 'none', duration: 1000 //持续的时间 }) } else { wx.showToast({ title: '配置指令发送失败!', icon: 'none', duration: 1000 //持续的时间 }) } }, fail: function (error) { wx.hideNavigationBarLoading(); wx.showToast({ title: '服务器请求失败!', icon: 'none', duration: 1000 //持续的时间 }) } }) } else { //这里是点击了取消以后 //console.log('用户点击取消') } } }) }, radioChange: function (e) { //console.log('radio发生change事件,携带value值为:', e.detail.value); var runSetting = this.data.runSetting; runSetting.intervalTime = e.detail.value; var radioItems = this.data.runSetting.datagramTimes; for (var i = 0, len = radioItems.length; i < len; ++i) { radioItems[i].checked = radioItems[i].value == e.detail.value; } runSetting.datagramTimes = radioItems; this.setData({ runSetting: runSetting }); }, onItemtap: function (event) { console.log(event); const pageIndex = event.detail.currentTarget.dataset.index; if (pageIndex == 0) { this.setData({ commandView: true, baseSettingView: false, runSettingView: false }); } else if (pageIndex == 1) { this.setData({ commandView: false, baseSettingView: true, runSettingView: false }); } else if (pageIndex == 2) { this.setData({ commandView: false, baseSettingView: false, runSettingView: true }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })