fix: 微信静默授权

This commit is contained in:
zhangds 2024-03-13 13:45:54 +08:00
parent 9ce586c4dc
commit 68621d6120
2 changed files with 25 additions and 18 deletions

View File

@ -100,7 +100,8 @@
popShow: false, popShow: false,
popTitle: '', popTitle: '',
popText: '', popText: '',
popStatus: 1 /*1 成功 2提示 3失败 */ popStatus: 1, /*1 成功 2提示 3失败 */
openid: localStorage.setItem('openid', openid)
}; };
}, },
@ -246,6 +247,18 @@
}, 300) }, 300)
}, },
// 静默授权
wxgzAuth(is_have_webview_voucher) {
/* 公众号打开 */
if (is_have_webview_voucher && !this.openid) {
const key = localStorage.getItem('key');
const linkId = localStorage.getItem('linkId');
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/${linkId}/${key}`;
return
}
},
//获取白名单验证码 //获取白名单验证码
getcode() { getcode() {
let self = this; let self = this;
@ -299,6 +312,8 @@
}, 2000); }, 2000);
if (res.code == 200) { if (res.code == 200) {
this.wxgzAuth(res.data.is_have_webview_voucher);
localStorage.setItem('key', self.key); localStorage.setItem('key', self.key);
localStorage.setItem('token', res.data.token); localStorage.setItem('token', res.data.token);
this.openDialog('正在加载商品...'); this.openDialog('正在加载商品...');

View File

@ -191,14 +191,6 @@
} }
}, },
receiveFn() { receiveFn() {
/* 公众号打开 */
if (this.goodInfo.entity.channel == 2 && this.goodInfo.entity.is_webview == 1 && !this.openId) {
const key = localStorage.getItem('key');
const linkId = localStorage.getItem('linkId');
location.href = `https://openapi.1688sup.com/wechat/oauth?jump=${location.origin}/${linkId}/${key}`;
return;
}
if (this.loading) return; if (this.loading) return;
this.loading = true; this.loading = true;
let self = this; let self = this;