hotime/example/app/sms.go

31 lines
703 B
Go
Raw Normal View History

2022-04-20 10:36:05 +00:00
package app
import (
. "code.hoteas.com/golang/hotime"
2022-05-03 00:09:25 +00:00
"code.hoteas.com/golang/hotime/dri/ddsms"
2022-04-20 10:36:05 +00:00
)
var Sms = Ctr{
//只允许微信验证过的或者登录成功的发送短信
2022-05-03 00:09:25 +00:00
"send": func(that *Context) {
2022-05-03 01:41:18 +00:00
if that.Session("wechat_id").Data == nil && that.Session("user_id").Data == nil {
2022-05-03 00:09:25 +00:00
that.Display(2, "没有登录不可发送短信")
return
}
phone := that.Req.FormValue("phone")
if len(phone) < 11 {
that.Display(3, "手机号格式错误")
return
}
code := getCode()
that.Session("phone", phone)
that.Session("code", code)
ddsms.DDY.SendYZM(phone, that.Config.GetString("smsLogin"), map[string]string{"code": code})
that.Display(0, "发送成功")
},
2022-04-20 10:36:05 +00:00
}