|
@@ -34,6 +34,7 @@ func (this *WechatCommonController) WechatLoginByxzs() {
|
|
|
br.ErrMsg = "Code 为空"
|
|
|
return
|
|
|
}
|
|
|
+ var token string
|
|
|
item, err := services.WxGetUserOpenIdByCodeXzs(code)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取用户信息失败"
|
|
@@ -108,7 +109,7 @@ func (this *WechatCommonController) WechatLoginByxzs() {
|
|
|
}
|
|
|
timeUnix := time.Now().Unix()
|
|
|
timeUnixStr := strconv.FormatInt(timeUnix, 10)
|
|
|
- token := utils.MD5(unionId) + utils.MD5(timeUnixStr)
|
|
|
+
|
|
|
user, err := models.GetWxUserItemByUserUnionId(unionId)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取用户信息失败"
|
|
@@ -116,13 +117,14 @@ func (this *WechatCommonController) WechatLoginByxzs() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- totalToken, err := models.GetXzsSessionCountByToken(token)
|
|
|
- if err != nil {
|
|
|
+ totalItem, err := models.GetTokenByOpenId(openId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取用户信息失败"
|
|
|
br.ErrMsg = "查询数量失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- if totalToken == 0 {
|
|
|
+ if totalItem == nil {
|
|
|
+ token := utils.MD5(unionId) + utils.MD5(timeUnixStr)
|
|
|
itemsSession := new(models.CygxXzsSession)
|
|
|
itemsSession.UnionId = unionId
|
|
|
itemsSession.OpenId = openId
|
|
@@ -139,6 +141,8 @@ func (this *WechatCommonController) WechatLoginByxzs() {
|
|
|
br.ErrMsg = "添加Token失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ } else {
|
|
|
+ token = totalItem.AccessToken
|
|
|
}
|
|
|
|
|
|
if user == nil {
|
|
@@ -256,10 +260,7 @@ func (this *WechatController) UserInfo() {
|
|
|
resp.RealName = user.RealName
|
|
|
resp.HasPermission = 2
|
|
|
}
|
|
|
- resp.Headimgurl = user.HeadimgurlRecord
|
|
|
- }
|
|
|
- if resp.Headimgurl == "" {
|
|
|
- resp.Headimgurl = utils.HeadimgurlDefault
|
|
|
+ resp.Headimgurl = user.Headimgurl
|
|
|
}
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|