const app = getApp()
const Http = require("../../utils/HttpBasics");
const config = require("../../config/config");
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    paramAtoB: String,
    from: String,
    data: {
      value: {},
      type: Object
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    mouldType: 0,
    mouldConfig: {},
    couponListShowSelled: ''
  },
  attached: function () {
    // 在组件实例进入页面节点树时执行
    if (app.globalData.mouldType) {
      this.setData({
        mouldType: app.globalData.mouldType,
        mouldConfig: app.globalData.mouldConfig
      })
    }

    Http.get({
      url: config.api.couponListShowSelled,
    }).then(res => {
      this.setData({
        couponListShowSelled: res.data || ""
      })
    }).catch(err => {

    })

  },
  methods: {
    gotoDetail(e) {
      let couponId = e.currentTarget.dataset.couponid;
      let title = e.currentTarget.dataset.title;
      let id = e.currentTarget.dataset.id;
      let targetAd = e.currentTarget.dataset.targetad;
      if (id && targetAd != 7) {
        wx.navigateTo({
          url: `/pages/coupon/detail/index?couponChannelId=${id}&couponId=${couponId}&title=${title}`,
        })
      } else if (targetAd == 7) {
        wx.navigateTo({
          url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${id}&couponId=${couponId}&title=${title}`,
        })
      }
    }
  }
});