Browse Source

push orign master

master
黄梓健 5 years ago
parent
commit
f96d28fc5d
  1. 18
      controllers/client/login.go
  2. 4
      controllers/client/sign.go

18
controllers/client/login.go

@ -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

4
controllers/client/sign.go

@ -23,7 +23,7 @@ func (t *SignCtl) Sign() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetInt64("customer_id")
kind, _ := t.GetInt("kind")
_type, _ := t.GetInt("_type")
//根据activity_id查找主活动的信息
activity := new(models.Activity)
@ -74,7 +74,7 @@ func (t *SignCtl) Sign() {
}
signHistory = new(models.SignHistory)
signHistory.Type = kind
signHistory.Type = _type
signHistory.UserId = uid
signHistory.RehearsalId = activity.RehearsalId
signHistory.ActivityId = activityId

Loading…
Cancel
Save