index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. } else if (datas[i].status == 2) {
  41. datas[i].status = '待比赛'
  42. } else if (datas[i].status == 3) {
  43. datas[i].status = '进行中'
  44. datass.push(datas[i])
  45. }else if (datas[i].status == 4) {
  46. datas[i].status = '已结束'
  47. dataend.push(datas[i])
  48. }
  49. }
  50. that.setData({
  51. list: datass,
  52. liststart: datastart,
  53. listend: dataend,
  54. });
  55. } else {
  56. wx.showToast({
  57. title: res.data.errmsg,
  58. icon: 'none',
  59. duration: 2000
  60. })
  61. }
  62. }
  63. })
  64. },
  65. // 监听用户是否登录
  66. watchLogin: function () {
  67. wx.getStorage({
  68. key: 'token',
  69. success: res => {
  70. console.log(res);
  71. },
  72. fail: res => {
  73. return wx.redirectTo({ url: '/pages/login/index', })
  74. }
  75. })
  76. },
  77. tabPath(e) {
  78. let query = e.detail.detail;
  79. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  80. },
  81. tiao: function (e) {
  82. let id= e.currentTarget.dataset.name;
  83. console.log(id);
  84. wx.navigateTo({
  85. url: '/pages/list/index?id='+id,
  86. })
  87. },
  88. xun: function () {
  89. wx.navigateTo({
  90. url: '/pages/match/detail',
  91. })
  92. },
  93. jump: function () {
  94. wx.navigateTo({
  95. url: `/pages/competition/index`,
  96. })
  97. },
  98. tuan: function () {
  99. wx.navigateTo({
  100. url: `/pages/ranking/index`,
  101. })
  102. },
  103. shen: function () {
  104. wx.navigateTo({
  105. url: `/pages/manage/index`,
  106. })
  107. },
  108. //标签页
  109. setup() {
  110. const activeName = ref('a');
  111. return { activeName };
  112. },
  113. /**
  114. * 生命周期函数--监听页面加载
  115. */
  116. onLoad: function (options) {
  117. // 监听用户是否登录
  118. this.watchLogin();
  119. // 计算高度
  120. this.searchHeight()
  121. // 查询数据
  122. this.search();
  123. },
  124. // 计算高度
  125. searchHeight: function () {
  126. let frameStyle = this.data.frameStyle;
  127. let client = app.globalData.client;
  128. // 减去状态栏
  129. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  130. // 是否减去底部菜单
  131. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  132. if (infoHeight) this.setData({ infoHeight: infoHeight })
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload: function () {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh: function () {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom: function () {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage: function () {
  168. }
  169. })