index.js 2.3 KB

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