index.js 3.3 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: 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({ conduct: datas, nostart: datastart, complete: dataend })
  68. }
  69. },
  70. fail: res => {
  71. return wx.redirectTo({ url: '/pages/login/index', })
  72. }
  73. })
  74. },
  75. // 计算高度
  76. searchHeight: function () {
  77. let frameStyle = this.data.frameStyle;
  78. let client = app.globalData.client;
  79. let infoHeight = client.windowHeight;
  80. // 是否去掉状态栏
  81. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  82. // 是否减去底部菜单
  83. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  84. if (infoHeight) this.setData({ infoHeight: infoHeight })
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面卸载
  103. */
  104. onUnload: function () {
  105. },
  106. /**
  107. * 页面相关事件处理函数--监听用户下拉动作
  108. */
  109. onPullDownRefresh: function () {
  110. },
  111. /**
  112. * 页面上拉触底事件的处理函数
  113. */
  114. onReachBottom: function () {
  115. },
  116. /**
  117. * 用户点击右上角分享
  118. */
  119. onShareAppMessage: function () {
  120. }
  121. })