layout.js 2.6 KB

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