index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. ranking: [],
  14. },
  15. back: function () {
  16. wx.navigateBack({ url: '/pages/home/index' })
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. // 计算高度
  23. this.searchHeight();
  24. // 监听用户是否登录
  25. this.watchLogin();
  26. },
  27. // 监听用户是否登录
  28. watchLogin: function () {
  29. wx.getStorage({
  30. key: 'token',
  31. success: res => {
  32. var that = this;
  33. wx.request({
  34. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  35. method: 'get',
  36. data: {},
  37. success(res) {
  38. if (res.data.errcode == 0) {
  39. that.setData({
  40. ranking: res.data.data,
  41. });
  42. } else {
  43. wx.showToast({
  44. title: res.data.errmsg,
  45. icon: 'none',
  46. duration: 2000
  47. })
  48. }
  49. }
  50. })
  51. },
  52. fail: res => {
  53. return wx.redirectTo({ url: '/pages/login/index', })
  54. }
  55. })
  56. },
  57. // 计算高度
  58. searchHeight: function () {
  59. let frameStyle = this.data.frameStyle;
  60. let client = app.globalData.client;
  61. let infoHeight = client.windowHeight;
  62. // 是否去掉状态栏
  63. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  64. // 是否减去底部菜单
  65. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  66. if (infoHeight) this.setData({ infoHeight: infoHeight })
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面显示
  75. */
  76. onShow: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面隐藏
  80. */
  81. onHide: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面卸载
  85. */
  86. onUnload: function () {
  87. },
  88. /**
  89. * 页面相关事件处理函数--监听用户下拉动作
  90. */
  91. onPullDownRefresh: function () {
  92. },
  93. /**
  94. * 页面上拉触底事件的处理函数
  95. */
  96. onReachBottom: function () {
  97. },
  98. /**
  99. * 用户点击右上角分享
  100. */
  101. onShareAppMessage: function () {
  102. }
  103. })