index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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' ? '#2DCE66' : options.type == '3' ? '#FF7E6C' : '#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. jumpIndex() {
  49. wx.switchTab({
  50. url: '/pages/index/index',
  51. })
  52. },
  53. jumpUserInfo({
  54. currentTarget
  55. }) {
  56. if (!currentTarget.dataset.uid) {
  57. return
  58. }
  59. wx.navigateTo({
  60. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
  61. })
  62. },
  63. onShareAppMessage() {
  64. return {
  65. title: this.data.rankingType == 3 ? '我要上热门,就差你的一个赞,快来帮帮我吧!' : '这个小程序太赞了!孩子朗读能力蹭蹭上涨,推荐你试试!',
  66. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  67. 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'
  68. }
  69. }
  70. })