setting.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. // pages/index/showBoxDetail/showBoxDetail.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. rtuCode: '',
  9. openId: null,
  10. rtuName: '',
  11. orgName: '',
  12. agreement: '',
  13. lastTime: '',
  14. spaceTime: '',
  15. relay: '',
  16. relayIp: '',
  17. masterIp: '',
  18. items: ['远程指令', '基本参数', '运行参数'],
  19. commandView: true,
  20. baseSettingView: false,
  21. runSettingView: false,
  22. baseSetting: {
  23. newRtuCode: "",
  24. ip1: "",
  25. ip1port: "",
  26. ip2: "",
  27. ip2port: "",
  28. ip3: "",
  29. ip3port: "",
  30. ip4: "",
  31. ip4port: ""
  32. },
  33. runSetting: {
  34. datagramTimes: [{
  35. value: '00',
  36. name: '5分钟'
  37. },
  38. {
  39. value: '01',
  40. name: '1小时',
  41. checked: true
  42. },
  43. {
  44. value: '02',
  45. name: '2小时'
  46. },
  47. {
  48. value: '03',
  49. name: '3小时'
  50. },
  51. {
  52. value: '04',
  53. name: '4小时'
  54. },
  55. {
  56. value: '06',
  57. name: '6小时'
  58. },
  59. {
  60. value: '08',
  61. name: '8小时'
  62. },
  63. {
  64. value: '12',
  65. name: '12小时'
  66. },
  67. {
  68. value: '24',
  69. name: '24小时'
  70. }
  71. ],
  72. addWaterUpValue: "", //sw
  73. waterLevelCorrectValue: "", //sw
  74. waterLevelBase: "", //sw
  75. addIntervalTime: "", //sw
  76. intervalTime: "01", //sw
  77. agreement: "",
  78. szy_intervalTime_setting_00: "", //szy
  79. szy_intervalTime_setting_01: "", //szy
  80. szy_intervalTime_setting_02: "", //szy
  81. szy_intervalTime_setting_03: "", //szy
  82. szy_intervalTime_setting_04: "", //szy
  83. szy_intervalTime_setting_05: "", //szy
  84. szy_intervalTime_setting_06: "", //szy
  85. szy_intervalTime_setting_07: "", //szy
  86. szy_intervalTime_setting_08: "", //szy
  87. szy_intervalTime_setting_09: "", //szy
  88. szy_intervalTime_setting_10: "", //szy
  89. szy_intervalTime_setting_10: "", //szy
  90. szy_intervalTime_setting_11: "", //szy
  91. szy_intervalTime_setting_12: "", //szy
  92. szy_intervalTime_setting_13: "", //szy
  93. }
  94. },
  95. /**
  96. * 生命周期函数--监听页面加载
  97. */
  98. onLoad: function (options) {
  99. const rtuCode = options.rtuCode;
  100. console.log(rtuCode);
  101. const openId = options.openId;
  102. const agreement = options.agreement;
  103. var runSetting = this.data.runSetting;
  104. runSetting.agreement = agreement;
  105. this.setData({
  106. rtuCode: rtuCode,
  107. openId: openId,
  108. agreement: agreement,
  109. runSetting: runSetting
  110. })
  111. },
  112. waterLevelInputHandle: function (e) {
  113. var runSetting = this.data.runSetting;
  114. runSetting.szy_intervalTime_setting_01 = e.detail.value;
  115. this.setData({
  116. runSetting: runSetting
  117. })
  118. },
  119. flowRateInputHandle: function (e) {
  120. var runSetting = this.data.runSetting;
  121. runSetting.szy_intervalTime_setting_02 = e.detail.value;
  122. this.setData({
  123. runSetting: runSetting
  124. })
  125. },
  126. flowSpeedInputHandle: function (e) {
  127. var runSetting = this.data.runSetting;
  128. runSetting.szy_intervalTime_setting_03 = e.detail.value;
  129. this.setData({
  130. runSetting: runSetting
  131. })
  132. },
  133. addDatagramInputHandle: function (e) {
  134. var runSetting = this.data.runSetting;
  135. runSetting.addIntervalTime = e.detail.value;
  136. this.setData({
  137. runSetting: runSetting
  138. })
  139. },
  140. waterBaseValueInputHandle: function (e) {
  141. var runSetting = this.data.runSetting;
  142. runSetting.waterLevelBase = e.detail.value;
  143. this.setData({
  144. runSetting: runSetting
  145. })
  146. },
  147. waterCorrectValueInputHandle: function (e) {
  148. var runSetting = this.data.runSetting;
  149. runSetting.waterLevelCorrectValue = e.detail.value;
  150. this.setData({
  151. runSetting: runSetting
  152. })
  153. },
  154. upWaterLevelInputHandle: function (e) {
  155. var runSetting = this.data.runSetting;
  156. runSetting.addWaterUpValue = e.detail.value;
  157. this.setData({
  158. runSetting: runSetting
  159. })
  160. },
  161. bindNewRtuCodeInput: function (e) {
  162. var baseSetting = this.data.baseSetting;
  163. baseSetting.newRtuCode = e.detail.value;
  164. this.setData({
  165. baseSetting: baseSetting
  166. })
  167. },
  168. bindIp1Input: function (e) {
  169. var baseSetting = this.data.baseSetting;
  170. baseSetting.ip1 = e.detail.value;
  171. this.setData({
  172. baseSetting: baseSetting
  173. })
  174. },
  175. bindIp2Input: function (e) {
  176. var baseSetting = this.data.baseSetting;
  177. baseSetting.ip2 = e.detail.value;
  178. this.setData({
  179. baseSetting: baseSetting
  180. })
  181. },
  182. bindIp3Input: function (e) {
  183. var baseSetting = this.data.baseSetting;
  184. baseSetting.ip3 = e.detail.value;
  185. this.setData({
  186. baseSetting: baseSetting
  187. })
  188. },
  189. bindIp4Input: function (e) {
  190. var baseSetting = this.data.baseSetting;
  191. baseSetting.ip4 = e.detail.value;
  192. this.setData({
  193. baseSetting: baseSetting
  194. })
  195. },
  196. bindIp1portInput: function (e) {
  197. var baseSetting = this.data.baseSetting;
  198. baseSetting.ip1port = e.detail.value;
  199. this.setData({
  200. baseSetting: baseSetting
  201. })
  202. },
  203. bindIp2portInput: function (e) {
  204. var baseSetting = this.data.baseSetting;
  205. baseSetting.ip2port = e.detail.value;
  206. this.setData({
  207. baseSetting: baseSetting
  208. })
  209. },
  210. bindIp3portInput: function (e) {
  211. var baseSetting = this.data.baseSetting;
  212. baseSetting.ip3port = e.detail.value;
  213. this.setData({
  214. baseSetting: baseSetting
  215. })
  216. },
  217. bindIp4portInput: function (e) {
  218. var baseSetting = this.data.baseSetting;
  219. baseSetting.ip4port = e.detail.value;
  220. this.setData({
  221. baseSetting: baseSetting
  222. })
  223. },
  224. bindWaterHighTimeInput: function (e) {
  225. this.setData({
  226. rtuCode: e.detail.value
  227. })
  228. },
  229. bindFlowRateTimeInput: function (e) {
  230. this.setData({
  231. rtuCode: e.detail.value
  232. })
  233. },
  234. bindFlowSpeedTimeInput: function (e) {
  235. this.setData({
  236. rtuCode: e.detail.value
  237. })
  238. },
  239. bindAddDatagramTimeInput: function (e) {
  240. this.setData({
  241. rtuCode: e.detail.value
  242. })
  243. },
  244. bindWaterBaseCorrectValueInput: function (e) {
  245. this.setData({
  246. rtuCode: e.detail.value
  247. })
  248. },
  249. bindwaterBaseValueInput: function (e) {
  250. this.setData({
  251. rtuCode: e.detail.value
  252. })
  253. },
  254. bindUpWaterHightValueInput: function (e) {
  255. this.setData({
  256. rtuCode: e.detail.value
  257. })
  258. },
  259. onGetRtuVersion: function (event) {
  260. wx.showNavigationBarLoading()
  261. var url = app.globalData.cloudBase + "/Wx/Rtu/Setting/" + that.data.rtuCode;
  262. wx.request({
  263. url: url,
  264. method: 'GET',
  265. data: {
  266. openId: that.data.openId
  267. },
  268. header: {
  269. "Content-Type": "json"
  270. },
  271. success: function (res) {
  272. wx.hideNavigationBarLoading();
  273. if (res.data.code === "0") {
  274. } else {
  275. wx.showToast({
  276. title: 'RTU版本号查询失败!',
  277. icon: 'none',
  278. duration: 1000 //持续的时间
  279. })
  280. }
  281. },
  282. fail: function (error) {
  283. wx.hideNavigationBarLoading();
  284. wx.showToast({
  285. title: '服务器请求失败!',
  286. icon: 'none',
  287. duration: 1000 //持续的时间
  288. })
  289. }
  290. })
  291. },
  292. onGetRtuClock: function (event) {
  293. wx.showNavigationBarLoading()
  294. var url = app.globalData.cloudBase + "/Wx/Rtu/Setting/" + that.data.rtuCode;
  295. wx.request({
  296. url: url,
  297. method: 'GET',
  298. data: {
  299. openId: that.data.openId
  300. },
  301. header: {
  302. "Content-Type": "json"
  303. },
  304. success: function (res) {
  305. wx.hideNavigationBarLoading();
  306. if (res.data.code === "0") {
  307. } else {
  308. wx.showToast({
  309. title: 'RTU时钟查询失败!',
  310. icon: 'none',
  311. duration: 1000 //持续的时间
  312. })
  313. }
  314. },
  315. fail: function (error) {
  316. wx.hideNavigationBarLoading();
  317. wx.showToast({
  318. title: '服务器请求失败!',
  319. icon: 'none',
  320. duration: 1000 //持续的时间
  321. })
  322. }
  323. })
  324. },
  325. onRtuClockSet: function (event) {
  326. const that = this;
  327. wx.showModal({
  328. title: '提示',
  329. content: '确定同步RTU时钟?',
  330. success: function (res) {
  331. if (res.confirm) {
  332. //这里是点击了确定以后
  333. wx.showNavigationBarLoading()
  334. var url = app.globalData.cloudBase + "/Wx/Rtu/Clock/" + that.data.rtuCode;
  335. wx.request({
  336. url: url,
  337. method: 'GET',
  338. data: {
  339. openId: that.data.openId
  340. },
  341. header: {
  342. "Content-Type": "json"
  343. },
  344. success: function (res) {
  345. wx.hideNavigationBarLoading();
  346. if (res.data.code === "0") {
  347. wx.showToast({
  348. title: 'RTU时钟同步指令已成功发送!',
  349. icon: 'none',
  350. duration: 1000 //持续的时间
  351. })
  352. } else {
  353. wx.showToast({
  354. title: 'RTU时钟同步指令发送失败!',
  355. icon: 'none',
  356. duration: 1000 //持续的时间
  357. })
  358. }
  359. },
  360. fail: function (error) {
  361. wx.hideNavigationBarLoading();
  362. wx.showToast({
  363. title: '服务器请求失败!',
  364. icon: 'none',
  365. duration: 1000 //持续的时间
  366. })
  367. }
  368. })
  369. } else {
  370. //这里是点击了取消以后
  371. //console.log('用户点击取消')
  372. }
  373. }
  374. })
  375. },
  376. onRtuReset: function (event) {
  377. const that = this;
  378. wx.showModal({
  379. title: '提示',
  380. content: '确定恢复RTU出厂设置?',
  381. success: function (res) {
  382. if (res.confirm) {
  383. //这里是点击了确定以后
  384. wx.showNavigationBarLoading()
  385. var url = app.globalData.cloudBase + "/Wx/Rtu/Reset/" + that.data.rtuCode;
  386. wx.request({
  387. url: url,
  388. method: 'GET',
  389. data: {
  390. openId: that.data.openId
  391. },
  392. header: {
  393. "Content-Type": "json"
  394. },
  395. success: function (res) {
  396. wx.hideNavigationBarLoading();
  397. if (res.data.code === "0") {
  398. wx.showToast({
  399. title: '恢复RTU出厂设置指令已成功发送!',
  400. icon: 'none',
  401. duration: 1000 //持续的时间
  402. })
  403. } else {
  404. wx.showToast({
  405. title: '恢复RTU出厂设置指令发送失败!',
  406. icon: 'none',
  407. duration: 1000 //持续的时间
  408. })
  409. }
  410. },
  411. fail: function (error) {
  412. wx.hideNavigationBarLoading();
  413. wx.showToast({
  414. title: '服务器请求失败!',
  415. icon: 'none',
  416. duration: 1000 //持续的时间
  417. })
  418. }
  419. })
  420. } else {
  421. //这里是点击了取消以后
  422. //console.log('用户点击取消')
  423. }
  424. }
  425. })
  426. },
  427. onRtuReboot: function (event) {
  428. const that = this;
  429. wx.showModal({
  430. title: '提示',
  431. content: '确定重启RTU设备?',
  432. success: function (res) {
  433. if (res.confirm) {
  434. //这里是点击了确定以后
  435. wx.showNavigationBarLoading()
  436. var url = app.globalData.cloudBase + "/Wx/Rtu/Reboot/" + that.data.rtuCode;
  437. wx.request({
  438. url: url,
  439. method: 'GET',
  440. data: {
  441. openId: that.data.openId
  442. },
  443. header: {
  444. "Content-Type": "json"
  445. },
  446. success: function (res) {
  447. wx.hideNavigationBarLoading();
  448. if (res.data.code === "0") {
  449. wx.showToast({
  450. title: 'RTU设备重启指令已成功发送!',
  451. icon: 'none',
  452. duration: 1000 //持续的时间
  453. })
  454. } else {
  455. wx.showToast({
  456. title: 'RTU设备重启指令发送失败!',
  457. icon: 'none',
  458. duration: 1000 //持续的时间
  459. })
  460. }
  461. },
  462. fail: function (error) {
  463. wx.hideNavigationBarLoading();
  464. wx.showToast({
  465. title: '服务器请求失败!',
  466. icon: 'none',
  467. duration: 1000 //持续的时间
  468. })
  469. }
  470. })
  471. } else {
  472. //这里是点击了取消以后
  473. //console.log('用户点击取消')
  474. }
  475. }
  476. })
  477. },
  478. submitRunsetting: function (e) {
  479. const that = this;
  480. wx.showModal({
  481. title: '提示',
  482. content: '确定提交配置?',
  483. success: function (res) {
  484. if (res.confirm) {
  485. //这里是点击了确定以后
  486. wx.showNavigationBarLoading()
  487. var url = app.globalData.cloudBase + "/Wx/Rtu/Runsetting/" + that.data.rtuCode;
  488. wx.request({
  489. url: url,
  490. method: 'POST',
  491. data: {
  492. openId: that.data.openId,
  493. runSetting: JSON.stringify(that.data.runSetting)
  494. },
  495. header: {
  496. "Content-Type": "application/x-www-form-urlencoded"
  497. },
  498. success: function (res) {
  499. wx.hideNavigationBarLoading();
  500. if (res.data.code === "0") {
  501. wx.showToast({
  502. title: '配置指令已成功发送!',
  503. icon: 'none',
  504. duration: 1000 //持续的时间
  505. })
  506. } else {
  507. wx.showToast({
  508. title: '配置指令发送失败!',
  509. icon: 'none',
  510. duration: 1000 //持续的时间
  511. })
  512. }
  513. },
  514. fail: function (error) {
  515. wx.hideNavigationBarLoading();
  516. wx.showToast({
  517. title: '服务器请求失败!',
  518. icon: 'none',
  519. duration: 1000 //持续的时间
  520. })
  521. }
  522. })
  523. } else {
  524. //这里是点击了取消以后
  525. //console.log('用户点击取消')
  526. }
  527. }
  528. })
  529. },
  530. submitBasesetting: function (e) {
  531. const that = this;
  532. wx.showModal({
  533. title: '提示',
  534. content: '确定提交配置?',
  535. success: function (res) {
  536. if (res.confirm) {
  537. //这里是点击了确定以后
  538. wx.showNavigationBarLoading()
  539. var url = app.globalData.cloudBase + "/Wx/Rtu/Basesetting/" + that.data.rtuCode;
  540. wx.request({
  541. url: url,
  542. method: 'POST',
  543. data: {
  544. openId: that.data.openId,
  545. baseSetting: JSON.stringify(that.data.baseSetting)
  546. },
  547. header: {
  548. "Content-Type": "application/x-www-form-urlencoded"
  549. },
  550. success: function (res) {
  551. wx.hideNavigationBarLoading();
  552. if (res.data.code === "0") {
  553. wx.showToast({
  554. title: '配置指令已成功发送!',
  555. icon: 'none',
  556. duration: 1000 //持续的时间
  557. })
  558. } else {
  559. wx.showToast({
  560. title: '配置指令发送失败!',
  561. icon: 'none',
  562. duration: 1000 //持续的时间
  563. })
  564. }
  565. },
  566. fail: function (error) {
  567. wx.hideNavigationBarLoading();
  568. wx.showToast({
  569. title: '服务器请求失败!',
  570. icon: 'none',
  571. duration: 1000 //持续的时间
  572. })
  573. }
  574. })
  575. } else {
  576. //这里是点击了取消以后
  577. //console.log('用户点击取消')
  578. }
  579. }
  580. })
  581. },
  582. radioChange: function (e) {
  583. //console.log('radio发生change事件,携带value值为:', e.detail.value);
  584. var runSetting = this.data.runSetting;
  585. runSetting.intervalTime = e.detail.value;
  586. var radioItems = this.data.runSetting.datagramTimes;
  587. for (var i = 0, len = radioItems.length; i < len; ++i) {
  588. radioItems[i].checked = radioItems[i].value == e.detail.value;
  589. }
  590. runSetting.datagramTimes = radioItems;
  591. this.setData({
  592. runSetting: runSetting
  593. });
  594. },
  595. onItemtap: function (event) {
  596. console.log(event);
  597. const pageIndex = event.detail.currentTarget.dataset.index;
  598. if (pageIndex == 0) {
  599. this.setData({
  600. commandView: true,
  601. baseSettingView: false,
  602. runSettingView: false
  603. });
  604. } else if (pageIndex == 1) {
  605. this.setData({
  606. commandView: false,
  607. baseSettingView: true,
  608. runSettingView: false
  609. });
  610. } else if (pageIndex == 2) {
  611. this.setData({
  612. commandView: false,
  613. baseSettingView: false,
  614. runSettingView: true
  615. });
  616. }
  617. },
  618. /**
  619. * 生命周期函数--监听页面初次渲染完成
  620. */
  621. onReady: function () {
  622. },
  623. /**
  624. * 生命周期函数--监听页面显示
  625. */
  626. onShow: function () {
  627. },
  628. /**
  629. * 生命周期函数--监听页面隐藏
  630. */
  631. onHide: function () {
  632. },
  633. /**
  634. * 生命周期函数--监听页面卸载
  635. */
  636. onUnload: function () {
  637. },
  638. /**
  639. * 页面相关事件处理函数--监听用户下拉动作
  640. */
  641. onPullDownRefresh: function () {
  642. },
  643. /**
  644. * 页面上拉触底事件的处理函数
  645. */
  646. onReachBottom: function () {
  647. },
  648. /**
  649. * 用户点击右上角分享
  650. */
  651. onShareAppMessage: function () {
  652. }
  653. })