|
@@ -10,44 +10,54 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
userList: [],
|
|
|
- ranking:'',
|
|
|
+ ranking: '',
|
|
|
//2:邀新榜,3:热播榜,4:挑战pk榜
|
|
|
rankingType: '',
|
|
|
icon: '',
|
|
|
podiumBoxBg: '',
|
|
|
historyList: [],
|
|
|
- day: '',
|
|
|
+ selector: {
|
|
|
+ currentDay: '',
|
|
|
+ next: true,
|
|
|
+ previous: true,
|
|
|
+ },
|
|
|
+ backgroundColor: ''
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
async onLoad(options) {
|
|
|
let historyList = await getRankedDay()
|
|
|
- console.log(historyList);
|
|
|
this.setData({
|
|
|
historyList,
|
|
|
- day: historyList[historyList.length - 1]
|
|
|
+ selector: {
|
|
|
+ currentDay: historyList.length - 1,
|
|
|
+ next: false,
|
|
|
+ previous: historyList.length - 1 > 0
|
|
|
+ }
|
|
|
}, () => {
|
|
|
this.getRankInfo(options)
|
|
|
})
|
|
|
|
|
|
},
|
|
|
async getRankInfo(options) {
|
|
|
+ let backgroundColor = options.type == '2' ? '#50AE75' : options.type == '3' ? '#FF7E6C' : '#8468FA';
|
|
|
this.setData({
|
|
|
rankingType: options.type,
|
|
|
icon: options.type == '2' ? '/static/yx.png' : options.type == '3' ? '/static/play.png' : '/static/win.png',
|
|
|
podiumBoxBg: options.type == '2' ? 'invitation' : options.type == '3' ? 'hot' : 'pk',
|
|
|
+ backgroundColor
|
|
|
})
|
|
|
wx.setNavigationBarColor({
|
|
|
frontColor: '#ffffff',
|
|
|
- backgroundColor: options.type == '2' ? '#50AE75' : options.type == '3' ? '#FF7E6C' : '#8468FA',
|
|
|
+ backgroundColor
|
|
|
})
|
|
|
let {
|
|
|
userList,
|
|
|
ranking
|
|
|
} = await getRankingData({
|
|
|
type: options.type,
|
|
|
- day: this.data.day
|
|
|
+ day: this.data.historyList[this.data.selector.currentDay]
|
|
|
})
|
|
|
this.setData({
|
|
|
userList,
|
|
@@ -64,9 +74,22 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- bindDateChange(e) {
|
|
|
+ bindDateChange({
|
|
|
+ currentTarget
|
|
|
+ }) {
|
|
|
+ let type = currentTarget.dataset.type
|
|
|
+ let currentDay = this.data.selector.currentDay
|
|
|
+ if (type == 'next' && currentDay < this.data.historyList.length - 1) {
|
|
|
+ currentDay = ++currentDay
|
|
|
+ } else if (type == 'previous' && currentDay > 0) {
|
|
|
+ currentDay = --currentDay
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- day: e.detail.value
|
|
|
+ selector: {
|
|
|
+ currentDay,
|
|
|
+ next: currentDay < this.data.historyList.length - 1,
|
|
|
+ previous: currentDay > 0
|
|
|
+ }
|
|
|
})
|
|
|
this.getRankInfo({
|
|
|
type: this.data.rankingType
|