// shoppingGuid/page/pages/taskNotice/taskNotice.js
const wxService = require('../../../../utils/wxService')
wxService.page({

  /**
   * 页面的初始数据
   */
  data: {
    notice : [],
    nodata : false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = options.id , 
      type = options.type;
    this.getTaskInfo(id,type);
  },
  //获取任务详情
  getTaskInfo(id,type){
    wx.showLoading({
      title: '加载中'
    });
    wxService.post(`/marketing/shoppingguide/task/detail?orderType=${type}&taskId=${id}`).then(res => {
      if (res) {
        const { result, data } = res.data
        if (result == 0) {
          let notice = data.task.notice ? JSON.parse(data.task.notice) : [];
          if(notice.length == 0){
            this.data.nodata = true;
          }
          else{
            this.data.nodata = false;
          }

          this.setData({
            notice: notice,
            nodata: this.data.nodata
          });
        }
      }
    })
  }
  
})