index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. back: function () {
  23. wx.navigateBack({ url: '/pages/home/index' })
  24. },
  25. // 跳转菜单
  26. tabPath(e) {
  27. let { route } = e.detail.detail;
  28. if (route) wx.redirectTo({ url: `/${route}` })
  29. },
  30. //跳转详情
  31. tiao: function (e) {
  32. let { id, type } = e.currentTarget.dataset;
  33. if (type == 1) wx.navigateTo({ url: `/pages/list/index?id=${id}` })
  34. else wx.navigateTo({ url: `/pages/match/detail?id=${id}` })
  35. },
  36. //跳转页面
  37. jump(e) {
  38. let { type } = e.currentTarget.dataset;
  39. if (type) wx.navigateTo({ url: `/pages/${type}/index` })
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function (options) {
  45. // 监听用户是否登录
  46. this.watchLogin();
  47. // 计算高度
  48. this.searchHeight();
  49. },
  50. // 监听用户是否登录
  51. watchLogin: async function () {
  52. const that = this;
  53. wx.getStorage({
  54. key: 'token',
  55. success: async res => {
  56. const arr = await app.$get('/courtAdmin/api/match');
  57. if (arr.errcode === 0) {
  58. let datastart = arr.data.filter((i) => i.status == '2');
  59. let datas = arr.data.filter((i) => i.status == '3');
  60. let dataend = arr.data.filter((i) => i.status == '4');
  61. for (const val of datas) {
  62. if (val.status == '3') {
  63. const aee = await app.$get('/courtAdmin/api/schedule', { match_id: val._id });
  64. if (aee.errcode === 0) val.schedulelist = aee.data;
  65. }
  66. }
  67. that.setData({
  68. conduct: datas,
  69. nostart: datastart,
  70. complete: dataend,
  71. })
  72. }
  73. },
  74. fail: res => {
  75. return wx.redirectTo({ url: '/pages/login/index', })
  76. }
  77. })
  78. },
  79. // 计算高度
  80. searchHeight: function () {
  81. let frameStyle = this.data.frameStyle;
  82. let client = app.globalData.client;
  83. let infoHeight = client.windowHeight;
  84. // 是否去掉状态栏
  85. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  86. // 是否减去底部菜单
  87. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  88. if (infoHeight) this.setData({ infoHeight: infoHeight })
  89. },
  90. /**
  91. * 生命周期函数--监听页面初次渲染完成
  92. */
  93. onReady: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面显示
  97. */
  98. onShow: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function () {
  124. }
  125. })