index.js 2.5 KB

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