Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-11-01 13:34:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eeec4e096dd9c24ad87439fd962e6d78dc2d67c5
eeec4e09
1 parent
9c716a78
✨ feat: 处理授权从定向问题
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
8 deletions
src/app.js
src/pages/auth/index.vue
src/stores/router.js
src/utils/request.js
src/app.js
View file @
eeec4e0
/*
* @Date: 2022-09-19 14:11:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-01 1
1:49:42
* @LastEditTime: 2022-11-01 1
3:28:38
* @FilePath: /swx/src/app.js
* @Description: 文件描述
*/
...
...
@@ -11,7 +11,7 @@ import './app.less'
import
'@/components/vant-weapp/common/index.wxss'
import
request
from
'./utils/request'
;
import
Taro
from
'@tarojs/taro'
import
{
getCurrentPageUrl
}
from
"@/utils/weapp"
;
import
{
routerStore
}
from
'@/stores/router'
const
App
=
createApp
({
// 可以使用所有的 Vue 生命周期方法
...
...
@@ -22,6 +22,9 @@ const App = createApp({
onLaunch
(
options
)
{
// 未授权状态跳转授权页面,首页不需要权限
const
path
=
options
.
path
;
// 缓存没有权限的地址
const
router
=
routerStore
();
router
.
add
(
path
);
if
(
path
!==
'pages/index/index'
&&
!
wx
.
getStorageSync
(
"sessionid"
))
{
wx
.
navigateTo
({
url
:
'./pages/auth/index'
...
...
src/pages/auth/index.vue
View file @
eeec4e0
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-1
0-21 17:24:06
* @LastEditTime: 2022-1
1-01 13:32:00
* @FilePath: /swx/src/pages/auth/index.vue
* @Description: 文件描述
-->
...
...
@@ -21,6 +21,8 @@ import request from '@/utils/request';
<script>
import "./index.less";
import { getCurrentPageParam } from "@/utils/weapp";
export default {
name: "authPage",
mounted () {
...
...
@@ -42,9 +44,9 @@ export default {
// 修改请求头
request.defaults.headers.cookie = res.cookies[0];
if (res.data.data.avatar) {
Taro.
navigateBack
({
delta: 1 // 返回上一级页面。
})
;
Taro.
redirectTo
({
url: '../../' + getCurrentPageParam().url
})
} else { // 头像没有设置跳转完善信息页面
Taro.redirectTo({
url: '../apxUserInfo/index'
...
...
src/stores/router.js
0 → 100755
View file @
eeec4e0
/*
* @Date: 2022-10-28 14:34:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-01 13:27:09
* @FilePath: /swx/src/stores/router.js
* @Description: 缓存路由信息
*/
import
{
defineStore
}
from
'pinia'
export
const
routerStore
=
defineStore
(
'router'
,
{
state
:
()
=>
{
return
{
url
:
''
,
}
},
actions
:
{
add
(
path
)
{
this
.
url
=
path
},
remove
()
{
this
.
url
=
''
},
},
})
src/utils/request.js
View file @
eeec4e0
/*
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-1
0-18 15:02:01
* @LastEditTime: 2022-1
1-01 13:29:19
* @FilePath: /swx/src/utils/request.js
* @Description: 简单axios封装,后续按实际处理
*/
...
...
@@ -11,6 +11,7 @@ import Taro from '@tarojs/taro'
import
Toast
from
'../components/vant-weapp/toast/toast'
;
import
{
strExist
}
from
'./tools'
import
qs
from
'Qs'
import
{
routerStore
}
from
'@/stores/router'
// import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress';
// import store from '@/store'
...
...
@@ -94,7 +95,7 @@ service.interceptors.response.use(
* 授权完成后 返回当前页面
*/
Taro
.
navigateTo
({
url
:
'../../pages/auth/index
'
url
:
'../../pages/auth/index
?url='
+
routerStore
().
url
})
}
return
response
...
...
Please
register
or
login
to post a comment