layout.js 2.9 KB

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