index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: false, name: '比赛管理', leftArrow: false, useBar: true },
  8. // 主体高度
  9. infoHeight: '',
  10. // 背景
  11. bg_1: '/image/match_1.png',
  12. bg_2: '/image/match_2.png',
  13. bg_3: '/image/match_3.png',
  14. pm_1: '/image/paiming.png',
  15. sp_1: '/image/shenpi.png',
  16. list: [],
  17. // 选项卡
  18. tabs: {
  19. active: '3',
  20. list: [
  21. { title: '进行中', name: '3' },
  22. { title: '未开始', name: '0' },
  23. { title: '已结束', name: '4' },
  24. ],
  25. },
  26. },
  27. back: function () {
  28. wx.navigateBack({ url: '/pages/home/index' })
  29. },
  30. tabPath: function (e) {
  31. let { route } = e.detail.detail;
  32. if (route) wx.redirectTo({ url: `/${route}` })
  33. },
  34. // 选项卡
  35. tabsChange: function (e) {
  36. const that = this;
  37. that.setData({ 'tabs.active': e.detail.name })
  38. },
  39. // 公共路由跳转方法
  40. toCommon: function (e) {
  41. const { route } = e.currentTarget.dataset;
  42. wx.navigateTo({ url: `/pages/${route}/index` })
  43. },
  44. // 查看详情
  45. toView: function (e) {
  46. console.log(e);
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad: function (options) {
  52. // 计算高度
  53. this.searchHeight();
  54. // 监听用户是否登录
  55. this.watchLogin();
  56. },
  57. // 监听用户是否登录
  58. watchLogin: function () {
  59. const that = this;
  60. let status = that.data.tabs.active;
  61. wx.getStorage({
  62. key: 'token',
  63. success: async res => {
  64. const arr = await app.$get(`/courtAdmin/api/match`, {})
  65. if (arr.errcode == '0') that.setData({ list: arr.data })
  66. },
  67. fail: res => {
  68. wx.redirectTo({ url: '/pages/index/index', })
  69. }
  70. })
  71. },
  72. // 计算高度
  73. searchHeight: function () {
  74. let frameStyle = this.data.frameStyle;
  75. let client = app.globalData.client;
  76. let infoHeight = client.windowHeight;
  77. // 是否去掉状态栏
  78. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  79. // 是否减去底部菜单
  80. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  81. if (infoHeight) this.setData({ infoHeight: infoHeight })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. onShow: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function () {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function () {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function () {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function () {
  117. }
  118. })