1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import {
- getRankingData,
- getSelfRanking,
- getRankedDay
- } from '~/api/global'
- import event from '~/mixins/event'
- Page({
- behaviors: [event],
- /**
- * 页面的初始数据
- */
- data: {
- userList: [],
- //2:邀新榜,3:热播榜,4:挑战pk榜
- rankingType: '',
- icon: '',
- podiumBoxBg: '',
- historyList: [],
- day: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- let historyList = await getRankedDay()
- console.log(historyList);
- this.setData({
- historyList,
- day: historyList[historyList.length - 1]
- }, () => {
- this.getRankInfo(options)
- })
- },
- async getRankInfo(options) {
- 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',
- })
- wx.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: options.type == '2' ? '#50AE75' : options.type == '3' ? '#FF7E6C' : '#8468FA',
- })
- let userList = await getRankingData({
- type: options.type,
- day: this.data.day
- })
- let self = await getSelfRanking({
- type: options.type,
- day: this.data.day
- })
- console.log(self);
- this.setData({
- userList,
- })
- },
- switchType({
- target
- }) {
- let rankingType = target.dataset.type
- if (rankingType && rankingType != this.data.rankingType) {
- this.getRankInfo({
- type: rankingType
- })
- }
- },
- bindDateChange(e) {
- this.setData({
- day: e.detail.value
- })
- this.getRankInfo({
- type: this.data.rankingType
- })
- },
- jumpIndex() {
- wx.switchTab({
- url: '/pages/index/index',
- })
- },
- jumpUserInfo({
- currentTarget
- }) {
- if (!currentTarget.dataset.uid) {
- return
- }
- wx.navigateTo({
- url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
- })
- },
- onShareAppMessage() {
- return {
- title: this.data.rankingType == 3 ? '我要上热门,就差你的一个赞,快来帮帮我吧!' : '这个小程序太赞了!孩子朗读能力蹭蹭上涨,推荐你试试!',
- path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
- imageUrl: this.data.rankingType == 3 ? 'http://reader-wx.ai160.com/images/reader/v3/375-300-3.jpg' : 'http://reader-wx.ai160.com/images/reader/v3/375-300-2.jpg'
- }
- }
- })
|