info.js 5.9 KB

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