瀏覽代碼

提交修改推送接口

renzheng 9 年之前
父節點
當前提交
df1787566d

+ 1 - 0
common/src/qfw/util/rpc/push.go

@@ -3,4 +3,5 @@ package rpc
 type PushData struct {
 	Mopenid  string
 	PushType map[string]string
+	Words    string
 }

+ 3 - 3
core/src/web/staticres/wxswordfish/main.js

@@ -494,7 +494,7 @@ $(function(){
 				});
 			}
 		}
-		$("#"+type+"-content li:last").append('<div class="com-last">'+scope.replace(/,/g,";")+'</div>');
+		$("#"+type+"-content li:eq(1)").append('<div class="com-last">'+scope.replace(/,/g,";")+'</div>');
 	}
 	$("body").append($("#tender-keyword").clone().removeAttr("id").attr("id","bid-keyword"))
 			.append($("#tender-scope").clone().removeAttr("id").attr("id","bid-scope"));
@@ -573,8 +573,8 @@ $(function(){
 		$("#prexieyi").append("<br>");
 	}
 	//预览跳转
-	$(".result-view").click(function(){
-		var val=$(this).closest("li").find("ul>li:first-child>div.com-last").text().replace(/\s+/ig,"")
+	$(".result-view-2").click(function(){
+		var val=$(this).closest("ul").find("li:first-child>div.com-last").text().replace(/\s+/ig,"")
 		if(val){
 			window.location.href="/wxpush/bid/wxpushview/"+$(this).attr("v")
 		}else{

+ 4 - 10
core/src/web/staticres/wxswordfish/style.css

@@ -76,16 +76,6 @@ img{
 	font-size: 16px;
 	text-align:center;
 }
-.result-view{
-	width:80%;
-	margin:5px auto;
-	background-color:#F5F4F4;
-	color:black;
-	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
-	font-size: 14px;
-	font-size:16px;
-	border:1px solid #DBDBDB;
-}
 .operation>.parent-node>img{
 	margin-left: 10px;
 	margin-right: 10px;
@@ -619,4 +609,8 @@ img{
 .slide-point span.current {
 	background: #007aff;
 	opacity: 1;
+}
+.no-result{
+	text-align:center;
+	color:#999;
 }

+ 7 - 5
core/src/web/templates/swordfish/wxpush.html

@@ -15,21 +15,23 @@ $(function(){
 	var s = document.getElementsByTagName("script")[0]; 
 	s.parentNode.insertBefore(hm, s);
 	//
+	var width=$(window).width();
+	var height=$(window).height();
 	var s_words = {{.T.data.s_words}};
 	var a_visitedindex = {{.T.data.a_visitedindex}};
 	var s_type = {{.T.data.s_type}};
 	var a_publishtime = {{.T.data.a_publishtime}};
 	var s_content={{.T.data.s_content}}
-	var mark="为推送以下信息:"
+	var mark="为推送以下信息:"
 	if(!s_content&&"1"==b_view){
-		s_content="<div></div>"
-		mark=",在最新5天的数据中,没有匹配到相应的信息,请更换关键字或继续观察、使用。<a style='text-decoration:underline' href='javascript:history.go(-1)'>返回</a>"
+		s_content="<div></div><div class='no-result'><div><img style='width:"+(width*0.75)+"px;max-width:350px;margin-top:15px;' src='/images/findnull.png'></div><div>查询不到相关信息,请返回  </div><div>修改关键词  </div></div>"
+		mark=",预览结果如下:"
 	}else if("1"==b_view){
-		mark="为你推送以下预览信息(<a style='text-decoration:underline' href='javascript:history.go(-1)'>返回</a>):"
+		mark=",预览结果如下:"
 	}
 	$("body").prepend(s_content);
 	if(typeof(s_words) != "undefined" && s_words.length > 0){
-		$("body>div:first").html('根据你设置的'+(s_type=="tender"?"招标公告":s_type=="bid"?"中标公告":"")+'关键词(<font class="keyword">'+s_words.join(" ; ").replace(/\+/gm," ")+'</font>)'+mark);
+		$("body>div:first").html('{{session "nickName"}},您好!根据您设置的'+(s_type=="tender"?"招标公告":s_type=="bid"?"中标公告":"")+'关键词(<font class="keyword">'+s_words.join(" ; ").replace(/\+/gm," ")+'</font>)'+mark);
 	}else{
 		$("body>div:first").remove();
 	}

+ 7 - 6
core/src/web/templates/swordfish/wxrssset.html

@@ -41,10 +41,10 @@
 				<li>
 					<div>信息范围<img src="{{Msg "seo" "cdn"}}/wxswordfish/images/right.png"></div>
 				</li>
+				<li class="result-view-2" v="tender" style="border-bottom:none;cursor:pointer">
+					<div>结果预览<img src="{{Msg "seo" "cdn"}}/wxswordfish/images/right.png"></div>
+				</li>
 			</ul>
-			<div  class="parent-node-view">
-				<button class="btn result-view" v="tender" >结果预览</button >	
-			</div>
 		</li>
 
 		<li class="parent-node" id="bid">
@@ -61,10 +61,11 @@
 				<li>
 					<div>信息范围<img src="{{Msg "seo" "cdn"}}/wxswordfish/images/right.png"></div>
 				</li>
+				<li class="result-view-2" v="bid" style="border-bottom:none;cursor:pointer">
+					<div>结果预览<img src="{{Msg "seo" "cdn"}}/wxswordfish/images/right.png"></div>
+				</li>
 			</ul>
-			<div  class="parent-node-view">
-				<button class="btn result-view" v="bid" >结果预览</button >	
-			</div>
+
 		</li>
 		
 		<li class="parent-node">

+ 29 - 6
push/src/qfw/push/dopush/dopush.go

@@ -44,16 +44,34 @@ func (b *Pjob) CreateUserInterestWord() {
 }
 
 //遍历数据只做标题预览
-func (p *Pjob) EachInfoForView(mopenid string) map[string]interface{} {
+func (p *Pjob) EachInfoForView(mopenid, words string) map[string]interface{} {
 	defer func() {
 		if r := recover(); r != nil {
-			fmt.Println("推送开始[E]", r)
+			log.Println("[E]", r)
+			for skip := 0; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
 		}
 	}()
 	p.Cache = new(map[string]*[]*push.MemberInterest)
-	*p.Cache = push.InitCache(p.Stype, mopenid)
+	if words != "" {
+		pm := push.MemberInterest{
+			Province:    "A",
+			ProvinceVal: 0,
+			Interest:    []string{words},
+		}
+		ss := []*push.MemberInterest{&pm}
+		*p.Cache = map[string]*[]*push.MemberInterest{
+			words: &ss,
+		}
+	} else {
+		*p.Cache = push.InitCache(p.Stype, mopenid)
+	}
 	p.CreateUserInterestWord()
-
 	session := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(session)
 	q := `{"type":"` + p.Stype + `"}`
@@ -72,8 +90,11 @@ func (p *Pjob) EachInfoForView(mopenid string) map[string]interface{} {
 				res := p.Dfa.Analy(title)
 				if len(res) > 0 {
 					province := (*tmp)["area"].(string)
+
 					provinceVal := push.GetChoiceCode(province)
-					(*tmp)["title"] = `[<span class='area'>` + province + `</span>]` + title
+					if "A" != province {
+						(*tmp)["title"] = `[<span class='area'>` + province + `</span>]` + title
+					}
 					for _, v := range res {
 						//根据关键词返回用户指针
 						tw := (*p.Cache)[v]
@@ -183,7 +204,9 @@ L1:
 			if len(res) > 0 {
 				province := (*tmp)["area"].(string)
 				provinceVal := push.GetChoiceCode(province)
-				(*tmp)["title"] = `[<span class='area'>` + province + `</span>]` + title
+				if "A" != province {
+					(*tmp)["title"] = `[<span class='area'>` + province + `</span>]` + title
+				}
 				for _, v := range res {
 					//根据关键词返回用户指针
 					tw := (*cache)[v]

+ 1 - 1
push/src/qfw/push/rpcpush/rpcpush.go

@@ -26,7 +26,7 @@ func (p *PushInfo) ResultView(data *qrpc.PushData, Reply *[]byte) error {
 				Stype:       k,
 				StypeName:   v,
 			}
-			mp := pj.EachInfoForView(data.Mopenid)
+			mp := pj.EachInfoForView(data.Mopenid, data.Words)
 			log.Println("mp:", len((mp)))
 			*Reply, _ = json.Marshal(mp)
 		}

+ 23 - 0
push/src/qfw/push/wxcall_test.go

@@ -1,7 +1,9 @@
 package push
 
 import (
+	"encoding/json"
 	"log"
+	"net/rpc"
 	"regexp"
 
 	qrpc "qfw/util/rpc"
@@ -23,3 +25,24 @@ func TestWeixinRpc(t *testing.T) {
 	//coreutil.SendIdentifyTplMsg(&qrpc.NotifyMsg{Openid: "obEpLuKW516dqWdc-WT-Ra_5qigo", Remark: "审核成功", Detail: "你传的营业执照图片不清晰", Result: "认证失败"})
 	time.After(20 * time.Second)
 }
+
+func TestPushRpc(t *testing.T) {
+
+	clent, errs := rpc.DialHTTP("tcp", "127.0.0.1:8766")
+	defer clent.Close()
+	rpcData := qrpc.PushData{
+		//Mopenid: "oJULtwzXo6EFV1Ah-XeyRBimXGM8",
+		PushType: map[string]string{
+			"bid": "中标",
+		},
+		Words: "分析+公告",
+	}
+	var repl []byte
+	clent.Call("PushInfo.ResultView", &rpcData, &repl)
+	if errs == nil && repl != nil && len(repl) > 0 {
+		var mp map[string]interface{}
+		json.Unmarshal(repl, &mp)
+		log.Println(mp)
+	}
+
+}