|
|
@@ -192,7 +192,20 @@ export default {
|
|
|
},
|
|
|
onLoad(query) {
|
|
|
// 静默登录
|
|
|
- if (query.code) this.onLogin()
|
|
|
+ // 1. 获取URL中的code和state参数
|
|
|
+ const urlParams = new URLSearchParams(window.location.search)
|
|
|
+ const code = urlParams.get('code')
|
|
|
+ const state = urlParams.get('state')
|
|
|
+
|
|
|
+ // 2. 如果有code参数,就跳转到目标Hash路径并携带参数
|
|
|
+ if (code && state) {
|
|
|
+ const targetUrl = `https://test.baoxianzhanggui.com/fragrance/#/?code=${code}&state=${
|
|
|
+ state || 'STATE'
|
|
|
+ }`
|
|
|
+ // 替换当前页面,避免浏览器返回按钮出现重复授权
|
|
|
+ window.location.replace(targetUrl)
|
|
|
+ }
|
|
|
+ if (query.code) this.onLogin(query.code)
|
|
|
|
|
|
// uni.setStorageSync('wx_copenid', 'o-HEJ6VP2YNi0HPeLaIHCQsQD69s')
|
|
|
// uni.setStorageSync('access-token', 'eyJhbGciOiJIUzUxMiJ9.eyJ0ZjoiOiJlNGNiNjY0ZS05Y2Q5LTRlOWItODU1Yy0zN2RlNjRiOGI3ZDIifQ.xj0ZBULLc7wYOaUgDQd_zbeynbJ8M3M-UQM6JPUKcV9rIWVlax8dJnU247om39nialcKnklKFZ8m8oerc-NY0A')
|
|
|
@@ -325,8 +338,8 @@ export default {
|
|
|
)
|
|
|
},
|
|
|
// 静默登录
|
|
|
- onLogin() {
|
|
|
- let wxCode = this.getUrlCode('code')
|
|
|
+ onLogin(wxCode) {
|
|
|
+ // let wxCode = this.getUrlCode('code')
|
|
|
let params = {
|
|
|
code: wxCode,
|
|
|
}
|