瀏覽代碼

pc端搜索优化

wangshan 5 年之前
父節點
當前提交
fe4463aa88

+ 2 - 1
src/config.json

@@ -319,5 +319,6 @@
     "sealSendTime": 14400,
     "appPushServiceRpc": "127.0.0.1:5566",
     "openPlatformUrl": "https://open-jytest.jianyu360.cn/",
-    "sessionEnctryFlushCorn": "0 0 0 1 * ?"
+    "sessionEnctryFlushCorn": "0 0 0 1 * ?",
+    "PCS_time":30
 }

+ 1 - 1
src/jfw/front/entsearch.go

@@ -68,7 +68,7 @@ func (e *Entsearch) Bidsearchforentindex() error {
 		})
 	} else {
 		e.DisableHttpCache()
-		e.T["list"] = Newbids("")[0]
+		e.T["list"] = PCS_list("") //Newbids("")[0]
 	}
 	if minprice == 0 {
 		e.T["minprice"] = ""

+ 1 - 1
src/jfw/front/front.go

@@ -428,7 +428,7 @@ func (f *Front) Topics() error {
 	f.T["logid"] = config.Seoconfig["jySEMtgy"].(string)
 	f.DisableHttpCache()
 	//底部最新招标数据  3*6 条信息
-	news := Newbids("")[0].([]interface{})
+	news := PCS_list("").([]interface{}) //Newbids("")[0].([]interface{})
 	listAll := [][]map[string]interface{}{}
 	i := 1
 	list := []map[string]interface{}{}

+ 80 - 52
src/jfw/front/supsearch.go

@@ -6,6 +6,7 @@ import (
 	"jfw/filter"
 	"jfw/jylabutil"
 	"jfw/public"
+	"log"
 	"math/rand"
 	"net/http"
 	"qfw/util"
@@ -37,12 +38,52 @@ type Pcsearch struct {
 var industrylist map[string][]string
 var sortArray []string
 var industryname string
+var PCS_index map[string]interface{}
+var PCS_time int
 
 //
 func init() {
 	xweb.AddAction(&Pcsearch{})
 	industryname = util.ObjToString(config.Sysconfig["industry"])
 	industrylist, sortArray = getindustrys()
+	//清除搜索列表内存缓存 间隔时间
+	PCS_time = util.IntAll(config.Sysconfig["PCS_time"])
+	go func() {
+		time.Sleep(time.Second * 5)
+		PCS_task()
+	}()
+}
+
+//定时清理搜索列表页 从redis获取存入内存中的数据
+func PCS_task() {
+	//根据配置延迟 PCS_time 小时执行
+	sub := time.Hour * time.Duration(PCS_time)
+	timer := time.NewTimer(sub)
+	log.Println(PCS_time, "小时后执行清除缓存操作")
+	defer timer.Stop()
+	for {
+		select {
+		case <-timer.C:
+			{
+				PCS_index = map[string]interface{}{}
+				timer.Reset(time.Hour * time.Duration(PCS_time))
+			}
+		}
+	}
+
+}
+
+//返回内存中列表也的数据,只获取首页,其他页面访问量暂时不多
+func PCS_list(page_type string) interface{} {
+	var _page_type = page_type
+	//如果page_type为空,则是获取非拟建数据。
+	if page_type == "" {
+		_page_type = "page_index"
+	}
+	if PCS_index[_page_type] == nil {
+		PCS_index[_page_type] = Newbids(page_type)[0]
+	}
+	return PCS_index[_page_type]
 }
 
 //
@@ -89,7 +130,7 @@ func (p *Pcsearch) ProposedProject() error {
 		})
 	} else {
 		p.DisableHttpCache()
-		p.T["list"] = Newbids("nijian")[0]
+		p.T["list"] = PCS_list("nijian") //Newbids("nijian")[0]
 	}
 	if status == 2 {
 		if list != nil {
@@ -194,13 +235,9 @@ func (p *Pcsearch) GetNewBids() error {
 //
 func (p *Pcsearch) PcSearchIndex() error {
 	defer util.Catch()
-	var shareid = p.GetString("id")
-	if len(shareid) == 0 {
-		shareid = "10"
-	}
 	p.T["logid"] = config.Seoconfig["jysslby"].(string)
-	fmt.Println("logid:", config.Seoconfig["jysslby"].(string))
 	keywords := p.GetString("keywords")
+	industry := strings.TrimSpace(p.GetString("industry")) //选中的行业
 	area := p.GetString("area")                            //地区
 	publishtime := p.GetString("publishtime")              //发布时间
 	timeslot := p.GetString("timeslot")                    //显示选择时间
@@ -208,17 +245,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 	subtype := p.GetString("subtype")                      //信息类型
 	minprice := p.GetString("minprice")                    //最低价格
 	maxprice := p.GetString("maxprice")                    //最高价格
-	industry := strings.TrimSpace(p.GetString("industry")) //选中的行业
-	p.SetSession("industry", industry)
-	selectType := p.GetString("selectType") //标题或全文
-	selectTypesess := p.GetSession("selectType")
-
-	if selectTypesess != nil && selectTypesess != "" {
-		selectType = selectTypesess.(string)
-	}
-	//if selectType == "" {
-	selectType = "title"
-	//}
+	selectType := "title"
 
 	//历史导出数据回显
 	if strings.Contains(p.Url(), "?goback") {
@@ -232,8 +259,10 @@ func (p *Pcsearch) PcSearchIndex() error {
 		selectType = util.ObjToString(p.GetSession("Echo_selectType"))
 		timeslot = util.ObjToString(p.GetSession("Echo_timeslot"))
 	}
-
-	b_word, _, s_word := jy.InterceptSearchKW(keywords, false, len(industry) == 0)
+	b_word, s_word := "", ""
+	if keywords != "" {
+		b_word, _, s_word = jy.InterceptSearchKW(keywords, false, len(industry) == 0)
+	}
 	var list *[]map[string]interface{}
 	var status = 1
 	var count, totalPage int64
@@ -281,7 +310,7 @@ func (p *Pcsearch) PcSearchIndex() error {
 		})
 	} else {
 		p.DisableHttpCache()
-		p.T["list"] = Newbids("")[0]
+		p.T["list"] = PCS_list("") //Newbids("")[0]
 	}
 	if status == 2 {
 		if list != nil {
@@ -315,45 +344,44 @@ func (p *Pcsearch) PcSearchIndex() error {
 				totalPage = 1
 			}
 		}
+		p.T["secondFlag"] = secondFlag
+		p.T["area"] = area
+		p.T["publishtime"] = publishtime
+		p.T["timeslot"] = timeslot
+		p.T["toptype"] = toptype
+		p.T["subtype"] = subtype
+		p.T["searchvalue"] = s_word
+		p.T["selectType"] = selectType
+		p.T["minprice"] = minprice
+		p.T["maxprice"] = maxprice
+		p.T["login"] = p.Session().Get("user")
+		p.T["totalPage"] = totalPage
+		p.T["count"] = count
+		p.SetSession("paramkey", b_word)
+		switch publishtime {
+		case "lately-7":
+			p.SetSession("parampublishtime", "最近7天")
+		case "lately-30":
+			p.SetSession("parampublishtime", "最近30天")
+		case "thisyear":
+			p.SetSession("parampublishtime", "去年")
+		default:
+			p.SetSession("parampublishtime", publishtime)
+		}
+		p.SetSession("paramarea", area)
+		if subtype != "" {
+			p.SetSession("paraminfotype", subtype)
+		} else {
+			p.SetSession("paraminfotype", toptype)
+		}
 	}
-
-	p.T["secondFlag"] = secondFlag
-	p.T["area"] = area
-	p.T["publishtime"] = publishtime
-	p.T["timeslot"] = timeslot
-	p.T["toptype"] = toptype
-	p.T["subtype"] = subtype
 	p.T["keywords"] = b_word
-	p.T["searchvalue"] = s_word
-	p.T["selectType"] = selectType
 	p.T["industry"] = industry
-	p.T["minprice"] = minprice
-	p.T["maxprice"] = maxprice
-	p.T["login"] = p.Session().Get("user")
-	p.T["totalPage"] = totalPage
-	p.T["count"] = count
-	p.SetSession("paramkey", b_word)
-	if publishtime == "lately-7" {
-		p.SetSession("parampublishtime", "最近7天")
-	} else if publishtime == "lately-30" {
-		p.SetSession("parampublishtime", "最近30天")
-	} else if publishtime == "thisyear" {
-		p.SetSession("parampublishtime", "去年")
-	} else {
-		p.SetSession("parampublishtime", publishtime)
-	}
-	p.SetSession("paramarea", area)
-	if subtype != "" {
-		p.SetSession("paraminfotype", subtype)
-	} else {
-		p.SetSession("paraminfotype", toptype)
-	}
 	p.T["industrylist"] = industrylist
 	p.T["sortArray"] = sortArray
-	p.T["shareid"] = se.EncodeString(shareid)
-
 	//
 	if userid := p.GetSession("userId"); userid != nil {
+		//企业画像 权限
 		p.T["portraitpower"] = jylabutil.IsAuthorized(userid.(string), "i_portraitpower")
 	}
 	return p.Render("/pc/supsearch.html", &p.T)

+ 2 - 2
src/web/templates/common/pcbottom.html

@@ -105,7 +105,7 @@
 		<div style="position:relative" class="jy_imgright">
 			<div class="jy_QRtext">微信扫一扫<br>随时随地掌握招标信息</div>
 				<img id=bc_bottoming src="{{Msg "seo" "cdn"}}/images/yj-background.png"/>
-				<img style="position:absolute;left:39px;margin-top:6px;width:123px;" id="bottomimg" src="/front/share/{{.T.shareid}}"/>
+				<img style="position:absolute;left:39px;margin-top:6px;width:123px;" id="bottomimg" src="/front/share/10"/>
 		</div>
 	</div>
 </div>
@@ -115,7 +115,7 @@
 		<div class="j-wx-code">
 			<img class="code-close" src="{{Msg "seo" "cdn"}}/images/j-wx-code-close.png" alt="" onclick="zbsqClose();"/>
 			<div class="code-title"></div>
-			<div class="code-wxm"><img id="layerImg-zbsq" src="/front/share/{{.T.shareid}}"/></div>
+			<div class="code-wxm"><img id="layerImg-zbsq" src="/front/share/10"/></div>
 			<div class="code-text">
 				<span><img id="wxpng" src="{{Msg "seo" "cdn"}}/images/wx1.png"/>微信扫码关注</span>
 				<br/>

+ 20 - 20
src/web/templates/pc/supsearch.html

@@ -236,23 +236,23 @@
 }
 </style>
 <script>
-var areas = {{.T.area}};
-var selectPublishtime = {{.T.publishtime}};
-var selectTimeslot = {{.T.timeslot}};
-var toptype = {{.T.toptype}};
-var subtype = {{.T.subtype}};
-var isopen = {{.T.isopen}};
-var keys = {{.T.keywords}};
-var minprice = {{.T.minprice}};
-var maxprice = {{.T.maxprice}};
-var selectType = {{.T.selectType}};//全文或标题
-var industry = {{.T.industry}}
-var industrylist = {{.T.industrylist}}
-var sortArray = {{.T.sortArray}}
-var list = {{.T.list}}
-var totalPage = {{.T.totalPage}};
-var searchvalue = {{.T.searchvalue}};
-var secondFlag = {{.T.secondFlag}}
+var areas = {{.T.area}}!=null?{{.T.area}}:"";
+var selectPublishtime = {{.T.publishtime}}!=null?{{.T.publishtime}}:"";
+var selectTimeslot = {{.T.timeslot}}!=null?{{.T.timeslot}}:"";
+var toptype = {{.T.toptype}}!=null?{{.T.toptype}}:"";
+var subtype = {{.T.subtype}}!=null?{{.T.subtype}}:"";
+var isopen = {{.T.isopen}}!=null?{{.T.isopen}}:"";
+var keys = {{.T.keywords}}!=null?{{.T.keywords}}:"";
+var minprice = {{.T.minprice}}!=null?{{.T.minprice}}:"";
+var maxprice = {{.T.maxprice}}!=null?{{.T.maxprice}}:"";
+var selectType = {{.T.selectType}}!=null?{{.T.selectType}}:"title";//全文或标题
+var industry = {{.T.industry}}!=null?{{.T.industry}}:"";
+var industrylist = {{.T.industrylist}}!=null?{{.T.industrylist}}:"";
+var sortArray = {{.T.sortArray}}!=null?{{.T.sortArray}}:"";
+var list = {{.T.list}}!=null?{{.T.list}}:"";
+var totalPage = {{.T.totalPage}}!=null?{{.T.totalPage}}:1;
+var searchvalue = {{.T.searchvalue}}!=null?{{.T.searchvalue}}:"";
+var secondFlag = {{.T.secondFlag}}!=null?{{.T.secondFlag}}:"";
 var secondList = ""
 {{if .T.secondList}}
 secondList = {{.T.secondList}}
@@ -285,7 +285,7 @@ $(function(){
 	$("#zbSeatchT [name='selectType']").val(selectType);
 	//
 	$("#searchinput").focus();
-	if(searchvalue!=""){
+	if(searchvalue!=""&&searchvalue!=null){
 		$(".wx-inner-bottom").html('');
 		$("#t-clear").show();
 		$("#newsclass").show();
@@ -601,7 +601,7 @@ $(function(){
 		<div class="j-wx-code" id="myModal-div">
 			<img class="code-close" src="{{Msg "seo" "cdn"}}/images/j-wx-code-close.png" alt="" onclick="layerClose();"/>
 			<div class="code-title"></div>
-			<div class="code-wxm"><img id="layerImg" src="/front/share/{{.T.shareid}}"/></div>
+			<div class="code-wxm"><img id="layerImg" src="/front/share/10"/></div>
 			<div class="code-text">
 				<span><img id="wxpng" src="{{Msg "seo" "cdn"}}/images/wx1.png"/>微信扫码登录</span>
 				<br/>
@@ -645,7 +645,7 @@ $(function(){
 							扫码关注剑鱼标讯
 						</div>
 						<div class="wx-inner-ewm">
-							<img  id="keyImg" src="/front/share/{{.T.shareid}}"/>
+							<img  id="keyImg" src="/front/share/10"/>
 						</div>
 						<div class="wx-inner-bottom">
 							微信扫一扫<br>随时随地掌握招标信息

+ 43 - 17
src/web/templates/weixin/wxinfocontent_rec.html

@@ -1195,44 +1195,70 @@ $(function(){
 		var area = {{.T.obj.area}}
 		if(area=="A"){
 			area="全国"
-		}
+		}else if(area==null){
+      area = "";
+    }
 		var city = {{.T.obj.city}}
 		if(city=="A"){
 			city="全国"
-		}
+		}else if(city==null){
+      city = "";
+    }
 		outhtml +='<li><p class="name">省份</p><p class="textcontent">'+area+'</p></li>'+
 					'<li><p class="name">城市</p><p class="textcontent">'+city+'</p></li>'
 		var reragency = {{.T.obj.agency}};
-		if(reragency==undefined){
+		if(reragency==undefined||reragency==null){
 			reragency=""
 		}
-		outhtml +='<li><p class="name">招标代理机构</p><p class="textcontent">'+{{.T.obj.agency}}+'</p><a dataName="招标代理机构" dataCont="'+{{.T.obj.agency}}+'" dataCode="agency" onClick="recoveryAction(this)">纠错</a></li>'
+		outhtml +='<li><p class="name">招标代理机构</p><p class="textcontent">'+reragency+'</p><a dataName="招标代理机构" dataCont="'+reragency+'" dataCode="agency" onClick="recoveryAction(this)">纠错</a></li>'
 		var rerprojectname = {{.T.obj.projectname}};
-		if(rerprojectname!=undefined){
+		if(rerprojectname!=undefined||rerprojectname==null){
 			rerprojectname=""
 		}
-		outhtml +='<li><p class="name">项目名称</p><p class="textcontent">'+{{.T.obj.projectname}}+'</p><a dataName="项目名称" dataCont="'+{{.T.obj.projectname}}+'" dataCode="projectname" onClick="recoveryAction(this)">纠错</a></li>'
+		outhtml +='<li><p class="name">项目名称</p><p class="textcontent">'+rerprojectname+'</p><a dataName="项目名称" dataCont="'+rerprojectname+'" dataCode="projectname" onClick="recoveryAction(this)">纠错</a></li>'
 		var rerbuyer = {{.T.obj.buyer}};
-		if(rerbuyer==undefined){
+		if(rerbuyer==undefined||rerbuyer==null){
 			rerbuyer=""
 		}
-		outhtml +='<li><p class="name">采购单位</p><p class="textcontent">'+{{.T.obj.buyer}}+'</p><a dataName="采购单位" dataCont="'+{{.T.obj.buyer}}+'" dataCode="buyer" onClick="recoveryAction(this)">纠错</a></li>'
-		outhtml +='<li><p class="name">采购联系人</p><p class="textcontent">'+{{.T.obj.buyerperson}}+'</p><a dataName="采购联系人" dataCont="'+{{.T.obj.buyerperson}}+'" dataCode="buyerperson" onClick="recoveryAction(this)">纠错</a></li>'+
-					'<li class="bbm0"><p class="name">采购电话</p><p class="textcontent">'+{{.T.obj.buyertel}}+'</p><a dataName="采购电话" dataCont="'+{{.T.obj.buyertel}}+'" dataCode="buyertel" onClick="recoveryAction(this)">纠错</a></li>'
+    var rerbuyerperson = {{.T.obj.buyerperson}};
+		if(rerbuyerperson==undefined||rerbuyerperson==null){
+			rerbuyerperson=""
+		}
+    var rerbuyertel = {{.T.obj.buyertel}};
+		if(rerbuyertel==undefined||rerbuyertel==null){
+			rerbuyertel=""
+		}
+		outhtml +='<li><p class="name">采购单位</p><p class="textcontent">'+rerbuyer+'</p><a dataName="采购单位" dataCont="'+rerbuyer+'" dataCode="buyer" onClick="recoveryAction(this)">纠错</a></li>'
+		outhtml +='<li><p class="name">采购联系人</p><p class="textcontent">'+rerbuyerperson+'</p><a dataName="采购联系人" dataCont="'+rerbuyerperson+'" dataCode="buyerperson" onClick="recoveryAction(this)">纠错</a></li>'+
+					'<li class="bbm0"><p class="name">采购电话</p><p class="textcontent">'+rerbuyertel+'</p><a dataName="采购电话" dataCont="'+rerbuyertel+'" dataCode="buyertel" onClick="recoveryAction(this)">纠错</a></li>'
 		if(packageCon==""){
-			outhtml +='<li style="border-top:1px solid #ebebeb;" class="bbm0"><p class="name">项目预算(元)</p><p class="textcontent">'+{{.T.obj.budget}}+'</p><a dataName="项目预算(元)" dataCont="'+{{.T.obj.budget}}+'" dataCode="budget" onClick="recoveryAction(this)">纠错</a></li>'
+    var rerbudget = {{.T.obj.budget}};
+		if(rerbudget==undefined||rerbudget==null){
+			rerbudget=""
+		}
+			outhtml +='<li style="border-top:1px solid #ebebeb;" class="bbm0"><p class="name">项目预算(元)</p><p class="textcontent">'+rerbudget+'</p><a dataName="项目预算(元)" dataCont="'+rerbudget+'" dataCode="budget" onClick="recoveryAction(this)">纠错</a></li>'
 			}
 		if({{.T.obj.subtype}}=="单一"&&packageCon==""){
 			var rerwinner = {{.T.obj.winner}};
-			outhtml +='<li style="border-top:1px solid #ebebeb;"><p class="name">拟定单一来源采购供应商</p><p class="textcontent">'+{{.T.obj.winner}}+'</p><a dataName="拟定单一来源采购供应商" dataCont="'+{{.T.obj.winner}}+'" dataCode="winner" onClick="recoveryAction(this)">纠错</a></li>'
+      if(rerwinner==null){
+        rerwinner=""
+      }
+			outhtml +='<li style="border-top:1px solid #ebebeb;"><p class="name">拟定单一来源采购供应商</p><p class="textcontent">'+rerwinner+'</p><a dataName="拟定单一来源采购供应商" dataCont="'+rerwinner+'" dataCode="winner" onClick="recoveryAction(this)">纠错</a></li>'
 		}
 	$("#baseInfo ul").html(outhtml)
 	//中标信息
 	if({{.T.obj.subtype}}=="中标"||{{.T.obj.subtype}}=="成交"||{{.T.obj.subtype}}=="合同"){
 		$("#bidInfoTitle").show();
 		var rerwinner = {{.T.obj.winner}};
+      if(rerwinner==null){
+        rerwinner=""
+      }
+		var rerbidamount = {{.T.obj.bidamount}};
+      if(rerbidamount==null){
+        rerbidamount=""
+      }
 		var bidInfohtml ='<li><p class="name">中标单位</p><p class="textcontent">'+rerwinner+'</p><a dataName="中标单位" dataCont="'+rerwinner+'" dataCode="winner" onClick="recoveryAction(this)">纠错</a></li>'
-		bidInfohtml +='<li class="bbm0"><p class="name">中标金额(元)</p><p class="textcontent">'+{{.T.obj.bidamount}}+'</p><a dataName="中标金额(元)" dataCont="'+{{.T.obj.bidamount}}+'" dataCode="bidamount" onClick="recoveryAction(this)">纠错</a></li>'
+		bidInfohtml +='<li class="bbm0"><p class="name">中标金额(元)</p><p class="textcontent">'+rerbidamount+'</p><a dataName="中标金额(元)" dataCont="'+rerbidamount+'" dataCode="bidamount" onClick="recoveryAction(this)">纠错</a></li>'
 		$("#bidInfo ul").html(bidInfohtml)
 	}
 	var rerwinnerorder = {{.T.obj.winnerorder}}//中标候选人
@@ -1242,16 +1268,16 @@ $(function(){
 		for(n in packageCon){
 			pkchtml+='<div class="publicTitle" id="bagInfoTitle">分包</div><div id="bagInfo" class="itemInfo"><ul>'
 			var pckorigin = packageCon[n].m_origin
-			if(pckorigin==undefined){
+			if(pckorigin==undefined||pckorigin==null){
 				pckorigin=packageCon[n].type+packageCon[n].origin
 			}
 			pkchtml+='<li><p class="name">分包/标段</p><p class="textcontent">'+pckorigin+'</p><a dataName="分包/标段" dataCont="'+pckorigin+'" dataCode="'+n+'-m_origin" onClick="recoveryAction(this)">纠错</a></li>'
 			var pckwinner = packageCon[n].winner
-			if(pckwinner==undefined){
+			if(pckwinner==undefined||pckwinner==null){
 				pckwinner=""
 			}
 			var pckbidamount = packageCon[n].bidamount;
-			if(pckbidamount==undefined){
+			if(pckbidamount==undefined||pckbidamount==null){
 				pckbidamount=""
 			}
 			if({{.T.obj.subtype}}=="招标"){
@@ -1268,7 +1294,7 @@ $(function(){
 			
 			pkchtml+='</ul></div>'
 			var pckwinnerorder = packageCon[n].winnerorder;
-			if(pckwinnerorder!=undefined&&pckwinnerorder.length>0){
+			if(pckwinnerorder!=undefined&&pckwinnerorder.length>0&&pckwinnerorder!=null){
 				pkchtml+='<div class="publicTitle" id="candidateInfoTitle"><span class="line"></span>候选人</div><div id="candidateInfo" class="itemInfo" style="border-bottom:0px">'
 				for(var i=0;i<pckwinnerorder.length;i++){
 					if(i>0){