|
@@ -1,4 +1,5 @@
|
|
|
import store from '@/store'
|
|
|
+import { pcLogin } from '@/api/user'
|
|
|
|
|
|
export default (router) => {
|
|
|
// 路由白名单,可以考虑不同环境配置不同白名单
|
|
@@ -6,6 +7,13 @@ export default (router) => {
|
|
|
|
|
|
// 全局路由前置守卫
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
+ if (!uni.getStorageSync('user')) {
|
|
|
+ let res = await pcLogin().catch(() => {})
|
|
|
+ if (res) {
|
|
|
+ uni.setStorageSync('user', res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
next() //小程序登录接口还没有出来,先放开路由拦截器
|
|
|
return
|
|
|
const token = store.state.vuex_access_token
|