index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '系统首页', leftArrow: false, useBar: false },
  8. // 主体高度
  9. infoHeight: '',
  10. // 上传图片
  11. imgList: []
  12. },
  13. // 上傳圖片
  14. imgUpl: function (e) {
  15. const that = this;
  16. let data = that.data.imgList;
  17. data.push(e.detail)
  18. that.setData({ imgList: data })
  19. },
  20. // 删除图片
  21. imgDel: function (e) {
  22. const that = this;
  23. let list = that.data.imgList;
  24. let arr = list.filter((i, index) => index != e.detail.index)
  25. that.setData({ imgList: arr })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. // 监听用户是否登录
  32. this.watchLogin();
  33. // 计算高度
  34. this.searchHeight();
  35. },
  36. // 监听用户是否登录
  37. watchLogin: function () {
  38. wx.getStorage({
  39. key: 'token',
  40. success: res => {
  41. // if (res.data) wx.redirectTo({ url: '/pages/home/index', })
  42. },
  43. fail: res => {
  44. wx.redirectTo({ url: '/pages/login/index', })
  45. }
  46. })
  47. },
  48. // 计算高度
  49. searchHeight: function () {
  50. let frameStyle = this.data.frameStyle;
  51. let client = app.globalData.client;
  52. let infoHeight = client.windowHeight;
  53. // 是否去掉状态栏
  54. if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  55. // 是否减去底部菜单
  56. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  57. if (infoHeight) this.setData({ infoHeight: infoHeight })
  58. },
  59. /**
  60. * 生命周期函数--监听页面初次渲染完成
  61. */
  62. onReady: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面显示
  66. */
  67. onShow: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. }
  94. })