App.vue 919 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script>
  2. import Cache from './utils/cache'
  3. export default {
  4. globalData: {
  5. },
  6. async onLaunch(options) {
  7. console.log('App Launch')
  8. const whitelist = [
  9. '/pages/login',
  10. '/pages/forget'
  11. ]
  12. const path = options.path ? '/' + options.path : '/pages/index'
  13. if (this.$api.user.isLogin()) {
  14. await this.$api.user.info().then(res => {
  15. this.$store.dispatch('user/info', res.data)
  16. })
  17. } else {
  18. if (whitelist.indexOf(path) === -1) {
  19. Cache.set('path', path)
  20. uni.reLaunch({
  21. url: '/pages/index'
  22. })
  23. }
  24. }
  25. },
  26. onShow() {
  27. console.log('App Show')
  28. },
  29. onHide() {
  30. console.log('App Hide')
  31. }
  32. }
  33. </script>
  34. <style lang="scss">
  35. /*每个页面公共css */
  36. @import "@/uni_modules/uview-ui/index.scss";
  37. @import '@/static/css/flex.scss';
  38. @import '@/static/css/common.scss';
  39. @import '@/static/css/iconfont.css';
  40. </style>