layoutInfo.js 3.6 KB

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