// monitor/pages/components/feedBackRecord/feedBackRecord.js
const app = getApp(),
  Api = require("../../../../utils/util.js");
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    basic: Object,
    tabType: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    
  },

  pageLifetimes: {
    show: function () {
      // 页面被展示
      this.getList()
    },
  }, 
  observers: {
    'tabType': function (tabType) {
      if(tabType){
       this.getList()
       this.setData({
        imgUrl: app.globalData.imgUrl
       })
      }
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getList(){
      var that = this
      wx.showLoading({
        title: '加载中...',
      })  
      Api.req('sf/operationOrderFeedback/listFeedback', {
        orderId: this.data.basic.id
      }, 'get')
      .then(res => {
        wx.hideLoading()
        if(res.code == 200){
          for (var i = 0; i < res.data.length; i++) {
            if (res.data[i].feedbackImg) {
              res.data[i].feedbackImg = res.data[i].feedbackImg.split(',')
            } else {
              res.data[i].feedbackImg = []
            }
          }
          that.setData({
            back: res.data,
          })
        }
      })
    },
    //查看图片
    bigImg(e) {
      let photo_arr = new Array();
      let current = this.data.imgUrl + e.currentTarget.dataset.url;
      photo_arr.push(current);
      wx.previewImage({
        current: current, // 当前显示图片的https链接
        urls: photo_arr, // 需要预览的图片https链接列表
      })
    },
  }
})