From e53abdda81ac7557ed999c57deffad45830b534a Mon Sep 17 00:00:00 2001 From: mixtan <424491071@qq.com> Date: Wed, 7 May 2025 11:37:15 +0800 Subject: [PATCH] =?UTF-8?q?update:=20gitignore=E6=B7=BB=E5=8A=A0history?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=EF=BC=8C=E4=B8=80=E9=94=AE=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E5=A4=84=E7=90=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=95=B0=E6=8D=AE=E4=BC=A0=E9=80=92=E5=B9=B6?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- components/loginPopup.vue | 52 ++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index d94a68a..7b3fd3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ unpackage/ -.hbuilderx \ No newline at end of file +.hbuilderx +.history \ No newline at end of file diff --git a/components/loginPopup.vue b/components/loginPopup.vue index adab399..528ea0f 100644 --- a/components/loginPopup.vue +++ b/components/loginPopup.vue @@ -54,6 +54,7 @@ export default { "getPlantformInfo", "forceUserInfo", "getUserInfo", + "reloadUserResource", ]), open() { this.$refs["popup"].open("bottom"); @@ -142,16 +143,15 @@ export default { // 一键登录注册 async doWxUserRegisterAndLogin(phoneNumber) { - this.close() const openId = await this.getWxOpenId() - const user = await this.getUserprofile() + const {userInfo:{ nickName, avatarUrl }} = await this.getUserprofile() const that = this this.$.request({ url: this.Config.URL.wx.doWxUserRegisterAndLogin, data: { - nickName: user.userInfo.nickName, - avatarUrl: user.userInfo.avatarUrl, + nickName, + avatarUrl, phoneNumber, openId }, @@ -160,25 +160,43 @@ export default { 'Content-Type': 'application/json;charset=utf-8' }, dataType: "json", - success: function (res) { - if (res.status != 200) { - that.$.confirm(that.__(res.msg || '登录失败,请重试!')); + success: function (data, status, msg, code) { + if (status != 200) { + that.$.confirm(that.__(msg || '登录失败,请重试!')); return } + that.loginSuccess(data) }, }); - // that.$.request({ - // url: that.Config.URL.user.overview, - // success: function (data, status, msg, code) { - // userInfo = Object.assign(userInfo, data.member_info); - - // that.login(userInfo); - - // that.close(); - // }, - // }); }, + + // 成功登录回调 + loginSuccess(data) { + const that = this + + that.$.setStorageSync("uid", data.user_id); + that.$.setStorageSync("ukey", data.key); + + // #ifdef H5 + $cookies.set("uid", data.user_id); + $cookies.set("ukey", data.key); + // #endif + + that.$.request({ + url: that.Config.URL.user.overview, + success: function (data, status, msg, code) { + that.login(data); + that.reloadUserResource(function (user_info) { + that.setData({ + UserInfo: user_info, + }); + }); + + that.close(); + }, + }); + } }, };