index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. // 计算高度
  90. searchHeight: function () {
  91. let frameStyle = this.data.frameStyle;
  92. let client = app.globalData.client;
  93. let infoHeight = client.windowHeight;
  94. // 是否去掉状态栏
  95. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  96. // 是否减去底部菜单
  97. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  98. if (infoHeight) this.setData({ infoHeight: infoHeight })
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })