index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. //getSales:temp,
  46. list: datas,
  47. });
  48. // 查询参赛队伍数据
  49. that.ranks();
  50. // 查询赛程列表数据
  51. that.course();
  52. } else {
  53. wx.showToast({
  54. title: res.data.errmsg,
  55. icon: 'none',
  56. duration: 2000
  57. })
  58. }
  59. }
  60. })
  61. },
  62. fail: res => {
  63. return wx.redirectTo({ url: '/pages/login/index', })
  64. }
  65. })
  66. },
  67. // 查询参赛队伍数据
  68. ranks: function () {
  69. var that = this;
  70. var list = that.data.list;
  71. var match_id = that.ids;
  72. var match_name = list.name;
  73. wx.request({
  74. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  75. method: 'get',
  76. data: {
  77. "match_id": match_id,
  78. "match_name": match_name,
  79. },
  80. success(res) {
  81. if (res.data.errcode == 0) {
  82. let datacan = res.data.data
  83. that.setData({
  84. lists: datacan,
  85. listbang: datacan,
  86. });
  87. } else {
  88. wx.showToast({
  89. title: res.data.errmsg,
  90. icon: 'none',
  91. duration: 2000
  92. })
  93. }
  94. }
  95. })
  96. },
  97. // 查询赛程列表数据
  98. course: function () {
  99. var that = this;
  100. var list = that.data.list;
  101. var match_id = that.ids;
  102. var match_name = list.name;
  103. var match_time = list.match_time;
  104. wx.request({
  105. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
  106. method: 'get',
  107. data: {
  108. "match_id": match_id,
  109. "match_name": match_name,
  110. "match_time": match_time,
  111. },
  112. success(res) {
  113. if (res.data.errcode == 0) {
  114. let datasai = res.data.data
  115. that.setData({
  116. listbisai: datasai,
  117. });
  118. } else {
  119. wx.showToast({
  120. title: res.data.errmsg,
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. }
  125. }
  126. })
  127. },
  128. back: function () {
  129. wx.navigateBack({ url: '/pages/home/index' })
  130. },
  131. tabPath(e) {
  132. let query = e.detail.detail;
  133. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  134. },
  135. /**
  136. * 生命周期函数--监听页面加载
  137. */
  138. onLoad: function (options) {
  139. // 监听用户是否登录
  140. this.watchLogin();
  141. // 计算高度
  142. this.searchHeight()
  143. this.ids = options.id;
  144. },
  145. // 计算高度
  146. searchHeight: function () {
  147. let frameStyle = this.data.frameStyle;
  148. let client = app.globalData.client;
  149. let infoHeight = client.windowHeight;
  150. // 减去状态栏
  151. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2)
  152. // 是否减去底部菜单
  153. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  154. if (infoHeight) this.setData({ infoHeight: infoHeight })
  155. },
  156. /**
  157. * 生命周期函数--监听页面初次渲染完成
  158. */
  159. onReady: function () {
  160. },
  161. /**
  162. * 生命周期函数--监听页面显示
  163. */
  164. onShow: function () {
  165. },
  166. /**
  167. * 生命周期函数--监听页面隐藏
  168. */
  169. onHide: function () {
  170. },
  171. /**
  172. * 生命周期函数--监听页面卸载
  173. */
  174. onUnload: function () {
  175. },
  176. /**
  177. * 页面相关事件处理函数--监听用户下拉动作
  178. */
  179. onPullDownRefresh: function () {
  180. },
  181. /**
  182. * 页面上拉触底事件的处理函数
  183. */
  184. onReachBottom: function () {
  185. },
  186. /**
  187. * 用户点击右上角分享
  188. */
  189. onShareAppMessage: function () {
  190. }
  191. })