layoutInfo.js 2.7 KB

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