From 0b02bf783888ecfedd16228fa8879239557769b0 Mon Sep 17 00:00:00 2001 From: yige Date: Wed, 22 Jul 2020 23:53:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BE=AE=E4=BF=A1=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/post/_id.vue | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 0b93f14..379ecae 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -678,26 +678,33 @@ export default { this.useWeixinLogin = true this.commentLoading = true try { - const { data } = await this.$axios.get('https://weixin.openapi.site/img?appid=wx2d1d6aa2f86768d7&redirect_uri=https://wyr.me') - - if (data.status === 1) { - const uuid = data.result.wxUUID - this.weixinLoginQrcode = data.result.imgData - this.getCode(uuid) - this.commentLoading = false - } else { + if (navigator.userAgent.toLowerCase().includes('micromessenger')) { // 如果在微信中打开 this.commentLoading = false this.currentLoginType = null - this.$toasted.show('获取微信登录所需参数错误,请重试或换用其它登录方式。', { - position: 'top-center', - duration: 5000 - }) + this.useWeixinLogin = false + window.location.href = `https://open.weixin.qq.com/connect/authorize?appid=wx9d5e677f533d1e84&redirect_uri=${encodeURIComponent('https://tool.sercretcore.com/auth.php')}&response_type=code&scope=snsapi_userinfo&state=blog-${this.postID}#wechat_redirect` + } else { + const { data } = await this.$axios.get('https://weixin.openapi.site/img?appid=wx2d1d6aa2f86768d7&redirect_uri=https://wyr.me') + + if (data.status === 1) { + const uuid = data.result.wxUUID + this.weixinLoginQrcode = data.result.imgData + this.getCode(uuid) + this.commentLoading = false + } else { + this.commentLoading = false + this.currentLoginType = null + this.$toasted.show('获取微信登录所需参数错误,请重试或换用其它登录方式。', { + position: 'top-center', + duration: 5000 + }) + } } } catch (err) { this.commentLoading = false this.currentLoginType = null this.useWeixinLogin = false - this.$toasted.show('暂时无法使用Github登录,请重试或换用其它登录方式。', { + this.$toasted.show('暂时无法使用微信登录,请重试或换用其它登录方式。', { position: 'top-center', duration: 5000 })