|
@@ -9,6 +9,7 @@ import (
|
|
|
"github.com/go-xweb/httpsession"
|
|
|
"jfw/jyutil"
|
|
|
"fmt"
|
|
|
+ "qfw/util/redis"
|
|
|
)
|
|
|
|
|
|
type PcHelper struct {
|
|
@@ -24,6 +25,13 @@ func init() {
|
|
|
xweb.AddAction(&PcHelper{})
|
|
|
}
|
|
|
|
|
|
+var (
|
|
|
+ redisKeyPrefix_PPVOpenid = "pc_push_view_openid_"
|
|
|
+ redisPool = "other"
|
|
|
+ timeout = 15
|
|
|
+ redisKey_openid = "pc_s_m_openid"
|
|
|
+)
|
|
|
+
|
|
|
func (l *PcHelper) Login() error {
|
|
|
defer util.Catch()
|
|
|
//登录页面
|
|
@@ -48,7 +56,7 @@ func (l *PcHelper) Login() error {
|
|
|
query := map[string]interface{}{
|
|
|
"i_appid": 2,
|
|
|
"s_m_openid": phone,
|
|
|
- "i_type": 1, //app用户(手机号注册用户)??
|
|
|
+ "i_type": 1, //app用户(手机号注册用户)
|
|
|
"s_password": util.GetMd5String(password),
|
|
|
}
|
|
|
user, ok := mongodb.FindOne("user", query)
|
|
@@ -151,7 +159,7 @@ func (l *PcHelper) Login() error {
|
|
|
}
|
|
|
|
|
|
func (l *PcHelper) Logout() {
|
|
|
- l.DelSession("pc_s_m_openid")
|
|
|
+ l.DelSession(redisKey_openid)
|
|
|
deleteIdentSession_(l.Session())
|
|
|
l.ServeJson(map[string]interface{}{
|
|
|
"status": 1,
|
|
@@ -165,6 +173,7 @@ func (l *PcHelper) GetSubscribeToken() error {
|
|
|
reToken := ""
|
|
|
if phone != "" && mac == deMac {
|
|
|
reToken = getSToken(token)
|
|
|
+ redis.Put(redisPool, redisKeyPrefix_PPVOpenid+phone, 1, timeout)
|
|
|
} else {
|
|
|
reToken = ""
|
|
|
}
|
|
@@ -180,9 +189,14 @@ func (l *PcHelper) ToPushView() error {
|
|
|
mac := l.GetString("mac")
|
|
|
if token != "" && mac != "" {
|
|
|
deMac, phone := decryptSToken(token)
|
|
|
- if phone != "" && mac == deMac {
|
|
|
- l.SetSession("pc_s_m_openid", phone)
|
|
|
- return l.Render("/pchelper/pushView.html")
|
|
|
+ b, err := redis.Exists(redisPool, redisKeyPrefix_PPVOpenid+phone)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("redis key "+redisKeyPrefix_PPVOpenid+phone, err.Error())
|
|
|
+ } else {
|
|
|
+ if phone != "" && mac == deMac && b {
|
|
|
+ l.SetSession(redisKey_openid, phone)
|
|
|
+ return l.Render("/pchelper/pushView.html")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return l.Redirect("/")
|
|
@@ -191,7 +205,7 @@ func (l *PcHelper) ToPushView() error {
|
|
|
func (l *PcHelper) PushView() error {
|
|
|
defer util.Catch()
|
|
|
lasttime, _ := l.GetInt("lasttime")
|
|
|
- myopenid, _ := l.GetSession("pc_s_m_openid").(string)
|
|
|
+ myopenid, _ := l.GetSession(redisKey_openid).(string)
|
|
|
res := map[string]interface{}{}
|
|
|
res["success"] = false
|
|
|
if myopenid != "" && lasttime > 0 {
|