Эх сурвалжийг харах

wip:小程序模拟登录到详情页

wangshan 1 жил өмнө
parent
commit
83b7938fc9

+ 10 - 0
src/jfw/modules/app/src/app/filter/phonefilter.go

@@ -1,12 +1,14 @@
 package filter
 
 import (
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"fmt"
 	utils "jy/src/jfw/modules/app/src/app/jyutil"
 	"jy/src/jfw/modules/app/src/jfw/config"
 	"log"
 	"net/http"
 	"regexp"
+	"strconv"
 	"strings"
 	"time"
 
@@ -89,6 +91,14 @@ func (l *phoneFilter) Do() bool {
 					return true
 				}
 				if articleUrl.MatchString(l.R.URL.Path) {
+					//小程序
+					if paths := strings.Split(l.R.URL.RequestURI(), "miniprogram="); len(paths) > 0 {
+						if viewTime := encrypt.SE.Decode4Hex(paths[1]); viewTime != "" {
+							if vt, err := strconv.ParseInt(viewTime, 10, 64); err != nil && time.Now().Unix()-vt < 30 {
+								return false
+							}
+						}
+					}
 					bindPopNum := redis.Incr(dbname, key)
 					if bindPopNum == qu.Int64All(config.Sysconfig["firstBindPop"]) ||
 						bindPopNum > qu.Int64All(config.Sysconfig["maxBindPop"]) {

+ 34 - 0
src/jfw/modules/app/src/app/front/login.go

@@ -14,6 +14,7 @@ import (
 	"log"
 	"net/http"
 	"regexp"
+	"strconv"
 	"strings"
 	"sync"
 	"time"
@@ -59,6 +60,7 @@ type Login struct {
 	channelSign          xweb.Mapper `xweb:"/jyapp/free/channelSign"`          //渠道统计
 	savePushIdMsg        xweb.Mapper `xweb:"/jyapp/free/savePushIdMsg"`        //推送id记录
 	setPwd               xweb.Mapper `xweb:"/jyapp/free/setPwd"`               //修改密码
+	activateLogin        xweb.Mapper `xweb:"/jyapp/free/al/(.*)"`              //小程序激活活动模拟登录跳转详情页
 }
 
 var (
@@ -79,6 +81,38 @@ func init() {
 	go rs.GC()
 }
 
+// 小程序激活活动模拟登录跳转详情页
+func (l *Login) ActivateLogin(id string) error {
+	redirectUrl := "pages/tabbar/home/index" //小程序首页地址
+	if id != "" && encrypt.SE.EncodeString(id) != "" {
+		id = encrypt.SE.EncodeString(id)
+		sessVal := l.Session().GetMultiple()
+		userid, _ := sessVal["mgoUserId"].(string)
+		uId, err := strconv.Atoi(id)
+		activateInfos := public.BaseMysql.SelectBySql(`SELECT au.user_id,au.phone,au.position_id,ab.id FROM activate_user au LEFT JOIN activate_bidding ab ON au.id = ab.au_id WHERE au.id = ?`, uId)
+		if activateInfos != nil && len(*activateInfos) > 0 {
+			activateInfo := (*activateInfos)[0]
+			biddingId := qutil.InterfaceToStr(activateInfo["id"])
+			if userid == "" { //模拟登录
+				if err == nil && uId > 0 {
+					mgoUserId := qutil.InterfaceToStr(activateInfo["user_id"])
+					if mgoUserId != "" && biddingId != "" {
+						if ok := jy.JyAppCreateSession(mongodb, l.Session(), mgoUserId, 0, l.ResponseWriter, false, config.Middleground, qutil.ObjToString(config.Sysconfig["appPushServiceRpc"]), qutil.IntAll(config.Sysconfig["criticality"])); ok {
+							sessVal := l.Session().GetMultiple()
+							userid, _ = sessVal["mgoUserId"].(string)
+						}
+					}
+				}
+			}
+			if userid != "" {
+				biddingId = encrypt.EncodeArticleId2ByCheck(biddingId)
+				redirectUrl = fmt.Sprintf("/jyapp/article/content/%s.html?miniprogram=%s", biddingId, encrypt.SE.Encode2Hex(strconv.FormatInt(time.Now().Unix(), 10)))
+			}
+		}
+	}
+	return l.Redirect(redirectUrl)
+}
+
 func (l *Login) Login() error {
 	defer qutil.Catch()
 	if l.Method() == "GET" {