index.js 2.1 KB

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