
var util = require('../../../utils/util.js')
Page({
  data: {
    orderId:null,
    detailObj: {},
    goodsList:[]
  },

  onLoad(options) {
    const id = options.id;
    this.setData({
      orderId: id
    });
    this.getDetail()
  },

  getDetail() {
    var send_data = [
      { "name": "getInstallationOrderById", "returntype": "Map", "parammaps": { "id": this.data.orderId } },
      {"name":"getInstallationOrderDetail","returntype":"Map","parammaps":{"orderId":this.data.orderId}},
    ]
    util.getDataByNames(send_data, this.handleDetail)
  },

  handleDetail(res) { 
    var data = res.data;
    console.log(data,'详情')
    if (data.getInstallationOrderById.list != null) { 
      let acceptanceImagePath = data.getInstallationOrderById.list[0].acceptanceImagePath;
      if(acceptanceImagePath) {
        data.getInstallationOrderById.list[0].acceptanceImagePath = acceptanceImagePath.split(',').map(path => getApp().globalData.g_url + path);
      }
      this.setData({
        detailObj: data.getInstallationOrderById.list[0],
        goodsList: data.getInstallationOrderDetail.list,
      })
    } else { 
        this.setData({
          detailObj: {},
          goodsList:[]
        })
    } 
  },
  onBack() {
    wx.navigateBack();
  },
    viewHistory() {
    var id = this.data.orderId;
    wx.navigateTo({
      url:`/pages/workbench/historyFill/historyFill?id=${id}`
    });
  },

  previewImage(e) {
    console.log(e)
  const urls = e.currentTarget.dataset.urls;
  const current = e.currentTarget.dataset.current;
  wx.previewImage({
    urls:[current], // 需要预览的图片链接列表
    current: current // 当前显示图片的链接
  });
}



});
