detail.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. teamlist: [],
  13. },
  14. back: function () {
  15. wx.navigateBack({ url: '/pages/me/index' })
  16. },
  17. tabPath(e) {
  18. let query = e.detail.detail;
  19. if (query) wx.redirectTo({ url: `/pages/${query}/index` })
  20. },
  21. //维护
  22. maintain: function (e) {
  23. let { id, type } = e.currentTarget.dataset;
  24. if (type) wx.navigateTo({ url: `/pages/${type}/index?id=${id}` })
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. // 计算高度
  31. this.searchHeight();
  32. // 监听用户是否登录
  33. this.watchLogin();
  34. },
  35. // 监听用户是否登录
  36. watchLogin: function () {
  37. var that = this;
  38. wx.getStorage({
  39. key: 'token',
  40. success: res => {
  41. wx.request({
  42. url: `${app.globalData.publicUrl}/courtAdmin/api/match`, //接口地址
  43. method: 'get',
  44. data: {},
  45. success(res) {
  46. that.setData({ teamlist: res.data.data });
  47. }
  48. })
  49. },
  50. fail: res => {
  51. return wx.redirectTo({ url: '/pages/login/index', })
  52. }
  53. })
  54. },
  55. // 计算高度
  56. searchHeight: function () {
  57. let frameStyle = this.data.frameStyle;
  58. let client = app.globalData.client;
  59. let infoHeight = client.windowHeight;
  60. // 减去状态栏
  61. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2)
  62. // 是否减去底部菜单
  63. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  64. if (infoHeight) this.setData({ infoHeight: infoHeight })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. }
  101. })