App.vue 956 B

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