Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-07 11:34:59 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3e481cf35572073c0e4faf805b690ccc63190e04
3e481cf3
1 parent
2f18f3a9
✨ feat: 微信授权API联调
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
src/utils/axios.js
src/views/auth.vue
src/utils/axios.js
View file @
3e481cf
...
...
@@ -26,9 +26,16 @@ axios.interceptors.request.use(
// 响应拦截器
axios
.
interceptors
.
response
.
use
(
response
=>
{
if
(
response
.
data
.
code
===
401
)
{
// 未授权跳转登录页
let
userType
=
router
.
currentRoute
.
value
.
href
.
indexOf
(
'business'
)
>
0
?
'b'
:
'c'
;
if
(
response
.
data
.
code
===
401
)
{
// 未授权跳转登录页
// 带着上一个页面的信息
router
.
replace
({
path
:
'/auth'
path
:
'/auth'
,
query
:
{
href
:
router
.
currentRoute
.
value
.
href
,
userType
}
});
}
return
response
;
...
...
src/views/auth.vue
View file @
3e481cf
...
...
@@ -11,9 +11,11 @@ import { Toast } from 'vant';
const $route = useRoute();
const $router = useRouter();
onMounted(() => {
})
onMounted(() => {
// php需要先跳转链接获取openid
let url = location.origin + '/' + $route.query.href; // 未授权的地址
location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}`
})
</script>
<script>
...
...
@@ -21,12 +23,12 @@ import mixin from 'common/mixin';
export default {
mixins: [mixin.init],
data
() {
data() {
return {
}
},
mounted
() {
mounted() {
},
methods: {
...
...
@@ -36,5 +38,4 @@ export default {
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment