index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: false, name: '比赛列表', leftArrow: false, useBar: false, tabSelectid: '0' },
  10. ids: '',
  11. src: '/image/yun.jpg',
  12. // 主体高度
  13. infoHeight: '',
  14. active: 1,
  15. teamlist: [],
  16. ranks: [],
  17. listbang: [],
  18. schedule: [],
  19. },
  20. back: function () {
  21. wx.navigateBack({ url: '/pages/home/index' })
  22. },
  23. tabPath(e) {
  24. let query = e.detail.detail;
  25. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. this.setData({ ids: options.id });
  32. // 计算高度
  33. this.searchHeight();
  34. // 监听用户是否登录
  35. this.watchLogin();
  36. },
  37. // 监听用户是否登录
  38. watchLogin: function () {
  39. var that = this;
  40. wx.getStorage({
  41. key: 'token',
  42. success: res => {
  43. wx.request({
  44. url: `${app.globalData.publicUrl}/courtAdmin/api/match/${this.data.ids}`, //接口地址
  45. method: 'get',
  46. // data: {},
  47. success(res) {
  48. if (res.data.errcode == 0) {
  49. let datas = res.data.data
  50. that.setData({
  51. teamlist: datas,
  52. });
  53. // 查询参赛队伍数据
  54. that.ranks();
  55. // 查询赛程列表数据
  56. that.course();
  57. } else {
  58. wx.showToast({
  59. title: res.data.errmsg,
  60. icon: 'none',
  61. duration: 2000
  62. })
  63. }
  64. }
  65. })
  66. },
  67. fail: res => {
  68. return wx.redirectTo({ url: '/pages/login/index', })
  69. }
  70. })
  71. },
  72. // 查询参赛队伍数据
  73. ranks: function () {
  74. var that = this;
  75. let match_id =that.data.ids;
  76. wx.request({
  77. url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
  78. method: 'get',
  79. data: { match_id:match_id},
  80. success(res) {
  81. if (res.data.errcode == 0) {
  82. let datacan = res.data.data
  83. that.setData({
  84. ranks: 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. let match_id =that.data.ids;
  101. wx.request({
  102. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
  103. method: 'get',
  104. data: { match_id:match_id},
  105. success(res) {
  106. if (res.data.errcode == 0) {
  107. let datasai = res.data.data
  108. that.setData({
  109. schedule: datasai,
  110. });
  111. } else {
  112. wx.showToast({
  113. title: res.data.errmsg,
  114. icon: 'none',
  115. duration: 2000
  116. })
  117. }
  118. }
  119. })
  120. },
  121. // 计算高度
  122. searchHeight: function () {
  123. let frameStyle = this.data.frameStyle;
  124. let client = app.globalData.client;
  125. let infoHeight = client.windowHeight;
  126. // 减去状态栏
  127. if (frameStyle.useTop) infoHeight = infoHeight - (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. })