index.js 3.0 KB

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