layoutInfo.js 5.0 KB

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