App.vue 782 B

123456789101112131415161718192021222324252627282930313233
  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. await this.$api.user.login().then(res => {
  11. const { token, user_info } = res.data
  12. this.$store.dispatch('user/token', token)
  13. this.$store.dispatch('user/info', user_info)
  14. })
  15. }
  16. },
  17. onShow() {
  18. console.log('App Show')
  19. },
  20. onHide() {
  21. console.log('App Hide')
  22. }
  23. }
  24. </script>
  25. <style lang="scss">
  26. /*每个页面公共css */
  27. @import "@/uni_modules/uview-ui/index.scss";
  28. @import '@/static/css/flex.scss';
  29. @import '@/static/css/common.scss';
  30. @import '@/static/css/iconfont.css';
  31. </style>