|
@@ -29,7 +29,7 @@ func (this *WechatCommonController) WechatLogin() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
- code:=this.GetString("Code")
|
|
|
+ code := this.GetString("Code")
|
|
|
if code == "" {
|
|
|
br.Msg = "参数错误"
|
|
|
br.ErrMsg = "Code 为空"
|
|
@@ -73,6 +73,28 @@ func (this *WechatCommonController) WechatLogin() {
|
|
|
return
|
|
|
}
|
|
|
userId = int(newId)
|
|
|
+ //新增用户记录
|
|
|
+ {
|
|
|
+ userRecord := new(models.UserRecord)
|
|
|
+ userRecord.UserId = int(newId)
|
|
|
+ userRecord.OpenId = user.OpenId
|
|
|
+ userRecord.UnionId = user.UnionId
|
|
|
+ userRecord.CompanyId = user.CompanyId
|
|
|
+ userRecord.NickName = user.NickName
|
|
|
+ userRecord.RealName = user.RealName
|
|
|
+ userRecord.Mobile = user.Mobile
|
|
|
+ userRecord.BindAccount = user.Mobile
|
|
|
+ userRecord.Email = user.Email
|
|
|
+ userRecord.Sex = user.Sex
|
|
|
+ userRecord.Province = user.Province
|
|
|
+ userRecord.City = user.City
|
|
|
+ userRecord.Country = user.Country
|
|
|
+ userRecord.Headimgurl = user.Headimgurl
|
|
|
+ userRecord.CreateTime = time.Now()
|
|
|
+ userRecord.CreatePlatform = 4
|
|
|
+ userRecord.SessionKey = user.SessionKey
|
|
|
+ go models.AddUserRecord(userRecord)
|
|
|
+ }
|
|
|
} else {
|
|
|
firstLogin = wxUser.FirstLogin
|
|
|
userId = wxUser.UserId
|
|
@@ -228,7 +250,20 @@ func (this *WechatController) GetUserInfo() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //更新用户记录信息
|
|
|
+ {
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+ updateParams["NickName"]=userInfo.Nickname
|
|
|
+ updateParams["Province"]=userInfo.Province
|
|
|
+ updateParams["City"]=userInfo.City
|
|
|
+ updateParams["Country"]=userInfo.Country
|
|
|
+ updateParams["Headimgurl"]=userInfo.Avatar
|
|
|
+ updateParams["Sex"]=userInfo.Gender
|
|
|
+ updateParams["Headimgurl"]=userInfo.Avatar
|
|
|
+ updateParams["UnionId"]=userInfo.UnionID
|
|
|
+ whereParam := map[string]interface{}{"user_id": user.UserId, "create_platform": 4}
|
|
|
+ go models.UpdateByExpr(models.UserRecord{}, whereParam, updateParams)
|
|
|
+ }
|
|
|
var token string
|
|
|
tokenItem, err := models.GetTokenByUid(userId)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -318,6 +353,16 @@ func (this *WechatController) GetPhoneNumber() {
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ //更新用户记录信息
|
|
|
+ {
|
|
|
+ updateParams := make(map[string]interface{})
|
|
|
+ updateParams["Mobile"]=wxMobile.PhoneNumber
|
|
|
+ updateParams["BindAccount"]=wxMobile.PhoneNumber
|
|
|
+ whereParam := map[string]interface{}{"user_id": user.UserId, "create_platform": 4}
|
|
|
+ go models.UpdateByExpr(models.UserRecord{}, whereParam, updateParams)
|
|
|
+ }
|
|
|
+
|
|
|
resp := new(models.WxGetPhoneNumberResp)
|
|
|
resp.PhoneNumber = wxMobile.PhoneNumber
|
|
|
resp.PurePhoneNumber = wxMobile.PurePhoneNumber
|
|
@@ -328,7 +373,6 @@ func (this *WechatController) GetPhoneNumber() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// @Title 获取短信验证码
|
|
|
// @Description 获取短信验证码接口
|
|
|
// @Param Mobile query string true "手机号码"
|
|
@@ -377,7 +421,6 @@ func (this *WechatController) GetSmsCode() {
|
|
|
br.Success = true
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// @Title 获取邮件验证码
|
|
|
// @Description 获取邮件验证码接口
|
|
|
// @Param Email query string true "邮箱"
|
|
@@ -443,4 +486,4 @@ func (this *WechatController) GetEmailCode() {
|
|
|
// fmt.Println(userInfo)
|
|
|
// fmt.Println(err)
|
|
|
// fmt.Println("end")
|
|
|
-//}
|
|
|
+//}
|