showBoxDetail.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. items: ['状态信息', '报文信息', '基本信息'],
  12. baseView: false,
  13. statusView: true,
  14. datagramView: false,
  15. baseInfo: {},
  16. statusInfo: {},
  17. datagramInfo: {}
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. //var imageName = options.imageName;
  24. var rtuCode = options.rtuCode; //注意,此赋值方法不是微信官方赋值方法,页面奖无法获取数据
  25. console.log(rtuCode);
  26. var openId = options.openId;
  27. this.setData({
  28. rtuCode: rtuCode,
  29. openId: openId
  30. })
  31. wx.showNavigationBarLoading()
  32. var that = this;
  33. var url = app.globalData.cloudBase + "/Wx/Rtu/" + this.data.rtuCode;
  34. wx.request({
  35. url: url,
  36. method: 'GET',
  37. data: {
  38. openid: this.data.openId
  39. },
  40. header: {
  41. "Content-Type": "json"
  42. },
  43. success: function (res) {
  44. if (res.data.code === "0") {
  45. console.log(res.data.data)
  46. var name = res.data.data.rtuName;
  47. var baseInfo = res.data.data.baseInfo;
  48. var statusInfo = res.data.data.statusInfo;
  49. var datagramInfo = res.data.data.datagramInfo;
  50. wx.setNavigationBarTitle({
  51. title: name
  52. })
  53. that.setData({
  54. rtuName: name,
  55. baseInfo: baseInfo,
  56. statusInfo: statusInfo,
  57. datagramInfo: datagramInfo
  58. })
  59. }
  60. },
  61. fail: function (error) {
  62. console.log(error)
  63. }
  64. })
  65. wx.hideNavigationBarLoading();
  66. },
  67. show_move_s: function () {
  68. var publish_button_state = this.data.publish_button_state;
  69. console.debug("move+++++++++++++++++++++++++++ " + publish_button_state);
  70. this.setData({
  71. publish_button_state: true
  72. })
  73. },
  74. show_move_h: function () {
  75. var publish_button_state = this.data.publish_button_state;
  76. console.debug("move+++++++++++++++++++++++++++ " + publish_button_state);
  77. this.setData({
  78. publish_button_state: false
  79. })
  80. },
  81. onItemtap: function (event) {
  82. console.log(event);
  83. const pageIndex = event.detail.currentTarget.dataset.index;
  84. if (pageIndex == 0) {
  85. this.setData({
  86. statusView: true,
  87. datagramView: false,
  88. baseView: false
  89. });
  90. } else if (pageIndex == 1) {
  91. this.setData({
  92. statusView: false,
  93. datagramView: true,
  94. baseView: false
  95. });
  96. } else if (pageIndex == 2) {
  97. this.setData({
  98. statusView: false,
  99. datagramView: false,
  100. baseView: true
  101. });
  102. }
  103. },
  104. takePhoto: function (event) {
  105. var _this = this;
  106. // // 允许从相机和相册扫码
  107. // wx.scanCode({
  108. // success: (res) => {
  109. // var result = res.result;
  110. // _this.setData({
  111. // result: result,
  112. // })
  113. // }
  114. // })
  115. // try {
  116. // var value = wx.getStorageSync('nick')
  117. // if (value !== null && value !== undefined && value !== "" && value.length > 0) {
  118. // this.data.nick = value;
  119. // } else {
  120. // this.data.nick = null;
  121. // }
  122. // } catch (e) {
  123. // console.log(e);
  124. // return;
  125. // }
  126. // if (this.data.nick === null) {
  127. // this.data.nickTempInputValue = '';
  128. // // this.setData({
  129. // // hiddenmodalput: !this.data.hiddenmodalput
  130. // // });
  131. // } else {
  132. wx.navigateTo({
  133. url: "/pages/index/setting/setting?rtuCode=" + this.data.rtuCode + "&openId=" + this.data.openId+"&agreement="+this.data.baseInfo['agreement']
  134. });
  135. // }
  136. },
  137. onGotUserInfo: function (e) {
  138. console.debug(e.detail.errMsg)
  139. console.debug(e.detail.userInfo)
  140. console.debug(e.detail.rawData)
  141. },
  142. /**
  143. * 生命周期函数--监听页面初次渲染完成
  144. */
  145. onReady: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面显示
  149. */
  150. onShow: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面隐藏
  154. */
  155. onHide: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面卸载
  159. */
  160. onUnload: function () {
  161. },
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh: function () {
  166. },
  167. /**
  168. * 页面上拉触底事件的处理函数
  169. */
  170. onReachBottom: function () {
  171. },
  172. /**
  173. * 用户点击右上角分享
  174. */
  175. onShareAppMessage: function () {
  176. },
  177. openDatagramViewHandle: function (e) {
  178. var datagram = e.currentTarget.dataset.datagram;
  179. console.debug(datagram)
  180. wx.navigateTo({
  181. url: "/pages/index/datagramDetailView/datagramDetailInfo?rtuCode=" + this.data.rtuCode + "&openId=" + this.data.openId+"&rtuName="+this.data.rtuName+"&datagram="+datagram
  182. });
  183. }
  184. })