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

  /**
   * 页面的初始数据
   */
  data: {
    navBar: [{ name: '线上订单', type: 1, isActive: true }, { name: '线下订单', type: 2, isActive: false }],
    current: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log('ddddd', this.options)
    let taskId = this.options && this.options.id || 0
    let orderType = this.options && this.options.type || 1
    this.getTaskDetail(orderType, taskId)
  },
  getTaskDetail(orderType,taskId) {
    wx.showLoading({
      title: '加载中'
    })
    wxService.post(`/marketing/shoppingguide/task/detail?orderType=${orderType}&taskId=${taskId}`).then(res => {
      if (res) {
        const { result, data } = res.data
        if (result == 0) {
          wx.hideLoading()
          // data && data.skuVOList.forEach(item=>{
          //   item.checked = false
          // })
          // this.setData({
          //   cartList: data && data.skuVOList || []
          // })
        }
      }
    })
  },
  // 点击事件
  onTopBarTap(e){
    let index = e.currentTarget.dataset.index,
      item = e.currentTarget.dataset.item;
    this.data.navBar.forEach(nav => {
      nav.isActive = false;
    });

    this.data.navBar[index].isActive = true;
    this.data.current = this.data.navBar[index].type;

    this.setData({
      navBar: this.data.navBar,
      current: this.data.current
    });
  },


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

  },

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

  },

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

  }
})