hookehuyr

✨ feat: 微信授权API联调

...@@ -26,9 +26,16 @@ axios.interceptors.request.use( ...@@ -26,9 +26,16 @@ axios.interceptors.request.use(
26 // 响应拦截器 26 // 响应拦截器
27 axios.interceptors.response.use( 27 axios.interceptors.response.use(
28 response => { 28 response => {
29 - if (response.data.code === 401) { // 未授权跳转登录页 29 + let userType = router.currentRoute.value.href.indexOf('business') > 0 ? 'b' : 'c';
30 + if (response.data.code === 401) {
31 + // 未授权跳转登录页
32 + // 带着上一个页面的信息
30 router.replace({ 33 router.replace({
31 - path: '/auth' 34 + path: '/auth',
35 + query: {
36 + href: router.currentRoute.value.href,
37 + userType
38 + }
32 }); 39 });
33 } 40 }
34 return response; 41 return response;
......
...@@ -11,9 +11,11 @@ import { Toast } from 'vant'; ...@@ -11,9 +11,11 @@ import { Toast } from 'vant';
11 const $route = useRoute(); 11 const $route = useRoute();
12 const $router = useRouter(); 12 const $router = useRouter();
13 13
14 - onMounted(() => { 14 +onMounted(() => {
15 - 15 + // php需要先跳转链接获取openid
16 - }) 16 + let url = location.origin + '/' + $route.query.href; // 未授权的地址
17 + location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}`
18 +})
17 </script> 19 </script>
18 20
19 <script> 21 <script>
...@@ -21,12 +23,12 @@ import mixin from 'common/mixin'; ...@@ -21,12 +23,12 @@ import mixin from 'common/mixin';
21 23
22 export default { 24 export default {
23 mixins: [mixin.init], 25 mixins: [mixin.init],
24 - data () { 26 + data() {
25 return { 27 return {
26 28
27 } 29 }
28 }, 30 },
29 - mounted () { 31 + mounted() {
30 32
31 }, 33 },
32 methods: { 34 methods: {
...@@ -36,5 +38,4 @@ export default { ...@@ -36,5 +38,4 @@ export default {
36 </script> 38 </script>
37 39
38 <style lang="less" scoped> 40 <style lang="less" scoped>
39 -
40 </style> 41 </style>
...\ No newline at end of file ...\ No newline at end of file
......