const util = require('../../../utils/util.js');
Page({
  data: {
    id:'',
    prize:[],
    wheelId:'',
    pageIndex:1,
    theam:'redContent',
    showAddress:false,
    test:''
  },
  onLoad: function (options) {
    if (!util.isEmpty(options.wheelId)) {
      this.setData({
        wheelId:options.wheelId,
        theam:options.theam
      })
    }
    // 获取屏幕高度
    let windowHeight = wx.getSystemInfoSync().windowHeight;
    this.setData({windowHeight:windowHeight})
  },
  // 填写地址
  sub(e){
    let id = e.currentTarget.dataset.item.id;
    this.setData({
      prizeId:id,
      showAddress:true,
    })
  },
  // 查看物流
  logistics(e){
    let data = e.currentTarget.dataset.item;
    wx.navigateTo({
      url: '/pages/order/express/express?no='+data.expNo+'&code='+data.expCode,
    })
  },
  // 去抽奖
  getprize(){
    wx.navigateBack({
      delta: -1,
    })
  },
  // 下拉懒加载
  lower(){
    this.setData({pageIndex:this.data.pageIndex+1})
    this.getPrizeList(1)
  },
  // 获取中奖列表
  getPrizeList(bol){
    let that=this;
    util.ajax({
      func: "v2/market/wheel/my/winning/list",
      data: {
        wheelId:that.data.wheelId,
        pageIndex:that.data.pageIndex,
        pageSize:10
      }
    }, function (res) {
      if (res.code==0) {
        if (res.data.list.length>0) {
          that.setData({
            prize:bol?that.data.prize.concat(res.data.list):res.data.list
          })
        } else {
          that.setData({pageIndex:that.data.pageIndex-1})
        }
      }else{
        util.showTips(res.reason);
      }
    })
  },
  closeTip(e){
    this.setData({
      showAddress:e.detail.status
    })
  },
  onReady: function () {
    this.getPrizeList();
  },
  onShow: function () {
  },

  onShareAppMessage: function () {

  }
})