index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: false, useBar: true },
  10. // 主体高度
  11. infoHeight: '',
  12. background: '/image/bisai.png',
  13. match: '/image/chuangjian.png',
  14. black: '/image/hei.png',
  15. //进行中数据
  16. conduct: [],
  17. //未开始数据
  18. nostart: [],
  19. //已结束数据
  20. complete: [],
  21. },
  22. // 跳转菜单
  23. tabPath(e) {
  24. let { route } = e.detail.detail;
  25. if (route) wx.redirectTo({ url: `/${route}` })
  26. },
  27. //跳转详情
  28. tiao: function (e) {
  29. let { id, type } = e.currentTarget.dataset;
  30. if (type == 1) wx.navigateTo({ url: `/pages/list/index?id=${id}` })
  31. else wx.navigateTo({ url: `/pages/match/detail?id=${id}` })
  32. },
  33. //创建比赛
  34. jump: function () {
  35. wx.navigateTo({
  36. url: `/pages/competition/index`,
  37. })
  38. },
  39. //团队排名
  40. tuan: function () {
  41. wx.navigateTo({
  42. url: `/pages/ranking/index`,
  43. })
  44. },
  45. //团队审批
  46. shen: function () {
  47. wx.navigateTo({
  48. url: `/pages/manage/index`,
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面加载
  53. */
  54. onLoad: function (options) {
  55. // 监听用户是否登录
  56. this.watchLogin();
  57. // 计算高度
  58. this.searchHeight();
  59. },
  60. // 监听用户是否登录
  61. watchLogin: async function () {
  62. const that = this;
  63. wx.getStorage({
  64. key: 'token',
  65. success: async res => {
  66. const arr = await app.$get('/courtAdmin/api/match');
  67. if (arr.errcode === 0) {
  68. let datastart = arr.data.filter((i) => i.status == 2);
  69. let datas = arr.data.filter((i) => i.status == 3);
  70. let dataend = arr.data.filter((i) => i.status == 4);
  71. for (const val of datas) {
  72. if (val.status == '3') {
  73. const aee = await app.$get('/courtAdmin/api/schedule', { match_id: val._id });
  74. if (aee.errcode === 0) val.schedulelist = aee.data;
  75. }
  76. }
  77. that.setData({
  78. conduct: datas,
  79. nostart: datastart,
  80. complete: dataend,
  81. })
  82. }
  83. },
  84. fail: res => {
  85. return wx.redirectTo({ url: '/pages/login/index', })
  86. }
  87. })
  88. },
  89. searchschedule: function (e) {
  90. wx.request({
  91. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
  92. method: 'get',
  93. data: { match_id: e._id },
  94. success(res) {
  95. if (res.data.errcode == 0) { } else {
  96. wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
  97. }
  98. }
  99. })
  100. },
  101. // 计算高度
  102. searchHeight: function () {
  103. let frameStyle = this.data.frameStyle;
  104. let client = app.globalData.client;
  105. let infoHeight = client.windowHeight;
  106. // 是否去掉状态栏
  107. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  108. // 是否减去底部菜单
  109. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  110. if (infoHeight) this.setData({ infoHeight: infoHeight })
  111. },
  112. /**
  113. * 生命周期函数--监听页面初次渲染完成
  114. */
  115. onReady: function () {
  116. },
  117. /**
  118. * 生命周期函数--监听页面显示
  119. */
  120. onShow: function () {
  121. },
  122. /**
  123. * 生命周期函数--监听页面隐藏
  124. */
  125. onHide: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面卸载
  129. */
  130. onUnload: function () {
  131. },
  132. /**
  133. * 页面相关事件处理函数--监听用户下拉动作
  134. */
  135. onPullDownRefresh: function () {
  136. },
  137. /**
  138. * 页面上拉触底事件的处理函数
  139. */
  140. onReachBottom: function () {
  141. },
  142. /**
  143. * 用户点击右上角分享
  144. */
  145. onShareAppMessage: function () {
  146. }
  147. })