// packageA/mycomponent/goodsComponent/plugin/guessLike/guessLike.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goodsInfo: {
      type: null
    },
    activityid: {
      type: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    currentIndex: 0,
    good_list: [],
    vip_level_status: {}
  },
  observers: {
    goodsInfo(goodsInfo) {
      if (goodsInfo) {
        let list = [];
        if(goodsInfo.show_push){
          for (let i = 0; i < goodsInfo.show_push.length;) {
            list.push(goodsInfo.show_push.slice(i, i + 6));
            i += 6;
          }
        }

        this.setData({
          good_list: list,
          vip_level_status: goodsInfo.vip_level_status || {}
        });
      }
    }
  },
  lifetimes: {
    attached() {
      let language = wx.getStorageSync("langIndex");
      this.setData({
        language: language.en
      });
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    swiperChange(e) {
      this.setData({
        currentIndex: e.detail.current
      });
    },
    //推广商品跳转
    pushGoodGoto(e) {
      let itemdata = e.currentTarget.dataset.itemdata;
      wx.navigateTo({
        url: "/packageA/detail_v2/detail_v2?id=" + itemdata.id,
      });
    },
  }
});