1
This commit is contained in:
@@ -40,7 +40,7 @@ func (u *UserLogin) WxLogin(ctx *gin.Context, code, phone string) (*model.User,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息,是否注册
|
// 获取用户信息,是否注册
|
||||||
userInfo, err := wechat.GetOauth2UserInfo(ctx, openObj.AccessToken, openObj.OpenID)
|
userInfo, err := api.WeixinMiniAPI.SNSGetUserInfo(openObj.AccessToken, openObj.OpenID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -57,10 +57,10 @@ func (u *UserLogin) WxLogin(ctx *gin.Context, code, phone string) (*model.User,
|
|||||||
DeletedAt: &utils.DefaultTimeValue,
|
DeletedAt: &utils.DefaultTimeValue,
|
||||||
UserID: utils.GetUUID(),
|
UserID: utils.GetUUID(),
|
||||||
Password: "",
|
Password: "",
|
||||||
Name: userInfo.Nickname,
|
Name: userInfo.NickName,
|
||||||
Mobile: phone,
|
Mobile: phone,
|
||||||
Email: "",
|
Email: "",
|
||||||
Avatar: userInfo.Headimgurl,
|
Avatar: userInfo.HeadImgURL,
|
||||||
Status: 1,
|
Status: 1,
|
||||||
Type: 1,
|
Type: 1,
|
||||||
Company: "",
|
Company: "",
|
||||||
@@ -72,8 +72,8 @@ func (u *UserLogin) WxLogin(ctx *gin.Context, code, phone string) (*model.User,
|
|||||||
LastLoginAt: &timeNow,
|
LastLoginAt: &timeNow,
|
||||||
LastLoginIP: ctx.ClientIP(),
|
LastLoginIP: ctx.ClientIP(),
|
||||||
LastLoginType: model.OrderOriginWxMini,
|
LastLoginType: model.OrderOriginWxMini,
|
||||||
OpenId: userInfo.Openid,
|
OpenId: userInfo.OpenID,
|
||||||
UnionId: userInfo.Unionid,
|
UnionId: userInfo.UnionID,
|
||||||
}
|
}
|
||||||
if err := dao.CreateUserWx(userBase); err != nil {
|
if err := dao.CreateUserWx(userBase); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -82,10 +82,10 @@ func (u *UserLogin) WxLogin(ctx *gin.Context, code, phone string) (*model.User,
|
|||||||
case 1:
|
case 1:
|
||||||
// 用户使用电话号码登录,未使用微信登录
|
// 用户使用电话号码登录,未使用微信登录
|
||||||
if users[0].OpenId == "" {
|
if users[0].OpenId == "" {
|
||||||
users[0].Name = userInfo.Nickname
|
users[0].Name = userInfo.NickName
|
||||||
users[0].Avatar = userInfo.Headimgurl
|
users[0].Avatar = userInfo.HeadImgURL
|
||||||
users[0].OpenId = userInfo.Openid
|
users[0].OpenId = userInfo.OpenID
|
||||||
users[0].UnionId = userInfo.Unionid
|
users[0].UnionId = userInfo.UnionID
|
||||||
}
|
}
|
||||||
// 用户存在,判断用户
|
// 用户存在,判断用户
|
||||||
users[0].UpdatedAt = &timeNow
|
users[0].UpdatedAt = &timeNow
|
||||||
|
|||||||
Reference in New Issue
Block a user