index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '团队排名', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 选项卡
  13. tabs: {
  14. active: 'a',
  15. list: [
  16. { title: '团队排名', name: 'a' },
  17. { title: '团队积分', name: 'b' },
  18. ],
  19. },
  20. //团队排名
  21. ranking: [],
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/match/index' })
  25. },
  26. // 选项卡
  27. tabsChange: function (e) {
  28. const that = this;
  29. that.setData({ 'tabs.active': e.detail.name })
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. // 计算高度
  36. this.searchHeight();
  37. // 监听用户是否登录
  38. this.watchLogin();
  39. },
  40. // 监听用户是否登录
  41. watchLogin: function () {
  42. const that = this;
  43. wx.getStorage({
  44. key: 'token',
  45. success: async res => {
  46. let arr;
  47. // 参赛团队
  48. arr = await app.$get(`/courtAdmin/api/matchteam`);
  49. if (arr.errcode == '0') that.setData({ ranking: arr.data });
  50. },
  51. fail: res => {
  52. wx.redirectTo({ url: '/pages/index/index', })
  53. }
  54. })
  55. },
  56. // 计算高度
  57. searchHeight: function () {
  58. let frameStyle = this.data.frameStyle;
  59. let client = app.globalData.client;
  60. let infoHeight = client.windowHeight;
  61. // 是否去掉状态栏
  62. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  63. // 是否减去底部菜单
  64. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  65. if (infoHeight) this.setData({ infoHeight: infoHeight })
  66. },
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. }
  102. })