index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {
  2. getRankingData
  3. } from '~/api/global'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ranking: '',
  10. userList: [],
  11. //2:邀新榜,3:热播榜,4:挑战pk榜
  12. rankingType: '',
  13. icon: '',
  14. podiumBoxBg: '',
  15. explain: ''
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. this.setData({
  22. rankingType: options.type,
  23. icon: options.type == '2' ? '/static/yx.png' : options.type == '3' ? '/static/play.png' : '/static/win.png',
  24. podiumBoxBg: options.type == '2' ? 'invitation' : options.type == '3' ? 'hot' : 'pk',
  25. })
  26. wx.setNavigationBarTitle({
  27. title: options.title
  28. })
  29. wx.setNavigationBarColor({
  30. frontColor: '#ffffff',
  31. backgroundColor: options.type == '2' ? '#ff7f6c' : options.type == '3' ? '#6D9FFE' : '#967DFF',
  32. })
  33. this.getRankingData()
  34. },
  35. async getRankingData() {
  36. let {
  37. ranking,
  38. userList,
  39. explain
  40. } = await getRankingData(this.data.rankingType)
  41. this.setData({
  42. ranking,
  43. userList,
  44. explain
  45. })
  46. },
  47. jumpIntro() {
  48. wx.navigateTo({
  49. url: `/pages/rankIntro/index?title=榜单说明&img=${this.data.explain}`,
  50. })
  51. },
  52. jumpUserInfo({
  53. currentTarget
  54. }) {
  55. wx.navigateTo({
  56. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
  57. })
  58. },
  59. })