const _my = require("../../../../__antmove/api/index.js")(my);
const wx = _my;
var {
  getProblemReportDetailById,
  evaluate
} = require("../../../../utils/api/xiaosha");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    id: null,
    imgList: [],
    //图片
    uploadVideo: "",
    //视频
    evaluateWorkpoint: null,
    //满意度
    evaluateContent: "" //处理评价
  },

  // 满意度
  starChange(e) {
    this.setData({
      evaluateWorkpoint: e.detail
    });
  },
  // 处理评价
  evaluateContentFun(e) {
    this.setData({
      evaluateContent: e.detail.value
    });
  },
  //查看照片
  ViewImage(e) {
    wx.previewImage({
      urls: this.data.list.pictures,
      current: e.currentTarget.dataset.url
    });
  },
  // 评价
  report() {
    let {
      evaluateWorkpoint,
      evaluateContent
    } = this.data;
    if (!evaluateWorkpoint) {
      wx.showToast({
        title: "请选择满意度",
        icon: "none"
      });
      return;
    }
    let form = {
      evaluateWorkpoint,
      evaluateContent,
      id: this.data.id
    };
    evaluate(form).then(res => {
      my.alert({
        title: "提示",
        content: "评价成功！",
        success: res => {
          wx.navigateBack({
            delta: 1
          });
        }
      });
    });
  },
  getProblemReportDetailById(reportId) {
    getProblemReportDetailById(reportId).then(res => {
      this.setData({
        list: res.data
      });
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options) {
      this.setData({
        id: options.id
      });
      this.getProblemReportDetailById(options.id);
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
  antmoveAction: function () {
    //执行时动态赋值，请勿删除
  }
});