index.js 2.5 KB

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