|
@@ -6,6 +6,7 @@ import (
|
|
|
userLogic "hongze/hongze_yb/logic/user"
|
|
|
"hongze/hongze_yb/models/request/user"
|
|
|
userResp "hongze/hongze_yb/models/response/user"
|
|
|
+ "hongze/hongze_yb/models/tables/wx_user"
|
|
|
userService "hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"strings"
|
|
@@ -35,6 +36,12 @@ func Login(c *gin.Context) {
|
|
|
response.Fail("参数异常", c)
|
|
|
return
|
|
|
}
|
|
|
+ if req.LoginType != 1 && req.LoginType != 2 {
|
|
|
+ response.Fail("无效的登录方式", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var bindAccount string
|
|
|
if req.LoginType == 1 {
|
|
|
//手机登录
|
|
|
if req.Mobile == "" {
|
|
@@ -42,7 +49,9 @@ func Login(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
req.Mobile = strings.Trim(req.Mobile, " ")
|
|
|
- } else if req.LoginType == 2 {
|
|
|
+ bindAccount = req.Mobile
|
|
|
+ }
|
|
|
+ if req.LoginType == 2 {
|
|
|
//邮箱登录
|
|
|
if req.Email == "" {
|
|
|
response.Fail("邮箱不能为空,请输入邮箱", c)
|
|
@@ -52,10 +61,20 @@ func Login(c *gin.Context) {
|
|
|
response.Fail("邮箱格式错误,请重新输入", c)
|
|
|
return
|
|
|
}
|
|
|
- } else {
|
|
|
- response.Fail("无效的登录方式", c)
|
|
|
+ bindAccount = req.Email
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验账号是否已有绑定微信
|
|
|
+ bindUser, e := wx_user.GetWxUserBindExist(bindAccount, openId)
|
|
|
+ if e != nil && e != utils.ErrNoRow {
|
|
|
+ response.FailMsg("登录失败", "获取账号是否已绑定微信失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if bindUser != nil && bindUser.UserID > 0 {
|
|
|
+ response.Fail("登录失败, 该账号已绑定其他微信", c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
token, newUserInfo, err, errMsg := userService.BindWxUser(openId, req.Mobile, req.Email, req.VerifyCode, req.LoginType, req.AreaNum, 1)
|
|
|
if err != nil {
|
|
|
if errMsg == "" {
|
|
@@ -317,4 +336,4 @@ func GetTopTab(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
response.OkData("获取成功", tabBarList, c)
|
|
|
-}
|
|
|
+}
|