index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. //赛程列表
  13. scheduleList: []
  14. },
  15. back: function () {
  16. wx.navigateBack({ url: '/pages/me/index' })
  17. },
  18. // 多选
  19. toSelect: function () {
  20. },
  21. // 删除多选
  22. toDel: function () {
  23. },
  24. // 保存
  25. toSubmit: function () { },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. // 计算高度
  31. this.searchHeight();
  32. // 监听用户是否登录
  33. this.watchLogin();
  34. },
  35. // 监听用户是否登录
  36. watchLogin: async function () {
  37. const that = this;
  38. wx.getStorage({
  39. key: 'token',
  40. success: async res => {
  41. const arr = await app.$get('/courtAdmin/api/schedule');
  42. if (arr.errcode === 0) that.setData({ scheduleList: arr.data })
  43. },
  44. fail: res => {
  45. wx.redirectTo({ url: '/pages/login/index', })
  46. }
  47. })
  48. },
  49. // 计算高度
  50. searchHeight: function () {
  51. let frameStyle = this.data.frameStyle;
  52. let client = app.globalData.client;
  53. let infoHeight = client.windowHeight;
  54. // 是否去掉状态栏
  55. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  56. // 是否减去底部菜单
  57. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  58. if (infoHeight) this.setData({ infoHeight: infoHeight })
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. }
  95. })