From e7a71570ae1de9690026fc60e558ff773b711299 Mon Sep 17 00:00:00 2001 From: Wen Fangping Date: Thu, 10 Mar 2022 14:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/service.js | 6 +++++- src/pages/get-user-phone/index.vue | 7 +++++-- src/util/index.js | 11 +++++++++++ wap/index.html | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) 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