|
@@ -1,57 +0,0 @@
|
|
|
-//人员手机号绑定、更换
|
|
|
-package phone
|
|
|
-
|
|
|
-import (
|
|
|
- . "api"
|
|
|
- . "ent/entity"
|
|
|
- . "ent/util"
|
|
|
- "qfw/util/jy"
|
|
|
-
|
|
|
- "github.com/go-xweb/xweb"
|
|
|
-)
|
|
|
-
|
|
|
-type Action struct {
|
|
|
- *xweb.Action
|
|
|
- bind xweb.Mapper `xweb:"/phone/bind"` //手机号绑定
|
|
|
- sendIdentCode xweb.Mapper `xweb:"/phone/sendidentcode"` //发短信
|
|
|
-}
|
|
|
-
|
|
|
-//手机号绑定
|
|
|
-func (a *Action) Bind() {
|
|
|
- if !R.CheckReqParam(a.ResponseWriter, a.Request, "code") {
|
|
|
- return
|
|
|
- }
|
|
|
- status := 0
|
|
|
- phone := jy.CheckPhoneIdent(a.Session(), a.GetString("code"))
|
|
|
- if phone == "" { //验证码不正确
|
|
|
- status = -1
|
|
|
- } else {
|
|
|
- userId, _ := a.GetSession("userId").(string)
|
|
|
- if bondPhone, _ := VarCurrentUser.Phone(userId); bondPhone != "" {
|
|
|
- R.NoPermissionReq(a.ResponseWriter, a.Request, "该用户已经绑定过手机号")
|
|
|
- return
|
|
|
- }
|
|
|
- //查询是否绑定过微信号
|
|
|
- if bindOk, _ := VarCurrentUser.BindPhone(userId, phone); bindOk {
|
|
|
- //go jy.AutoMerge(MQFW, a.Session())
|
|
|
- status = 1 //绑定成功
|
|
|
- } else {
|
|
|
- status = 0 //已经绑定过
|
|
|
- }
|
|
|
- }
|
|
|
- a.ServeJson(Result{Data: M{"status": status, "phone": phone}})
|
|
|
-}
|
|
|
-
|
|
|
-//发短信
|
|
|
-func (a *Action) SendIdentCode() {
|
|
|
- if !R.CheckReqParam(a.ResponseWriter, a.Request, "token") {
|
|
|
- return
|
|
|
- }
|
|
|
- status := 0
|
|
|
- token := a.GetString("token")
|
|
|
- phone := jy.CheckSendMsg(token)
|
|
|
- if PhoneReg.MatchString(phone) && jy.SendPhoneIdentCode(phone, a.Session()) {
|
|
|
- status = 1
|
|
|
- }
|
|
|
- a.ServeJson(Result{Data: M{"status": status}})
|
|
|
-}
|