index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. const app = getApp();
  2. import * as httpUtil from "../../utils/httpUtil";
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '系统首页', leftArrow: false, useBar: false },
  9. // 主体高度
  10. infoHeight: '',
  11. // 上传图片
  12. imgList: []
  13. },
  14. // 上傳圖片
  15. imgUpl: function (e) {
  16. const that = this;
  17. let data = that.data.imgList;
  18. data.push(e.detail)
  19. that.setData({ imgList: data })
  20. },
  21. // 删除图片
  22. imgDel: function (e) {
  23. const that = this;
  24. let list = that.data.imgList;
  25. let arr = list.filter((i, index) => index != e.detail.index)
  26. that.setData({ imgList: arr })
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. // 监听用户是否登录
  33. this.watchLogin();
  34. // 计算高度
  35. this.searchHeight();
  36. },
  37. // 监听用户是否登录
  38. watchLogin: function () {
  39. // httpUtil.$get('/courtAdmin/api/match').then(res => {
  40. // if (res.errcode === 0) {
  41. // for (const val of res.data) {
  42. // if (val.status == '3') {
  43. // httpUtil.$get('/courtAdmin/api/schedule', { match_id: val._id }).then(res => {
  44. // if (res.errcode === 0) {
  45. // val.schedulelist = res.data;
  46. // }
  47. // })
  48. // }
  49. // }
  50. // console.log(res.data);
  51. // }
  52. // })
  53. wx.getStorage({
  54. key: 'token',
  55. success: res => {
  56. if (res.data) wx.redirectTo({ url: '/pages/home/index', })
  57. },
  58. fail: res => {
  59. 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. })