index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. wx.getStorage({
  43. key: 'token',
  44. success: res => {
  45. var that = this;
  46. wx.request({
  47. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  48. method: 'get',
  49. data: {},
  50. success(res) {
  51. if (res.data.errcode == 0) {
  52. that.setData({
  53. ranking: res.data.data,
  54. });
  55. } else {
  56. wx.showToast({
  57. title: res.data.errmsg,
  58. icon: 'none',
  59. duration: 2000
  60. })
  61. }
  62. }
  63. })
  64. },
  65. fail: res => {
  66. return wx.redirectTo({ url: '/pages/login/index', })
  67. }
  68. })
  69. },
  70. // 计算高度
  71. searchHeight: function () {
  72. let frameStyle = this.data.frameStyle;
  73. let client = app.globalData.client;
  74. let infoHeight = client.windowHeight;
  75. // 是否去掉状态栏
  76. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  77. // 是否减去底部菜单
  78. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  79. if (infoHeight) this.setData({ infoHeight: infoHeight })
  80. },
  81. /**
  82. * 生命周期函数--监听页面初次渲染完成
  83. */
  84. onReady: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面显示
  88. */
  89. onShow: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function () {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function () {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function () {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })