// pages/list/list.js const $api = require('../../utils/api.js').API; const $push = require('../../utils/api.js').PUSH; Page({ /** * 页面的初始数据 */ data: { id:'', page:1, total:0, order1:1, order2: 1, order_by:'total_income__desc', list:[], date:'', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ id: options.id, date:options.stock_date }) this.getData(); }, getData(){ var data={ id: this.data.id, page: this.data.page, page_size:50, order_by: this.data.order_by, stock_date:this.data.date } const list = this.data.list; const count = list.length; wx.showNavigationBarLoading(); $api.getRankList(data).then(res=>{ const players = res.data.data.players; for (let i = 0; i < players.length; i++) { let player = players[i] player.rank = count+i+1 list.push(player) } this.setData({ group: res.data.data.group, list: list, total: res.data.data.total, actual_person: res.data.data.actual_person, leave_person: res.data.data.leave_person, total_person: res.data.data.total_person, win_person: res.data.data.win_person, loss_person: res.data.data.loss_person }) wx.setNavigationBarTitle({ title: res.data.data.group.name, }) wx.hideNavigationBarLoading() }) }, next: function () { if (this.data.list.length < this.data.total) { const page = this.data.page + 1 this.setData({ page: page }) this.getData() } }, //排序 changeOrder1(){ this.setData({ order1:!this.data.order1, order_by: this.data.order1 ? 'today_income__asc' :'today_income__desc', page:1, total:0, list:[] }) this.getData() }, changeOrder2() { this.setData({ order2: !this.data.order2, order_by: this.data.order2 ? 'total_income__asc' : 'total_income__desc', page: 1, total: 0, list: [] }) this.getData() }, pushToday(e){ $push.pushToday(e.currentTarget.dataset) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })