| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 | 
var app = getApp()var that;Page({  data: {    month: app.globalData.month,    showRuleTwo: false,//显示规则组件    ruleVal: "规则分类",    date:app.globalData.month,    isPx: true,    id: '',    page: 1,    dateType: 1,  },  onLoad(e) {    that = this;    if (e.date_interval == 3) {      this.setData({        dateType: e.date_interval,        month:app.globalData.year,        date:app.globalData.year,      })    } else if (e.date_interval == 2) { // 传进入如果是季度      this.setData({        month:app.globalData.year+String(this.getJ()+1),        dateType: e.date_interval      })    } else {      this.setData({        month:app.globalData.year+String(app.globalData.month_tow),        dateType: e.date_interval      })    }    if (e.id) {      this.setData({ id: e.id });      dd.setNavigationBar({ title: e.name });      this.getData();    }  },  // 获取当前是第几季  getJ() {    var getYearWeek = function (a, b, c) {      var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1),        d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000)      return Math.ceil((d + ((date2.getDay() + 1) - 1)) / 7)    }    var today = new Date()// 获取当前时间    var y = today.getFullYear()    var m = today.getMonth() + 1    var d = today.getDate()    var week, quarter = ''    var result = getYearWeek(y, m, d)    if (m < 4) {      quarter = 1      week = result    } else if (m < 7) {      quarter = 2      week = result - getYearWeek(y, 4, 1)      var day = new Date(y, 4, 1)      if (day.getDay() > 1) {        week += 1      }    } else if (m < 10) {      quarter = 3      week = result - getYearWeek(y, 7, 1)      var day = new Date(y, 7, 1)      if (day.getDay() > 1) {        week += 1      }    } else {      quarter = 4      week = result - getYearWeek(y, 10, 1)      var day = new Date(y, 10, 1)      if (day.getDay() > 1) {        week += 1      }    }    return quarter - 1  },  getData(is) {    var data = {      date: that.data.month,      page: that.data.page,      page_size: 10,      sort: that.data.isPx ? 'asc' : 'desc',      // type: 'normal',      group_id: that.data.id,    }    app.$get('api/integral/statistics/groups/rank',data).then((res) => {      var data = res.data.data.list;      if (is) {        if (data.length == 0) {          return;        }        var list = that.data.list;        this.setData({          list: list.concat(data)        })      } else {        this.setData({          list: data        })      }    })  },  //上啦加载  onScrollToLower() {    this.setData({ page: ++that.data.page })    this.getData(true);  },  selectDay() {    var str="yyyy-MM";    if(this.data.dateType==3){        str="yyyy"    }    this.setData({ showDate: true })    dd.datePicker({      format: str,      currentDate: this.data.date,      success: (res) => {        if(res.date&&that.data.dateType!=3){        var str=res.date.substr(0,4)        var str2=res.date.substr(res.date.length-2,2)        this.setData({          month: String(str)+String(str2),          date:res.date        })        this.getData();        }else{            this.setData({              month: res.date,              date:res.date            })            this.getData();        }      },      complete: (res) => {        that.setData({          showDate: false        })      }    });  },  //显示规则组件  selectRule() {    this.setData({      showRuleTwo: true    })  },  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({      showRuleTwo: false    })  },  //选择规则  onConfirmRule(data) {    this.setData({ rule_id: data.id, page: 1, ruleVal: data.name })    this.getData();  },});
 |