// pages/index/showBoxDetail/showBoxDetail.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { rtuCode: '', openId: null, rtuName: '', items: ['状态信息', '报文信息', '基本信息'], baseView: false, statusView: true, datagramView: false, baseInfo: {}, statusInfo: {}, datagramInfo: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //var imageName = options.imageName; var rtuCode = options.rtuCode; //注意,此赋值方法不是微信官方赋值方法,页面奖无法获取数据 console.log(rtuCode); var openId = options.openId; this.setData({ rtuCode: rtuCode, openId: openId }) wx.showNavigationBarLoading() var that = this; var url = app.globalData.cloudBase + "/Wx/Rtu/" + this.data.rtuCode; wx.request({ url: url, method: 'GET', data: { openid: this.data.openId }, header: { "Content-Type": "json" }, success: function (res) { if (res.data.code === "0") { console.log(res.data.data) var name = res.data.data.rtuName; var baseInfo = res.data.data.baseInfo; var statusInfo = res.data.data.statusInfo; var datagramInfo = res.data.data.datagramInfo; wx.setNavigationBarTitle({ title: name }) that.setData({ rtuName: name, baseInfo: baseInfo, statusInfo: statusInfo, datagramInfo: datagramInfo }) } }, fail: function (error) { console.log(error) } }) wx.hideNavigationBarLoading(); }, show_move_s: function () { var publish_button_state = this.data.publish_button_state; console.debug("move+++++++++++++++++++++++++++ " + publish_button_state); this.setData({ publish_button_state: true }) }, show_move_h: function () { var publish_button_state = this.data.publish_button_state; console.debug("move+++++++++++++++++++++++++++ " + publish_button_state); this.setData({ publish_button_state: false }) }, onItemtap: function (event) { console.log(event); const pageIndex = event.detail.currentTarget.dataset.index; if (pageIndex == 0) { this.setData({ statusView: true, datagramView: false, baseView: false }); } else if (pageIndex == 1) { this.setData({ statusView: false, datagramView: true, baseView: false }); } else if (pageIndex == 2) { this.setData({ statusView: false, datagramView: false, baseView: true }); } }, takePhoto: function (event) { var _this = this; // // 允许从相机和相册扫码 // wx.scanCode({ // success: (res) => { // var result = res.result; // _this.setData({ // result: result, // }) // } // }) // try { // var value = wx.getStorageSync('nick') // if (value !== null && value !== undefined && value !== "" && value.length > 0) { // this.data.nick = value; // } else { // this.data.nick = null; // } // } catch (e) { // console.log(e); // return; // } // if (this.data.nick === null) { // this.data.nickTempInputValue = ''; // // this.setData({ // // hiddenmodalput: !this.data.hiddenmodalput // // }); // } else { wx.navigateTo({ url: "/pages/index/setting/setting?rtuCode=" + this.data.rtuCode + "&openId=" + this.data.openId+"&agreement="+this.data.baseInfo['agreement'] }); // } }, onGotUserInfo: function (e) { console.debug(e.detail.errMsg) console.debug(e.detail.userInfo) console.debug(e.detail.rawData) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, openDatagramViewHandle: function (e) { var datagram = e.currentTarget.dataset.datagram; console.debug(datagram) wx.navigateTo({ url: "/pages/index/datagramDetailView/datagramDetailInfo?rtuCode=" + this.data.rtuCode + "&openId=" + this.data.openId+"&rtuName="+this.data.rtuName+"&datagram="+datagram }); } })