| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 |
- // 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 () {
- }
- })
|