index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. ids: '',
  10. src: '/image/yun.jpg',
  11. frameStyle: { useTop: false, name: '比赛列表', leftArrow: false, useBar: false, tabSelectid: '0' },
  12. // 主体高度
  13. infoHeight: '',
  14. active: 1,
  15. list: [],
  16. lists: [],
  17. listbang: [],
  18. listbisai: [],
  19. },
  20. // 监听用户是否登录
  21. watchLogin: function () {
  22. wx.getStorage({
  23. key: 'token',
  24. success: res => {
  25. var that = this;
  26. let id = that.ids
  27. wx.request({
  28. url: `${app.globalData.publicUrl}/courtAdmin/api/match/` + id, //接口地址
  29. method: 'get',
  30. // data: {},
  31. success(res) {
  32. console.log('res', res.data);
  33. if (res.data.errcode == 0) {
  34. let datas = res.data.data
  35. if (datas.status == 0) {
  36. datas.status = '待比赛'
  37. } else if (datas.status == 1) {
  38. datas.status = '进行中'
  39. } else if (datas.status == 2) {
  40. datas.status = '报名中'
  41. } else if (datas.status == 3) {
  42. datas.status = '已结束'
  43. }
  44. that.setData({
  45. list: datas,
  46. });
  47. // 查询参赛队伍数据
  48. that.ranks();
  49. // 查询赛程列表数据
  50. that.course();
  51. } else {
  52. wx.showToast({
  53. title: res.data.errmsg,
  54. icon: 'none',
  55. duration: 2000
  56. })
  57. }
  58. }
  59. })
  60. },
  61. fail: res => {
  62. return wx.redirectTo({ url: '/pages/login/index', })
  63. }
  64. })
  65. },
  66. // 查询参赛队伍数据
  67. ranks: function () {
  68. var that = this;
  69. var list = that.data.list;
  70. var match_id = that.ids;
  71. var match_name = list.name;
  72. wx.request({
  73. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  74. method: 'get',
  75. data: {
  76. "match_id": match_id,
  77. "match_name": match_name,
  78. },
  79. success(res) {
  80. if (res.data.errcode == 0) {
  81. let datacan = res.data.data
  82. that.setData({
  83. lists: datacan,
  84. listbang: datacan,
  85. });
  86. } else {
  87. wx.showToast({
  88. title: res.data.errmsg,
  89. icon: 'none',
  90. duration: 2000
  91. })
  92. }
  93. }
  94. })
  95. },
  96. // 查询赛程列表数据
  97. course: function () {
  98. var that = this;
  99. var list = that.data.list;
  100. var match_id = that.ids;
  101. var match_name = list.name;
  102. var match_time = list.match_time;
  103. wx.request({
  104. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
  105. method: 'get',
  106. data: {
  107. "match_id": match_id,
  108. "match_name": match_name,
  109. "match_time": match_time,
  110. },
  111. success(res) {
  112. if (res.data.errcode == 0) {
  113. let datasai = res.data.data
  114. that.setData({
  115. listbisai: datasai,
  116. });
  117. } else {
  118. wx.showToast({
  119. title: res.data.errmsg,
  120. icon: 'none',
  121. duration: 2000
  122. })
  123. }
  124. }
  125. })
  126. },
  127. back: function () {
  128. wx.navigateBack({ url: '/pages/home/index' })
  129. },
  130. tabPath(e) {
  131. let query = e.detail.detail;
  132. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  133. },
  134. /**
  135. * 生命周期函数--监听页面加载
  136. */
  137. onLoad: function (options) {
  138. // 监听用户是否登录
  139. this.watchLogin();
  140. // 计算高度
  141. this.searchHeight()
  142. this.ids = options.id;
  143. },
  144. // 计算高度
  145. searchHeight: function () {
  146. let frameStyle = this.data.frameStyle;
  147. let client = app.globalData.client;
  148. let infoHeight = client.windowHeight;
  149. // 减去状态栏
  150. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2)
  151. // 是否减去底部菜单
  152. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  153. if (infoHeight) this.setData({ infoHeight: infoHeight })
  154. },
  155. /**
  156. * 生命周期函数--监听页面初次渲染完成
  157. */
  158. onReady: function () {
  159. },
  160. /**
  161. * 生命周期函数--监听页面显示
  162. */
  163. onShow: function () {
  164. },
  165. /**
  166. * 生命周期函数--监听页面隐藏
  167. */
  168. onHide: function () {
  169. },
  170. /**
  171. * 生命周期函数--监听页面卸载
  172. */
  173. onUnload: function () {
  174. },
  175. /**
  176. * 页面相关事件处理函数--监听用户下拉动作
  177. */
  178. onPullDownRefresh: function () {
  179. },
  180. /**
  181. * 页面上拉触底事件的处理函数
  182. */
  183. onReachBottom: function () {
  184. },
  185. /**
  186. * 用户点击右上角分享
  187. */
  188. onShareAppMessage: function () {
  189. }
  190. })