show_encourage.js 1.53 KB
// components/show_encourage/show_encourage.js
var setting = getApp().globalData.setting

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    url: setting.imghost,
    show:false,
    itemobj:null,
  },
  pageLifetimes: {
    show: function() {
      // console.error('show');
      // this.get_encourage()
      // 页面被展示
    },
    hide: function() {
      // 页面被隐藏
    },
    resize: function(size) {
      // 页面尺寸变化
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    async get_encourage(){
      let user_id = getApp().globalData.user_id;
      let store_id= getApp().globalData.setting.stoid
      console.error('获取大转盘');
      if (!user_id) {
        return
      }
      await getApp().request.promiseGet(`/api/weshop/marketing/marketingLuckForm/getPayTopLuckInfo/${store_id}/${user_id}`, {}).then(res => {
        if (res.data.code==0 && res.data.data) {
          let gd_category = res.data.data;
          this.setData({
            itemobj: gd_category,
            show:true,
          });
        }
      }) 
    },
    close_disgraceful(){
      this.setData({
        show:false
      })
    },
    goto(){
      let item = this.data.itemobj
      let id = item.id;
      let title = item.act_name;
      if (!id) {
        this.setData({
          show:false
        })
        return
      }
      let url = `/packageB/pages/luckactivity/luckinfo/luckinfo?id=${id}&title=${title}`;
      getApp().goto(url);
    }
  }
})