| | |
| | | <script> |
| | | import { tokenUtils } from '@/utils/axios.js'; |
| | | import { useLoginStore } from '@/stores/login.js' |
| | | import { storeToRefs } from 'pinia'; |
| | | import { isWeixin } from '@/utils/UA.js' |
| | | export default { |
| | | setup() { |
| | | const { lastRouteInfo } = useLoginStore() |
| | | const { lastRouteInfo } = storeToRefs(useLoginStore()) |
| | | return { lastRouteInfo } |
| | | }, |
| | | data() { |
| | | return { |
| | | loginType: '', //mobile、weixin |
| | | loginType: '', //mobilePhone、weixin |
| | | form: { |
| | | mobile: '', |
| | | code: '', |
| | |
| | | created() { |
| | | tokenUtils.clearTokens() |
| | | this.loginType = isWeixin ? 'weixin' : 'mobilePhone' |
| | | this.loginType = 'mobile' |
| | | if (isWeixin) { |
| | | this.loginType = 'weixin' |
| | | this.$router.replace({ path: '/h5/redirect' }) |
| | | } |
| | | }, |
| | | computed: { |
| | | appId() { |
| | |
| | | const resData = res.data.data |
| | | tokenUtils.setTokens(resData.accessToken, resData.refreshToken) |
| | | this.$message.success('登录成功') |
| | | if (this.lastRouteInfo.name) { |
| | | this.$router.replace(this.lastRouteInfo) |
| | | const path = localStorage.getItem('verify_url') |
| | | if (path) { |
| | | this.$router.replace(path) |
| | | } |
| | | } else { |
| | | this.$message.error(res.data.msg || '登录失败') |
| | |
| | | this.loginLoading = false |
| | | }) |
| | | }, |
| | | verify() { |
| | | this.$router.push('/h5/verify') |
| | | }, |
| | | signup() { |
| | | this.$router.push('/h5/signup') |
| | | } |
| | | } |
| | | } |
| | | </script> |