index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const app = getApp()
  2. Page({
  3. data: {
  4. id: '',
  5. // 用户信息
  6. user: {},
  7. list: [],
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. async onLoad(options) {
  13. const that = this;
  14. that.setData({ id: options.id });
  15. },
  16. /**
  17. * 生命周期函数--监听页面显示
  18. */
  19. async onShow() {
  20. const that = this;
  21. wx.showLoading({ title: '加载中', mask: true })
  22. await that.searchUser()
  23. await that.search()
  24. wx.hideLoading()
  25. },
  26. async searchUser() {
  27. const that = this;
  28. wx.getStorage({
  29. key: 'user',
  30. async success(res) {
  31. that.setData({ user: res.data })
  32. },
  33. fail(err) {
  34. // console.log(err);
  35. }
  36. })
  37. },
  38. // 查询通知
  39. async search() {
  40. const that = this;
  41. let res = await app.$api('course/ranking', 'GET', { match_id: that.data.id })
  42. if (res.errcode == '0') that.setData({ list: res.data.scoreList })
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady() {
  48. },
  49. /**
  50. * 生命周期函数--监听页面隐藏
  51. */
  52. onHide() {
  53. },
  54. /**
  55. * 生命周期函数--监听页面卸载
  56. */
  57. onUnload() {
  58. },
  59. /**
  60. * 页面相关事件处理函数--监听用户下拉动作
  61. */
  62. onPullDownRefresh() {
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom() {
  68. },
  69. /**
  70. * 用户点击右上角分享
  71. */
  72. onShareAppMessage() {
  73. }
  74. })