index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const app = getApp()
  2. Page({
  3. data: {
  4. frameStyle: { useTop: true, name: '羽校', leftArrow: false, useBar: true },
  5. user: {}
  6. },
  7. // 跳转菜单
  8. tabPath(e) {
  9. let { route } = e.detail.detail;
  10. if (route) wx.redirectTo({ url: `/${route}` })
  11. },
  12. // 进入系统
  13. toJoin: function () {
  14. wx.navigateTo({ url: `/pages/smy/index` })
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) { },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function () { },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: function () {
  28. const that = this;
  29. // 监听用户是否登录
  30. that.watchLogin();
  31. },
  32. // 监听用户是否登录
  33. watchLogin: async function () {
  34. const that = this;
  35. wx.getStorage({
  36. key: 'user',
  37. success: async res => {
  38. that.setData({ user: res.data })
  39. },
  40. fail: async res => {
  41. wx.redirectTo({ url: '/pages/index/index' })
  42. }
  43. })
  44. },
  45. /**
  46. * 页面上拉触底事件的处理函数
  47. */
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面卸载
  55. */
  56. onUnload: function () {
  57. },
  58. /**
  59. * 页面相关事件处理函数--监听用户下拉动作
  60. */
  61. onPullDownRefresh: function () {
  62. },
  63. /**
  64. * 用户点击右上角分享
  65. */
  66. onShareAppMessage: function () {
  67. }
  68. })