系统优化
This commit is contained in:
+2
-1
@@ -25,12 +25,13 @@ var h5Program *officialaccount.OfficialAccount
|
||||
func InitApp(app Application) {
|
||||
weixin = wechat.NewWechat()
|
||||
memory := cache.NewMemory()
|
||||
memoryMini := cache.NewMemory()
|
||||
cfg := &config.Config{
|
||||
AppID: app.Config.GetString("wechatMiniAppID"),
|
||||
AppSecret: app.Config.GetString("wechatMiniAppSecret"),
|
||||
//Token: "xxx",
|
||||
//EncodingAESKey: "xxxx",
|
||||
Cache: memory,
|
||||
Cache: memoryMini,
|
||||
}
|
||||
h5cfg := &h5config.Config{
|
||||
AppID: app.Config.GetString("wechatAppID"),
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
)
|
||||
|
||||
var Sms = Ctr{
|
||||
//只允许微信验证过的或者登录成功的发送短信
|
||||
//"send": func(this *Context) {
|
||||
//
|
||||
// if len(this.Req.FormValue("token")) != 32 {
|
||||
// this.Display(2, "没有授权")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// phone := this.Req.FormValue("phone")
|
||||
// if len(phone) < 11 {
|
||||
// this.Display(3, "手机号格式错误")
|
||||
// return
|
||||
// }
|
||||
// code := getCode()
|
||||
// this.Session("phone", phone)
|
||||
// this.Session("code", code)
|
||||
//
|
||||
// ddsms.DDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
|
||||
//
|
||||
// this.Display(0, "发送成功")
|
||||
//},
|
||||
}
|
||||
@@ -9,23 +9,24 @@ import (
|
||||
var Wechat = Ctr{
|
||||
"login": func(that *Context) {
|
||||
|
||||
retoken := that.Req.FormValue("retoken")
|
||||
sessionKey := that.Req.FormValue("sessionkey")
|
||||
encryptedData := that.Req.FormValue("encryptedData")
|
||||
iv := that.Req.FormValue("iv")
|
||||
|
||||
if retoken == "" || encryptedData == "" || iv == "" {
|
||||
if sessionKey == "" || encryptedData == "" || iv == "" {
|
||||
that.Display(3, "参数不足")
|
||||
return
|
||||
}
|
||||
|
||||
eny := miniProgram.GetEncryptor()
|
||||
re, e := eny.Decrypt(retoken, encryptedData, iv)
|
||||
re, e := eny.Decrypt(sessionKey, encryptedData, iv)
|
||||
|
||||
if e != nil {
|
||||
that.Display(4, e)
|
||||
return
|
||||
}
|
||||
that.Display(0, re.PhoneNumber)
|
||||
|
||||
},
|
||||
"code": func(that *Context) {
|
||||
code := that.Req.FormValue("code")
|
||||
@@ -42,10 +43,10 @@ var Wechat = Ctr{
|
||||
return
|
||||
}
|
||||
wchat := Map{"openid": re.OpenID,
|
||||
"appid": a.AppID,
|
||||
"state": 0,
|
||||
"retoken": re.SessionKey,
|
||||
"unionid": re.UnionID,
|
||||
"appid": a.AppID,
|
||||
"state": 0,
|
||||
"sessionkey": re.SessionKey,
|
||||
"unionid": re.UnionID,
|
||||
}
|
||||
//wchat["id"] = that.Db.Insert("wechat", wchat)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user