ranking.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // pages/contest/ranking/ranking.js
  2. import {
  3. answer
  4. } from '../../../api/api.js'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. page: 1,
  11. first: {},
  12. second: {},
  13. third: {},
  14. dataList: [],
  15. statusBar: 0,
  16. user: wx.getStorageSync('user') || {},
  17. helpState: false
  18. },
  19. clickHelp () {
  20. this.setData({
  21. helpState: true
  22. })
  23. },
  24. closeShow () {
  25. this.setData({
  26. helpState: false
  27. })
  28. },
  29. getRankingList (type) {
  30. answer.getLeaderBoard({reqdata: {
  31. type
  32. }},r => {
  33. this.setData({
  34. dataList: r.list,
  35. page: type
  36. })
  37. })
  38. },
  39. togglePage(e) {
  40. this.getRankingList(e.currentTarget.dataset.index-0)
  41. },
  42. goHome (e) {
  43. wx.reLaunch({
  44. url: '/pages/home/home',
  45. })
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. this.getRankingList(this.data.page)
  52. wx.getSystemInfo({
  53. success: e => {
  54. // this.globalData.statusBar = e.statusBarHeight; //状态栏高度
  55. this.setData({
  56. statusBar: e.statusBarHeight + 13
  57. })
  58. // let custom = wx.getMenuButtonBoundingClientRect();//菜单按钮
  59. // this.globalData.custom = custom;
  60. // this.globalData.customBar = custom.bottom + custom.top - e.statusBarHeight;
  61. // //计算得到定义的状态栏高度
  62. }
  63. })
  64. },
  65. /**
  66. * 生命周期函数--监听页面初次渲染完成
  67. */
  68. onReady: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面显示
  72. */
  73. onShow: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面隐藏
  77. */
  78. onHide: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面卸载
  82. */
  83. onUnload: function () {
  84. },
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {
  89. },
  90. /**
  91. * 页面上拉触底事件的处理函数
  92. */
  93. onReachBottom: function () {
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. }
  100. })