index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {
  2. getRankingData
  3. } from '~/api/global'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ranking: '',
  10. userList: [],
  11. currentWeek: 0,
  12. weekBegin: '',
  13. weekEnd: '',
  14. //2:邀新榜,3:热播榜,4:挑战pk榜
  15. rankingType: '',
  16. icon: '',
  17. podiumBoxBg: '',
  18. color:'',
  19. explain: ''
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad(options) {
  25. this.setData({
  26. rankingType: options.type,
  27. icon: options.type == '2' ? '/static/yx.png' : options.type == '3' ? '/static/play.png' : '/static/win.png',
  28. podiumBoxBg: options.type == '2' ? 'invitation' : options.type == '3' ? 'hot' : 'pk',
  29. color: options.type == '2' ? '#2DCE66' : options.type == '3' ? '#FF7E6C' : '#967DFF',
  30. })
  31. wx.setNavigationBarColor({
  32. frontColor: '#ffffff',
  33. backgroundColor: options.type == '2' ? '#2DCE66' : options.type == '3' ? '#FF7E6C' : '#967DFF',
  34. })
  35. this.getRankingData(options.id)
  36. },
  37. async getRankingData(id) {
  38. let {
  39. ranking,
  40. userList,
  41. currentWeek,
  42. weekBegin,
  43. weekEnd,
  44. title,
  45. explain
  46. } = await getRankingData(id)
  47. wx.setNavigationBarTitle({
  48. title
  49. })
  50. this.setData({
  51. ranking,
  52. userList,
  53. currentWeek,
  54. weekBegin,
  55. weekEnd,
  56. explain
  57. })
  58. },
  59. jumpIndex() {
  60. wx.switchTab({
  61. url: '/pages/index/index',
  62. })
  63. },
  64. jumpUserInfo({
  65. currentTarget
  66. }) {
  67. if (!currentTarget.dataset.uid) {
  68. return
  69. }
  70. wx.navigateTo({
  71. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
  72. })
  73. },
  74. onShareAppMessage() {
  75. return {
  76. title: this.data.rankingType == 3 ? '我要上热门,就差你的一个赞,快来帮帮我吧!' : '这个小程序太赞了!孩子朗读能力蹭蹭上涨,推荐你试试!',
  77. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  78. 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'
  79. }
  80. }
  81. })