update: gitignore添加history忽略,一键登录成功后处理用户信息数据传递并关闭弹窗

This commit is contained in:
mixtan 2025-05-07 11:37:15 +08:00
parent 5a6938a857
commit e53abdda81
2 changed files with 37 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
unpackage/ unpackage/
.hbuilderx .hbuilderx
.history

View File

@ -54,6 +54,7 @@ export default {
"getPlantformInfo", "getPlantformInfo",
"forceUserInfo", "forceUserInfo",
"getUserInfo", "getUserInfo",
"reloadUserResource",
]), ]),
open() { open() {
this.$refs["popup"].open("bottom"); this.$refs["popup"].open("bottom");
@ -142,16 +143,15 @@ export default {
// //
async doWxUserRegisterAndLogin(phoneNumber) { async doWxUserRegisterAndLogin(phoneNumber) {
this.close()
const openId = await this.getWxOpenId() const openId = await this.getWxOpenId()
const user = await this.getUserprofile() const {userInfo:{ nickName, avatarUrl }} = await this.getUserprofile()
const that = this const that = this
this.$.request({ this.$.request({
url: this.Config.URL.wx.doWxUserRegisterAndLogin, url: this.Config.URL.wx.doWxUserRegisterAndLogin,
data: { data: {
nickName: user.userInfo.nickName, nickName,
avatarUrl: user.userInfo.avatarUrl, avatarUrl,
phoneNumber, phoneNumber,
openId openId
}, },
@ -160,25 +160,43 @@ export default {
'Content-Type': 'application/json;charset=utf-8' 'Content-Type': 'application/json;charset=utf-8'
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (data, status, msg, code) {
if (res.status != 200) { if (status != 200) {
that.$.confirm(that.__(res.msg || '登录失败,请重试!')); that.$.confirm(that.__(msg || '登录失败,请重试!'));
return 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();
},
});
}
}, },
}; };
</script> </script>