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