// pages/interaction/interaction.js
const app = getApp(),
  {
    globalData: {
      util: {
        regeneratorRuntime,
        api: {
          caseDetail
        },
        request: {
          get
        }
      }
    }
  } = app;

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  assess:function(e){
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  wuliu: function () {
    wx.navigateTo({
      url: 'webView/webView?takePostno=' + this.data.detailData.preExpress.takePostno + '&postUnitname=' + this.data.detailData.preExpress.postUnitno,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  tousu:function(e){
    wx.setStorageSync('unid', this.data.detailData.preService.unid)
    wx.setStorageSync('tousu', 'tousu')
    wx.switchTab({
      url: e.currentTarget.dataset.url,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad() {
    let that = this;
    let options = this.options.projid;
    let detailData = await get(caseDetail, {
      projId: options
    });
    that.data.detailData=detailData
    let fileArr = detailData.preApasinfo.preAttrList, imgArr = [], imgs = [];
    fileArr.forEach(function (item, index) {
      let img = item.fileUrl;
      imgs = String(img).split(",");
      if (imgs.length > 0 && imgs[0] != 'null') {
        imgArr.push({'url':imgs,'ind':index});
        detailData.preApasinfo.preAttrList[index].fileUrl = imgArr[index]
      }
    })
    that.setData({
      detailData: detailData,
      imgArr
    })
  },
  preview:function(e){
    wx.previewImage({
      current: e.currentTarget.dataset.url[e.currentTarget.dataset.index],
      urls: e.currentTarget.dataset.url,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  async onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})