index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {
  2. getRankingData
  3. } from '~/api/global'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. userInfo: {},
  10. ranking: '',
  11. userList: [],
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad(options) {
  17. wx.setNavigationBarColor({
  18. frontColor: '#ffffff',
  19. backgroundColor: '#2DCE66'
  20. })
  21. this.setData({
  22. userInfo: getApp().globalData.userInfo
  23. })
  24. console.log(getApp().globalData.userInfo);
  25. this.getRankingData(2)
  26. },
  27. async getRankingData(id) {
  28. let {
  29. ranking,
  30. userList,
  31. title,
  32. } = await getRankingData(id)
  33. wx.setNavigationBarTitle({
  34. title
  35. })
  36. this.setData({
  37. ranking,
  38. userList,
  39. })
  40. },
  41. jumpIndex() {
  42. wx.switchTab({
  43. url: '/pages/index/index',
  44. })
  45. },
  46. jumpUserInfo({
  47. currentTarget
  48. }) {
  49. if (!currentTarget.dataset.uid) {
  50. return
  51. }
  52. /* wx.navigateTo({
  53. url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=${this.data.rankingType==4?'pk':'user'}`,
  54. }) */
  55. },
  56. onShareAppMessage() {
  57. return {
  58. title: '这个小程序太赞了!孩子朗读能力蹭蹭上涨,推荐你试试!',
  59. path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
  60. imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/375-300-2.jpg'
  61. }
  62. }
  63. })