index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.setNavigationBarColor({
  27. frontColor: '#ffffff',
  28. backgroundColor: options.type == '2' ? '#ff7f6c' : options.type == '3' ? '#6D9FFE' : '#967DFF',
  29. })
  30. this.getRankingData(options.id)
  31. },
  32. async getRankingData(id) {
  33. let {
  34. ranking,
  35. userList,
  36. title,
  37. explain
  38. } = await getRankingData(id)
  39. wx.setNavigationBarTitle({
  40. title
  41. })
  42. this.setData({
  43. ranking,
  44. userList,
  45. explain
  46. })
  47. },
  48. jumpIntro() {
  49. wx.navigateTo({
  50. url: `/pages/rankIntro/index?title=榜单说明&img=${this.data.explain}`,
  51. })
  52. },
  53. jumpIndex() {
  54. wx.switchTab({
  55. url: '/pages/index/index',
  56. })
  57. },
  58. jumpUserInfo({
  59. currentTarget
  60. }) {
  61. if (!currentTarget.dataset.uid) {
  62. return
  63. }
  64. wx.navigateTo({
  65. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
  66. })
  67. },
  68. onShareAppMessage() {
  69. return {
  70. title: this.data.rankingType == 3 ? '我要上热门,就差你的一个赞,快来帮帮我吧!' : this.data.rankingType == 2 ? '这个小程序太赞了!孩子朗读能力蹭蹭上涨,推荐你试试!' : '',
  71. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  72. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
  73. }
  74. }
  75. })