|
|
@ -61,7 +61,7 @@ func (t *UserCtl) EntryLogin() { |
|
|
|
func (t *UserCtl) WxLogin() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
wxcode := t.MustGet("code") |
|
|
|
kind, _ := t.Get("type") // mini 小程序登陆 base 静默授权 userinfo 或者为空 非静默授权
|
|
|
|
_type, _ := t.Get("type") // mini 小程序登陆 base 静默授权 userinfo 或者为空 非静默授权
|
|
|
|
|
|
|
|
activity, exist, err := activity_service.GetActivityById(activityId) |
|
|
|
t.CheckErr(err) |
|
|
@ -85,16 +85,16 @@ func (t *UserCtl) WxLogin() { |
|
|
|
user.ActivityId = activityId |
|
|
|
user.AreaId = area.Id |
|
|
|
user.AreaName = area.Name |
|
|
|
if kind == "mini" { |
|
|
|
if _type == "mini" { |
|
|
|
session, err := wechat.MiniAuth(wxcode) |
|
|
|
t.CheckErr(err) |
|
|
|
user.Openid = session.OpenId |
|
|
|
|
|
|
|
} else if kind == "base" { |
|
|
|
} else if _type == "base" { |
|
|
|
token, err := wechat.GetToken(wxcode) |
|
|
|
t.CheckErr(err) |
|
|
|
user.Openid = token.OpenId |
|
|
|
} else if kind == "" || kind == "userinfo" { |
|
|
|
} else if _type == "" || _type == "userinfo" { |
|
|
|
//token, err := wx.GetToken(wxcode)
|
|
|
|
token, err := wechat.GetToken(wxcode) |
|
|
|
t.CheckErr(err) |
|
|
@ -206,17 +206,21 @@ type UserAuthCtl struct { |
|
|
|
func (t *UserAuthCtl) SaveUserInfo() { |
|
|
|
uid := t.MustGetUID() |
|
|
|
|
|
|
|
info := mpoauth2.UserInfo{} |
|
|
|
info := mpoauth2.SessionInfo{} |
|
|
|
t.RequestToStruct(&info) |
|
|
|
if info.Nickname == "" && info.AvatarUrl == "" { |
|
|
|
t.ERROR("参数错误", code.MSG_ERR_Param) |
|
|
|
return |
|
|
|
} |
|
|
|
user := models.User{} |
|
|
|
user.Nickname = info.Nickname |
|
|
|
user.Gender = func() string { |
|
|
|
if info.Sex == 1 { |
|
|
|
if info.Gender == 1 { |
|
|
|
return "男" |
|
|
|
} |
|
|
|
return "女" |
|
|
|
}() |
|
|
|
user.Avatar = info.HeadImageURL |
|
|
|
user.Avatar = info.AvatarUrl |
|
|
|
user.Unionid = info.UnionId |
|
|
|
user.City = info.City |
|
|
|
user.Province = info.Province |
|
|
|