login.vue 723 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <view class="login" />
  3. </template>
  4. <script>
  5. export default {
  6. data() {
  7. return {
  8. path: '/pages/index/index'
  9. }
  10. },
  11. computed: {},
  12. methods: {
  13. login() {
  14. this.$loading('登陆中...')
  15. this.$api.user.login().then(async res => {
  16. this.$hideLoading()
  17. const { token, user_info } = res.data
  18. await this.$store.dispatch('user/token', token)
  19. await this.$store.dispatch('user/info', user_info)
  20. uni.reLaunch({
  21. url: this.path.replace('//', '/')
  22. })
  23. })
  24. }
  25. },
  26. onLoad(options) {
  27. this.path = options.path ? options.path : this.path
  28. this.login()
  29. }
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. .login{
  34. }
  35. </style>