index.js 1.6 KB

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