index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. // 主体高度
  10. infoHeight: '',
  11. frameStyle: { useTop: true, name: '赛程编排', leftArrow: true, useBar: false },
  12. alreadyList: [],
  13. id: ''
  14. },
  15. back: function () {
  16. wx.navigateBack({ url: '/pages/meMatch/index' })
  17. },
  18. //新增赛程编排
  19. addTo: function (e) {
  20. let id = this.data.id;
  21. wx.navigateTo({ url: `/pages/layNew/index?id=${id}`, })
  22. },
  23. //维护赛程编排
  24. modify: function (e) {
  25. let id = e.currentTarget.dataset.id;
  26. wx.navigateTo({url: `/pages/modify/index?id=${id}`,})
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. this.setData({ id: options.id })
  33. // 计算高度
  34. this.searchHeight();
  35. // 监听用户是否登录
  36. this.watchLogin();
  37. },
  38. // 监听用户是否登录
  39. watchLogin: function () {
  40. const that = this;
  41. wx.getStorage({
  42. key: 'token',
  43. success: res => {
  44. wx.request({
  45. url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
  46. method: 'get',
  47. data: { match_id: that.data.id },
  48. success(res) {
  49. that.setData({ alreadyList: res.data.data })
  50. }
  51. })
  52. },
  53. fail: res => {
  54. return wx.redirectTo({ url: '/pages/login/index', })
  55. }
  56. })
  57. },
  58. // 计算高度
  59. searchHeight: function () {
  60. let frameStyle = this.data.frameStyle;
  61. let client = app.globalData.client;
  62. let infoHeight = client.windowHeight;
  63. // 是否去掉状态栏
  64. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  65. // 是否减去底部菜单
  66. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  67. if (infoHeight) this.setData({ infoHeight: infoHeight })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function () {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh: function () {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function () {
  98. },
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage: function () {
  103. }
  104. })