//获取应用实例
const app = getApp();
let deviceRecordId = 0;
let deviceId = 0;

Page({
  data: {
    record: null
  },

  onLoad: function (options) {
    deviceRecordId = options.id;
    deviceId = options.did;

    var that = this;
    app.ajaxReadyCallback = res => {
      var deviceinfo = res.data.data;
      if (!deviceinfo.deviceImg) {
        deviceinfo.deviceImg = [];
      } else {
        deviceinfo.deviceImg = deviceinfo.deviceImg.split(',');
      }
      if (!deviceinfo.recordImg) {
        deviceinfo.recordImg = [];
      } else {
        deviceinfo.recordImg = deviceinfo.recordImg.split(',');
      }
      deviceinfo.checkJson = JSON.parse(deviceinfo.checkJson);
      that.setData({
        record: deviceinfo,
      });
      wx.setNavigationBarTitle({
        title: deviceinfo.deviceTittle
      });
    };
    this.showData();
  },

  onShow: function () {
    
  },

  //图片预览
  previewImage: function (e) {
    var current = e.target.dataset.src;
    wx.previewImage({
      current: current, // 当前显示图片的http链接  
      urls: this.data.record.recordImg, // 需要预览的图片http链接列表  
      success: function (e) {
        console.log(e);
      }
    })
  },

  showData: function () {
    app.ajax({
      url: app.globalData.serverUrl + 'server/deviceRecord/queryRecordDetails',
      type: 'POST',
      data: {
        deviceId: deviceId,
        deviceRecordId: deviceRecordId,
      }
    });
  },
})
