index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. let { id, type } = e.currentTarget.dataset;
  23. if (type == 1) wx.navigateTo({ url: `/pages/list/index?id=${id}` })
  24. else wx.navigateTo({ url: `/pages/match/detail?id=${id}` })
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. // 计算高度
  31. this.searchHeight();
  32. // 监听用户是否登录
  33. this.watchLogin();
  34. },
  35. // 计算高度
  36. searchHeight: function () {
  37. let frameStyle = this.data.frameStyle;
  38. let client = app.globalData.client;
  39. let infoHeight = client.windowHeight;
  40. // 减去状态栏
  41. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2)
  42. // 是否减去底部菜单
  43. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  44. if (infoHeight) this.setData({ infoHeight: infoHeight })
  45. },
  46. // 监听用户是否登录
  47. watchLogin: async function () {
  48. const that = this;
  49. wx.getStorage({
  50. key: 'token',
  51. success: async res => {
  52. const arr = await app.$get('/courtAdmin/api/match');
  53. if (arr.errcode === 0) {
  54. for (const val of arr.data) {
  55. if (val.status == '3') {
  56. const aee = await app.$get('/courtAdmin/api/schedule', { match_id: val._id });
  57. if (aee.errcode === 0) val.schedulelist = aee.data;
  58. }
  59. }
  60. that.setData({ teamlist: arr.data })
  61. }
  62. },
  63. fail: res => {
  64. return wx.redirectTo({ url: '/pages/login/index', })
  65. }
  66. })
  67. },
  68. searchschedule: function (e) {
  69. wx.request({
  70. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
  71. method: 'get',
  72. data: { match_id: e._id },
  73. success(res) {
  74. if (res.data.errcode == 0) { } else {
  75. wx.showToast({ title: res.data.errmsg, icon: 'none', duration: 2000 })
  76. }
  77. }
  78. })
  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. })