index.js 2.6 KB

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