mine.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const { sessionStorageKey } = require('../../api/request')
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. navBarHeight: app.globalData.navBarHeight,
  9. navBarConfig: {
  10. booFixed: true,
  11. backgroundColor: ''
  12. },
  13. sessionId: '',
  14. userInfo: {}
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. this.setData({
  31. sessionId: wx.getStorageSync(sessionStorageKey),
  32. userInfo: app.globalData.userInfo
  33. })
  34. },
  35. /**
  36. * 生命周期函数--监听页面隐藏
  37. */
  38. onHide: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload: function () {
  44. },
  45. jump(e) {
  46. const { navigate } = e.currentTarget.dataset
  47. const index = ['order', 'invoice', 'setting', 'feedback'].findIndex(item => item === navigate)
  48. if (!this.data.sessionId && index > -1) {
  49. wx.navigateTo({
  50. url: '/pages/login/login'
  51. })
  52. return
  53. }
  54. if (this.data.sessionId && navigate === 'login') {
  55. return
  56. }
  57. wx.navigateTo({
  58. url: `/pages/${navigate}/${navigate}`
  59. })
  60. }
  61. })