提交 f0de2a63 编写于 作者: C chenruilong

fix: 修复 web微信登录回调地址不正确

上级 2922ab59
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
"id": "weixin", "id": "weixin",
"text": "微信登录", "text": "微信登录",
"logo": "/uni_modules/uni-id-pages/static/login/uni-fab-login/weixin.png", "logo": "/uni_modules/uni-id-pages/static/login/uni-fab-login/weixin.png",
}, },
// #ifndef MP-WEIXIN // #ifndef MP-WEIXIN
{ {
"id": "apple", "id": "apple",
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
"id": "sinaweibo", "id": "sinaweibo",
"text": "新浪微博", //暂未提供该登录方式的接口示例 "text": "新浪微博", //暂未提供该登录方式的接口示例
"logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/sinaweibo.png", "logo": "/uni_modules/uni-id-pages/static/app-plus/uni-fab-login/sinaweibo.png",
} }
// #endif // #endif
], ],
univerifyStyle: { //一键登录弹出窗的样式配置参数 univerifyStyle: { //一键登录弹出窗的样式配置参数
...@@ -201,8 +201,8 @@ ...@@ -201,8 +201,8 @@
} }
return '/' + pages[pages.length - n].route return '/' + pages[pages.length - n].route
}, },
toPage(path,index = 0) { toPage(path,index = 0) {
let type = ['navigateTo','redirectTo'][index] let type = ['navigateTo','redirectTo'][index]
//console.log('比较', this.getRoute(1),this.getRoute(2), path) //console.log('比较', this.getRoute(1),this.getRoute(2), path)
if (this.getRoute(1) == path.split('?')[0] && this.getRoute(1) == if (this.getRoute(1) == path.split('?')[0] && this.getRoute(1) ==
'/uni_modules/uni-id-pages/pages/login/login-withoutpwd') { '/uni_modules/uni-id-pages/pages/login/login-withoutpwd') {
...@@ -294,10 +294,26 @@ ...@@ -294,10 +294,26 @@
// #ifdef H5 // #ifdef H5
if(type == 'weixin'){ if(type == 'weixin'){
// console.log('开始微信网页登录'); // console.log('开始微信网页登录');
let redirectUrl = location.protocol +'//'+ // let redirectUrl = location.protocol +'//'+
document.domain + // document.domain +
(window.location.href.includes('#')?'/#':'') + // (window.location.href.includes('#')?'/#':'') +
'/uni_modules/uni-id-pages/pages/login/login-withoutpwd?is_weixin_redirect=true&type=weixin' // '/uni_modules/uni-id-pages/pages/login/login-withoutpwd?is_weixin_redirect=true&type=weixin'
// #ifdef VUE2
const baseUrl = process.env.BASE_URL
// #endif
// #ifdef VUE3
const baseUrl = import.meta.env.BASE_URL
// #endif
let redirectUrl = location.protocol +
'//' +
location.host +
(baseUrl ? '/': '') +
baseUrl.replace(/^\/|\/$/, '') +
(window.location.href.includes('#')?'/#':'') +
'/uni_modules/uni-id-pages/pages/login/login-withoutpwd?is_weixin_redirect=true&type=weixin'
// console.log('redirectUrl----',redirectUrl);
let ua = window.navigator.userAgent.toLowerCase(); let ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger'){ if (ua.match(/MicroMessenger/i) == 'micromessenger'){
// console.log('在微信公众号内'); // console.log('在微信公众号内');
...@@ -327,20 +343,20 @@ ...@@ -327,20 +343,20 @@
let onButtonsClickFn = async res => { let onButtonsClickFn = async res => {
console.log('点击了第三方登录,provider:', res, res.provider, this.univerifyStyle.buttons.list); console.log('点击了第三方登录,provider:', res, res.provider, this.univerifyStyle.buttons.list);
clickAnotherButtons = true clickAnotherButtons = true
let checkBoxState = await uni.getCheckBoxState(); let checkBoxState = await uni.getCheckBoxState();
// 同步一键登录弹出层隐私协议框是否打勾 // 同步一键登录弹出层隐私协议框是否打勾
// #ifdef VUE2 // #ifdef VUE2
this.agree = checkBoxState[1].state this.agree = checkBoxState[1].state
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
this.agree = checkBoxState.state this.agree = checkBoxState.state
// #endif // #endif
let { let {
path path
} = this.univerifyStyle.buttons.list[res.index] } = this.univerifyStyle.buttons.list[res.index]
if (path) { if (path) {
if( this.getRoute(1).includes('login-withoutpwd') && path.includes('login-withoutpwd') ){ if( this.getRoute(1).includes('login-withoutpwd') && path.includes('login-withoutpwd') ){
this.getParentComponent().showCurrentWebview() this.getParentComponent().showCurrentWebview()
} }
this.toPage(path,1) this.toPage(path,1)
closeUniverify() closeUniverify()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册