index.js 2.8 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: true, name: '查询比赛', leftArrow: false, useBar: true },
  10. src: '/image/home.png',
  11. // 主体高度
  12. infoHeight: '',
  13. list: [],
  14. listend: [],
  15. },
  16. // 跳转菜单
  17. tabPath(e) {
  18. let { route } = e.detail.detail;
  19. if (route) wx.redirectTo({ url: `/${route}` })
  20. },
  21. //跳转详情
  22. tiao: function (e) {
  23. let id = e.currentTarget.dataset.name;
  24. wx.navigateTo({
  25. url: '/pages/list/index?id=' + id,
  26. })
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  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`, //接口地址
  45. method: 'get',
  46. data: {},
  47. success(res) {
  48. if (res.data.errcode == 0) {
  49. let one = res.data.data.filter((i) => i.status == '1');
  50. let two = res.data.data.filter((i) => i.status == '4');
  51. that.setData({ list: one });
  52. that.setData({ listend: two });
  53. } else {
  54. wx.showToast({
  55. title: res.data.errmsg,
  56. icon: 'none',
  57. duration: 2000
  58. })
  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. })