index.js 3.9 KB

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