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

3
.gitignore vendored
View File

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

View File

@ -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();
},
});
}
},
};
</script>