
var app = getApp()
var that;
Page({
  data: {
    showTissue:false,//显示部门组件
    TissueVal:'全公司',
    isPx:true,
    page:1,
    scroll_top:0
  },
  onLoad() {
    that = this;
    dd.setNavigationBar({ title: "B分累计排名" });
    this.getData();
  },
    getData(is){
    var data = {
      page: that.data.page,
      page_size: 20,
      dept_id:that.data.dept_id,
      pt_id: app.getTypesItem('BF').id,
      sort: that.data.isPx?'DESC':'ASC',
      type: 'all'
    }
    app.$get('api/integral/statistics/ranking',data,'application/vnd.test.v2+json').then((res) => {
      var data = res.data.data.list;
      if (is) {
        if (data.length == 0) {
          this.setData({isData: true})
          return;
        }
        var list = that.data.list;
        this.setData({
          list: list.concat(data)
        })
      } else {
        this.setData({list:[]});
        this.setData({
          list: data,
          isData: false,
        })
      }
    })
  },
    //上啦加载
  onScrollToLower() {
    if(!that.data.isData){
      this.setData({ page: ++that.data.page })
      this.getData(true);
    }else{
       app.globalData.showToast("已无更多咯");
    }
  },
  selectIsPx(){
    this.setData({
      isPx:!this.data.isPx,
      page:1
    })
    this.getData();
  },
  //打开兴趣
  openDetail(e){
   var item=e.target.dataset.item;
    dd.navigateTo({
      url: '../prizeBuckleDetail/prizeBuckleDetail?item='+item
    })
  },
    //关闭弹窗
  onClose() {
    this.setData({
      showTissue:false
    })
  },
    //显示部门选择组件
  selectTissue(){
    this.setData({showTissue:!this.data.showTissue})
  },
  //选择部门
  onConfirmTissue(data) {
    this.setData({ dept_id: data.id,page:1,TissueVal:data.name })
    this.getData();
  },
});
