|
@@ -4,9 +4,12 @@ import (
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"hongze/hongze_yb/controller/response"
|
|
|
response2 "hongze/hongze_yb/models/response"
|
|
|
+ userResp "hongze/hongze_yb/models/response/user"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
+ userService "hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/services/wechat"
|
|
|
"hongze/hongze_yb/services/wx_app"
|
|
|
+ "strconv"
|
|
|
)
|
|
|
|
|
|
func GetQrCode(c *gin.Context) {
|
|
@@ -70,6 +73,7 @@ func Login(c *gin.Context) {
|
|
|
type EncryptReq struct {
|
|
|
EncryptedData string
|
|
|
Iv string
|
|
|
+ IsBind bool `json:"isBind" description:"是否需要去授权绑定"`
|
|
|
}
|
|
|
|
|
|
// GetEncryptInfo 消息解密
|
|
@@ -108,5 +112,29 @@ func GetEncryptInfo(c *gin.Context) {
|
|
|
response.Fail("获取失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- response.OkData("获取成功", decryptData, c)
|
|
|
+
|
|
|
+ if !req.IsBind {
|
|
|
+ response.OkData("获取成功", decryptData, c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果需要静默授权绑定,那么就去走静默绑定手机号流程
|
|
|
+ openId := userInfo.OpenID
|
|
|
+ //国际区号
|
|
|
+ countryCode, _ := strconv.Atoi(decryptData.CountryCode)
|
|
|
+ token, newUserInfo, err, errMsg := userService.BindWxUser(openId, decryptData.PurePhoneNumber, "", "", 3, countryCode, 1)
|
|
|
+ if err != nil {
|
|
|
+ if errMsg == "" {
|
|
|
+ errMsg = "登录失败"
|
|
|
+ }
|
|
|
+ response.Fail(errMsg, c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ response.OkData("登录成功", userResp.LoginResp{
|
|
|
+ UserID: int(newUserInfo.UserID),
|
|
|
+ Token: token,
|
|
|
+ Email: newUserInfo.Email,
|
|
|
+ Mobile: newUserInfo.Mobile,
|
|
|
+ }, c)
|
|
|
}
|