| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- // 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
- });
- }
- })
|