diff --git a/src/api/service.js b/src/api/service.js index 8b79c53..f37ad1f 100644 --- a/src/api/service.js +++ b/src/api/service.js @@ -32,6 +32,7 @@ instance.interceptors.request.use(request => { }) instance.interceptors.response.use(response => { + const { path, query } = router.currentRoute; if(response.status === 200){ if(response.data.code === 0){ return response.data.data; @@ -40,9 +41,12 @@ instance.interceptors.response.use(response => { location.href = '/api/wx/oauth?jumpUrl='+encodeURIComponent(location.href) return } + console.log('query', new URLSearchParams(query).toString()) + console.log('fullPath', path) if(response.data.code === 1000023){ Toast('请验证手机号') - return router.push({ name: 'get-user-phone'}); + const queryString = new URLSearchParams(query).toString(); + return router.push({ name: 'get-user-phone', query: { redirectPath: path, redirectPathQuery: encodeURIComponent(queryString)}}); } if(response.data.code !== 0){ Toast.fail(response.data.message) diff --git a/src/pages/get-user-phone/index.vue b/src/pages/get-user-phone/index.vue index 29af8fb..f581ca3 100644 --- a/src/pages/get-user-phone/index.vue +++ b/src/pages/get-user-phone/index.vue @@ -61,6 +61,7 @@ export default { }, data() { return { + query: this.$route.query, mobile: '', validCode: '', countdown: 0, @@ -101,8 +102,10 @@ export default { this.$toast.success('登记成功,请继续后续操作') this.$delay(500); this.$bus.$emit('updateMobile') - this.$router.back(); - // this.$router.replace({ name: 'user-home'}) + this.$router.replace({ + path: this.query.redirectPath, + query: this.$utils.queryStringToObj(decodeURIComponent(this.query.redirectPathQuery)) + }) } }, onSendCode(){ diff --git a/src/util/index.js b/src/util/index.js index 2a0926f..8b676ad 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -16,5 +16,16 @@ export default { return before+'?'+after+'&'+key+'='+value; } return before+(hasQuery ? '?': '&') + after; + }, + queryStringToObj(queryString){ + const string = queryString.split('&'); + const obj = {}; + + string.forEach(str => { + const [key, value] = str.split('='); + obj[key] = value; + }) + + return obj; } } \ No newline at end of file diff --git a/wap/index.html b/wap/index.html index a5870ce..67b2b39 100644 --- a/wap/index.html +++ b/wap/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file