index.js 1.4 KB

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