index.js 1.3 KB

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