From 2c4c0ea4f03d21d8a36454d7e828dd4f744ad763 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Fri, 25 Aug 2023 13:58:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/passport/wechatMPLogin.vue | 42 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pages/passport/wechatMPLogin.vue b/pages/passport/wechatMPLogin.vue index 20a0f1b..f5b5b06 100644 --- a/pages/passport/wechatMPLogin.vue +++ b/pages/passport/wechatMPLogin.vue @@ -20,7 +20,7 @@ 您的公开信息(昵称、头像) -
暂不登录
@@ -54,6 +54,7 @@ code: "", //微信昵称 nickName: "", + logingFlag: false, //微信头像 image: "", }; @@ -66,7 +67,19 @@ withShareTicket: true }); - let that = this; + + //获取code + uni.login({ + success: (res) => { + if(res.errMsg === "login:ok") { + this.code = res.code + } else { + uni.showToast({ + title: "系统异常,请联系管理员!" + }) + } + }, + }); }, methods: { @@ -93,27 +106,16 @@ //获取用户信息 getUserProfile(e) { - let that = this; - //获取code - uni.login({ - success: (res) => { - if(res.errMsg === "login:ok") { - that.code = res.code - } else { - uni.showToast({ - title: "系统异常,请联系管理员!" - }) - } - }, - }); + this.logingFlag = true; if (this.code) { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 uni.getUserProfile({ desc: "用于完善会员资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { - that.nickName = res.userInfo.nickName; - that.image = res.userInfo.avatarUrl; + console.log("success", res) + this.nickName = res.userInfo.nickName; + this.image = res.userInfo.avatarUrl; /** * 根据公有的配置设置登录方式 @@ -152,13 +154,15 @@ }); }); }); + }, fail: (res) => { - + console.log("fail", res) }, }); - } + this.logingFlag = false; + } }, //获取手机号授权