Browse Source

fix(wechatAuth): 修复微信授权回调后重定向URL丢失的问题

存储并处理微信授权回调中的redirectUri参数,确保授权后能正确跳转
lsc 1 month ago
parent
commit
9efed773f9

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 1 - 1
dist/report.html


+ 1 - 1
dist/static/css/chunk-1e7b5248.6ebbbd55.css → dist/static/css/chunk-93dc4c3a.5b517933.css

@@ -1 +1 @@
-.wechat-auth-container[data-v-295fefc8]{min-height:100vh;background:-webkit-linear-gradient(315deg,#667eea,#764ba2);background:linear-gradient(135deg,#667eea,#764ba2);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;padding:.53333rem}.wechat-auth-container .auth-content[data-v-295fefc8]{background:#fff;border-radius:.42667rem;padding:1.06667rem .8rem;text-align:center;box-shadow:0 .26667rem .8rem rgba(0,0,0,.1);max-width:10.66667rem;width:100%}.wechat-auth-container .auth-content .logo[data-v-295fefc8]{margin-bottom:.8rem}.wechat-auth-container .auth-content .logo img[data-v-295fefc8]{width:2.13333rem;height:2.13333rem;border-radius:50%}.wechat-auth-container .auth-content .auth-status .van-icon[data-v-295fefc8],.wechat-auth-container .auth-content .auth-status .van-loading[data-v-295fefc8]{margin-bottom:.53333rem}.wechat-auth-container .auth-content .auth-status p[data-v-295fefc8]{margin:.26667rem 0;font-size:.42667rem;color:#333}.wechat-auth-container .auth-content .auth-status p.user-info[data-v-295fefc8]{font-size:.37333rem;color:#666;margin-top:.26667rem}.wechat-auth-container .auth-content .auth-status p.auth-desc[data-v-295fefc8]{font-size:.37333rem;color:#999;margin:.4rem 0 .66667rem}.wechat-auth-container .auth-content .auth-status p.error-message[data-v-295fefc8]{font-size:.37333rem;color:#ee0a24;margin:.4rem 0 .66667rem}.wechat-auth-container .auth-content .auth-status .van-button[data-v-295fefc8]{margin-top:.53333rem;width:5.33333rem;height:1.17333rem;border-radius:.58667rem}@media (max-width:480px){.wechat-auth-container[data-v-295fefc8]{padding:.26667rem}.wechat-auth-container .auth-content[data-v-295fefc8]{padding:.8rem .53333rem}.wechat-auth-container .auth-content .auth-status .van-button[data-v-295fefc8]{width:100%}}
+.wechat-auth-container[data-v-1aaae12b]{min-height:100vh;background:-webkit-linear-gradient(315deg,#667eea,#764ba2);background:linear-gradient(135deg,#667eea,#764ba2);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;padding:.53333rem}.wechat-auth-container .auth-content[data-v-1aaae12b]{background:#fff;border-radius:.42667rem;padding:1.06667rem .8rem;text-align:center;box-shadow:0 .26667rem .8rem rgba(0,0,0,.1);max-width:10.66667rem;width:100%}.wechat-auth-container .auth-content .logo[data-v-1aaae12b]{margin-bottom:.8rem}.wechat-auth-container .auth-content .logo img[data-v-1aaae12b]{width:2.13333rem;height:2.13333rem;border-radius:50%}.wechat-auth-container .auth-content .auth-status .van-icon[data-v-1aaae12b],.wechat-auth-container .auth-content .auth-status .van-loading[data-v-1aaae12b]{margin-bottom:.53333rem}.wechat-auth-container .auth-content .auth-status p[data-v-1aaae12b]{margin:.26667rem 0;font-size:.42667rem;color:#333}.wechat-auth-container .auth-content .auth-status p.user-info[data-v-1aaae12b]{font-size:.37333rem;color:#666;margin-top:.26667rem}.wechat-auth-container .auth-content .auth-status p.auth-desc[data-v-1aaae12b]{font-size:.37333rem;color:#999;margin:.4rem 0 .66667rem}.wechat-auth-container .auth-content .auth-status p.error-message[data-v-1aaae12b]{font-size:.37333rem;color:#ee0a24;margin:.4rem 0 .66667rem}.wechat-auth-container .auth-content .auth-status .van-button[data-v-1aaae12b]{margin-top:.53333rem;width:5.33333rem;height:1.17333rem;border-radius:.58667rem}@media (max-width:480px){.wechat-auth-container[data-v-1aaae12b]{padding:.26667rem}.wechat-auth-container .auth-content[data-v-1aaae12b]{padding:.8rem .53333rem}.wechat-auth-container .auth-content .auth-status .van-button[data-v-1aaae12b]{width:100%}}

File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.31f52882.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-1e7b5248.d3531a37.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-93dc4c3a.3f0a5a5a.js


+ 17 - 7
src/permission.js

@@ -68,13 +68,23 @@ router.beforeEach(async(to, from, next) => {
         //   // 可以添加其他需要的参数
         //   timestamp: Date.now().toString()
         // }).toString()
-        const redirect_uri = to.query.url ? encodeURIComponent('url=' + encodeURIComponent(to.query.url)) : ''
-        const isApp = to.query.isApp ? to.query.isApp : '2'
-        if (isApp === '2' && redirect_uri) {
-          // window.location.href = `weixin://dl/business/?appid=wxf8a72764a38a40b2&path=pages/index/index&query=${redirect_uri}`
-          window.location.href = decodeURIComponent(to.query.url)
-        } else if (redirect_uri) {
-          window.location.href = decodeURIComponent(to.query.url)
+        // 从 URL 参数或 Cookie 中获取 redirect_uri
+
+        //  const redirect_uri = to.query.url ? to.query.url : ''
+        // const isApp = to.query.isApp ? to.query.isApp : '2'
+        // if (isApp === '2' && redirect_uri) {
+        //   // window.location.href = `weixin://dl/business/?appid=wxf8a72764a38a40b2&path=pages/index/index&query=${redirect_uri}`
+        //   window.location.href = decodeURIComponent(to.query.url)
+        // } else if (redirect_uri) {
+        //   window.location.href = decodeURIComponent(to.query.url)
+        
+        const redirect_uri = to.query.url ? to.query.url : Cookies.get('redirectUri') || ''
+        // 从 URL 参数或 Cookie 中获取 isApp
+        // const isApp = to.query.isApp ? to.query.isApp : Cookies.get('isApp') || '2'
+        if (redirect_uri) {
+          // 如果有 redirect_uri,清除 Cookie 并跳转
+          Cookies.remove('redirectUri')
+          window.location.href = decodeURIComponent(redirect_uri)
         } else {
           next({ path: '/appStoreCopy' })
         }

+ 5 - 1
src/views/wechatAuth/index.vue

@@ -353,7 +353,11 @@ export default {
       Cookies.set('isWeChat', '2')
     }
     await this.getLogin()
-
+    const redirectUri = this.$route.query.url ? decodeURIComponent(this.$route.query.url) : null
+    console.log('redirectUri from query:', redirectUri)
+    if (redirectUri && redirectUri !== 'undefined') {
+      Cookies.set('redirectUri', redirectUri)
+    }
     // 如果有code参数,说明是从微信授权回调过来的
     if (this.code) {
       this.handleAuthCallback()

Some files were not shown because too many files changed in this diff