diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 400c1fa..48051f0 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -288,6 +288,41 @@ func Register(c *gin.Context) { commReq(c, req) } +// WechatRegister +// @Summary 注册 +// @Tags 登录注册 +// @Description 注册 +// @Accept json +// @Produce json +// @Param req body md.RegisterReq true "注册参数" +// @Success 200 {object} md.LoginResponse "登录成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/wechatRegister [post] +func WechatRegister(c *gin.Context) { + var req md.RegisterReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = svc.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + data := svc.AliyunSmsBase(c, "") + //校验短信 + err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) + if cfg.Prd { + if err != nil { + e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) + return + } + } + if req.WechatCode == "" { + e.OutErr(c, 400, "获取微信信息失败") + return + } + commReq(c, req) +} + // Login 登陆 // @Summary 登陆 // @Tags 登录注册 diff --git a/app/router/router.go b/app/router/router.go index 3f7ba91..e4f1980 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -75,6 +75,7 @@ func route(r *gin.RouterGroup) { r.POST("/smsSend", hdl.SmsSend) //发送短信 r.POST("/fastLogin", hdl.FastLogin) //一键登录 r.POST("/wechatLogin", hdl.WechatLogin) //微信登录 + r.POST("/wechatRegister", hdl.WechatRegister) //注册 r.POST("/register", hdl.Register) //注册 r.POST("/login", hdl.Login) //登录 r.POST("/findPassword", hdl.FindPassword) //找回密码