import config from '../../../config'
import {
  getToken
} from '../../../utils/auth'
import {
  planScheduleInfo
} from '../../../api/project'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    infoData: {},
    imageList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (!getToken()) {
      wx.redirectTo({
        url: '../../../pages/login/login',
      })
    }
    this.getInfo(options.id);
  },

  /**
   * 查详进度详情
   * @param {*} id 
   */
  getInfo(id) {
    planScheduleInfo(id).then(res => {
      if (res.code == 200) {
        let urls = [];
        if (res.data.images) {
          res.data.images.split(',').forEach(item => {
            urls.push(config.baseImgUrl + item);
          });
        }
        this.setData({
          infoData: res.data,
          imageList: urls
        })
      }
    })
  },

  //展示图片
  showImg: function (e) {
    let img = e.target.dataset.set;
    wx.previewImage({
      urls: img.split(','),
      current: 0
    })
  },

  returnToPage: function () {
    /*关闭当前页面,跳转到其它页面。*/
    wx.redirectTo({
      url: `../list/index`,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})