Skip to content

Commit

Permalink
fix: 🐛 修复 app 端登录问题
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Mar 5, 2024
1 parent d1efe51 commit b5b03b1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/pages/login/phone/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<script>
import { version } from '/package.json'
import { appName, enterpriseInfo } from '@/configs/index'
import coderJSON from '@/utils/coderJSON.js'
export default {
data() {
Expand Down Expand Up @@ -96,10 +97,12 @@ export default {
try {
await user.getUserInfo()
const redirect = this.$Route.query.redirect
console.log('redirect', redirect)
if (redirect) {
this.$Router.replaceAll(JSON.parse(redirect))
if (this.$Route.query.redirect) {
const redirect = coderJSON.parse(this.$Route.query.redirect)
// console.log('redirect', redirect)
this.$Router.replaceAll(redirect)
}
else {
this.$Router.replaceAll('/')
Expand Down
4 changes: 2 additions & 2 deletions src/router/guards/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import permission from './permission/index.js'
import login from './login/index.js'
import realname from './realname/index.js'

import { defineMiddleware } from '$uni-router/middleware'

export default (app, router) => {
permission(router, { app })
login(router, { app })
defineMiddleware('realname', realname, { router, app })
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const loginPath = '/pages/login/phone/index'

const whiteList = [loginPath, '/pages/statement/index', '/pages/webview/index']

function permission(router) {
export default (router) => {
const userStore = store.useUserStore()

const loginRoute = to => ({
Expand Down Expand Up @@ -61,5 +61,3 @@ function permission(router) {

// router.afterEach(() => {})
}

export default permission
4 changes: 1 addition & 3 deletions src/router/guards/realname/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import store from '@/store/index.js'
import { useDialog, useToast } from '@/utils/modals'

function realname(router) {
export default (router) => {
const userStore = store.useUserStore()

router.beforeEach((to, from, next) => {
Expand Down Expand Up @@ -45,5 +45,3 @@ function realname(router) {
})
// router.afterEach(() => {})
}

export default realname
13 changes: 13 additions & 0 deletions src/utils/coderJSON.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function stringify(params) {
const value = encodeURIComponent(JSON.stringify(params))
return value
}
export function parse(params) {
const value = JSON.parse(decodeURIComponent(params))
return value
}

export default {
stringify,
parse,
}

0 comments on commit b5b03b1

Please sign in to comment.