From f96d28fc5dfbe85f329ab2135b283c96e568b1f0 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Wed, 1 Apr 2020 13:17:37 +0800 Subject: [PATCH] push orign master --- controllers/client/login.go | 18 +++++++++++------- controllers/client/sign.go | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/controllers/client/login.go b/controllers/client/login.go index 5bbdbc4..62dcae9 100644 --- a/controllers/client/login.go +++ b/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 diff --git a/controllers/client/sign.go b/controllers/client/sign.go index 54225a3..07cb61d 100644 --- a/controllers/client/sign.go +++ b/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