index.js 2.4 KB

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