examine.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: true, useBar: false },
  10. ids: '',
  11. src: '/image/adimges.jpg',
  12. // 主体高度
  13. infoHeight: '',
  14. //团队详情
  15. teamlist: [],
  16. //参考历史
  17. historylist: [],
  18. },
  19. back: function () {
  20. wx.navigateBack({ url: '/pages/home/index' })
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. this.setData({ ids: options.id });
  27. // 计算高度
  28. this.searchHeight()
  29. // 监听用户是否登录
  30. this.watchLogin();
  31. },
  32. // 监听用户是否登录
  33. watchLogin: function () {
  34. var that = this;
  35. let id = that.data.ids;
  36. wx.getStorage({
  37. key: 'token',
  38. success: res => {
  39. //查询数据
  40. wx.request({
  41. url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
  42. method: 'get',
  43. data: '',
  44. success(res) {
  45. that.setData({
  46. teamlist: res.data.data,
  47. });
  48. }
  49. })
  50. //查询历史比赛
  51. this.searchMatch(res.data.data);
  52. },
  53. fail: res => {
  54. return wx.redirectTo({ url: '/pages/login/index', })
  55. }
  56. })
  57. },
  58. //查询历史比赛
  59. searchMatch: async function (e) {
  60. const that = this;
  61. let id = that.data.ids;
  62. let data = [];
  63. const res = await app.$get('/courtAdmin/api/schedule', { red_id: id, status: '2' });
  64. if (res.errcode === 0) data = res.data;
  65. const arr = await app.$get('/courtAdmin/api/schedule', { blue_id: id, status: '2' });
  66. if (arr.errcode === 0) data = [...data, ...arr.data];
  67. that.setData({ historylist: data })
  68. },
  69. // 计算高度
  70. searchHeight: function () {
  71. let frameStyle = this.data.frameStyle;
  72. let client = app.globalData.client;
  73. let infoHeight = client.windowHeight;
  74. // 是否去掉状态栏
  75. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  76. // 是否减去底部菜单
  77. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  78. if (infoHeight) this.setData({ infoHeight: infoHeight })
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面隐藏
  92. */
  93. onHide: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面卸载
  97. */
  98. onUnload: function () {
  99. },
  100. /**
  101. * 页面相关事件处理函数--监听用户下拉动作
  102. */
  103. onPullDownRefresh: function () {
  104. },
  105. /**
  106. * 页面上拉触底事件的处理函数
  107. */
  108. onReachBottom: function () {
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. onShareAppMessage: function () {
  114. }
  115. })