index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. const that = this;
  18. wx.getStorage({
  19. key: 'user',
  20. success: async (res) => { },
  21. fail: async (res) => {
  22. // wx.redirectTo({ url: '/pages/index/index' });
  23. },
  24. });
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. const that = this;
  36. // 监听用户是否登录
  37. that.watchLogin();
  38. },
  39. /**
  40. * 生命周期函数--监听页面隐藏
  41. */
  42. onHide: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面卸载
  46. */
  47. onUnload: function () {
  48. },
  49. /**
  50. * 页面相关事件处理函数--监听用户下拉动作
  51. */
  52. onPullDownRefresh: function () {
  53. },
  54. /**
  55. * 页面上拉触底事件的处理函数
  56. */
  57. onReachBottom: function () {
  58. },
  59. /**
  60. * 用户点击右上角分享
  61. */
  62. onShareAppMessage: function () {
  63. }
  64. })