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