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

手机版本企业社区搜索

李广朋 9 жил өмнө
parent
commit
4f715b55a9

+ 55 - 6
core/src/qfw/search/searchService.go

@@ -21,8 +21,23 @@ import (
 	"strings"
 	"strings"
 )
 )
 
 
+type EntInfo struct {
+	_id           string
+	EntName       string //企业名称
+	RegNo         string //注册号
+	LeRep         string // 法定代表人
+	OpLocDistrict string //区域代码
+	EstDate       string //注册时间
+	OpStateName   string //状态名称
+}
+
 //企业社区首页
 //企业社区首页
 func (search *Search) EntCommunity() error {
 func (search *Search) EntCommunity() error {
+	ismobile := strings.Index(search.Header("User-Agent"), "Mobile")
+	if ismobile > -1 {
+		search.Render("/member/incmobile/index.html")
+		return nil
+	}
 	//新认证企业
 	//新认证企业
 	var newIndentEnts []interface{}
 	var newIndentEnts []interface{}
 	if ret := redis.Get("enterprise", "newIndentEnts"); ret != nil {
 	if ret := redis.Get("enterprise", "newIndentEnts"); ret != nil {
@@ -122,7 +137,7 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 	//必须是登录之后的已认证用户才可以进入企业社区
 	//必须是登录之后的已认证用户才可以进入企业社区
 	//if ui, _ := (n.GetSession("userInfo")).(*map[string]interface{}); reqType == "m_" || (n.GetSession("userType") != nil && IntAll(n.GetSession("userType")) > 0) && ((n.GetSession("identWay") != nil && IntAll(n.GetSession("identWay")) == 1) || ((*ui)["s_pid"] != nil && (*ui)["s_pid"].(string) != "")) {
 	//if ui, _ := (n.GetSession("userInfo")).(*map[string]interface{}); reqType == "m_" || (n.GetSession("userType") != nil && IntAll(n.GetSession("userType")) > 0) && ((n.GetSession("identWay") != nil && IntAll(n.GetSession("identWay")) == 1) || ((*ui)["s_pid"] != nil && (*ui)["s_pid"].(string) != "")) {
 	//n.T["uri"] = n.Uri()
 	//n.T["uri"] = n.Uri()
-
+	ismobile := strings.Index(n.Header("User-Agent"), "Mobile")
 	if len(param) == 0 {
 	if len(param) == 0 {
 		//请求是表单提交,走的查询
 		//请求是表单提交,走的查询
 		//拼装查询对象
 		//拼装查询对象
@@ -140,7 +155,7 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 		}
 		}
 		//查询生成列表数据
 		//查询生成列表数据
 		data, pagination := searhWebContentent(querymap, n, reqType)
 		data, pagination := searhWebContentent(querymap, n, reqType)
-
+		log.Println(len(*data))
 		//查询送积分
 		//查询送积分
 		queryStr := querymap["query"]
 		queryStr := querymap["query"]
 		if len(queryStr) > 0 {
 		if len(queryStr) > 0 {
@@ -155,7 +170,25 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 				}
 				}
 			}
 			}
 		}
 		}
-		n.Render("/search/enterpriseList.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+		if ismobile > -1 {
+			entinfos := make([]map[string]string, 0)
+			for _, v := range *data {
+				tmp := map[string]string{
+					"_id":           fmt.Sprint(v["_id"]),
+					"EntName":       fmt.Sprint(v["EntName"]),
+					"RegNo":         fmt.Sprint(v["RegNo"]),
+					"LeRep":         fmt.Sprint(v["LeRep"]),
+					"OpLocDistrict": fmt.Sprint(v["OpLocDistrict"]),
+					"EstDate":       fmt.Sprint(v["EstDate"]),
+					"OpStateName":   fmt.Sprint(v["OpStateName"]),
+				}
+				entinfos = append(entinfos, tmp)
+			}
+			d, _ := json.Marshal(entinfos)
+			n.Render("/member/incmobile/list.html", &xweb.T{"data": string(d)})
+		} else {
+			n.Render("/search/enterpriseList.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+		}
 	} else {
 	} else {
 		//反转生成map
 		//反转生成map
 		paramstr := param[1:]
 		paramstr := param[1:]
@@ -163,9 +196,26 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 		querymap := map[string]string{}
 		querymap := map[string]string{}
 
 
 		json.Unmarshal(bs, &querymap)
 		json.Unmarshal(bs, &querymap)
-		log.Println(querymap)
 		data, pagination := searhWebContentent(querymap, n, reqType)
 		data, pagination := searhWebContentent(querymap, n, reqType)
-		n.Render("/search/enterpriseList.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+		if ismobile > -1 {
+			entinfos := make([]map[string]string, 0)
+			for _, v := range *data {
+				tmp := map[string]string{
+					"_id":           fmt.Sprint(v["_id"]),
+					"EntName":       fmt.Sprint(v["EntName"]),
+					"RegNo":         fmt.Sprint(v["RegNo"]),
+					"LeRep":         fmt.Sprint(v["LeRep"]),
+					"OpLocDistrict": fmt.Sprint(v["OpLocDistrict"]),
+					"EstDate":       fmt.Sprint(v["EstDate"]),
+					"OpStateName":   fmt.Sprint(v["OpStateName"]),
+				}
+				entinfos = append(entinfos, tmp)
+			}
+			d, _ := json.Marshal(entinfos)
+			n.Render("/member/incmobile/list.html", &xweb.T{"data": string(d)})
+		} else {
+			n.Render("/search/enterpriseList.html", &xweb.T{"querymap": querymap, "data": data, "pagination": pagination})
+		}
 	}
 	}
 	return nil
 	return nil
 	//} else {
 	//} else {
@@ -481,7 +531,6 @@ func searhWebContentent(querymap map[string]string, n *Search, reqType string) (
 	if client == nil {
 	if client == nil {
 		return nil, nil
 		return nil, nil
 	}
 	}
-	log.Println(query)
 	searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
 	searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
 	if err != nil {
 	if err != nil {
 		return nil, nil
 		return nil, nil

+ 37 - 0
core/src/web/staticres/css/mobile/incmobile.css

@@ -3,6 +3,9 @@ body{
 	font-size:14px;
 	font-size:14px;
 	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
 	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
 }
 }
+input{
+	outline:none
+} 
 ul{
 ul{
 	list-style:none;
 	list-style:none;
 	padding-left:0px;
 	padding-left:0px;
@@ -12,6 +15,7 @@ ul{
 	padding:5px 0 0 0 ;
 	padding:5px 0 0 0 ;
 	background-color:rgb(247,248,250) !important;
 	background-color:rgb(247,248,250) !important;
 	border-bottom:1px solid #E7E7E7 !important;
 	border-bottom:1px solid #E7E7E7 !important;
+	text-align:center;
 }
 }
 .m-searchbar div.containers{
 .m-searchbar div.containers{
 	margin:0px auto;
 	margin:0px auto;
@@ -23,6 +27,27 @@ ul{
 	width: 71%;
 	width: 71%;
 	border: 1px solid #DDDFDB !important;
 	border: 1px solid #DDDFDB !important;
 	border-radius: 15px;
 	border-radius: 15px;
+	padding-left: 15px;
+}
+.m-searchbar .immediately{
+	position: absolute;
+	display:none;
+    	z-index: 9999;
+	top: 35px !important;
+	border: 1px solid #B5B6BB;
+	border-top: 0px;
+	padding:3px;
+	margin-left: 57px;
+	background: #FFF;
+}
+.m-searchbar .immediately div{
+	height:30px;
+	line-height:30px ;
+}
+.m-searchbar .immediately div:hover{
+	cursor:pointer;
+	background-color:#16A086;
+	color:#FFF;
 }
 }
 .m-searchbar .searchbtn{
 .m-searchbar .searchbtn{
 	display: inline-block;
 	display: inline-block;
@@ -245,6 +270,18 @@ hr.list{
 .index-navtable div:hover{
 .index-navtable div:hover{
 	background:#F6F8FA !important;
 	background:#F6F8FA !important;
 }
 }
+.ent-status-g,.ent-status-r{
+	background-size: 100% 100%;
+	padding: 2px 10px 2px 5px;
+	color:#FFF;
+	font-weight:normal;
+}
+.ent-status-g{
+	background-image: url("/images/status-g.png");
+}
+.ent-status-r{
+	background-image: url("/images/status-r.png");
+}
 /*各详细页面*/
 /*各详细页面*/
 .comnav ,.secnav{
 .comnav ,.secnav{
 	height:50px;
 	height:50px;

+ 26 - 1
core/src/web/staticres/js/entcommunity.js

@@ -11,6 +11,24 @@ mCommunity.prototype={
 		return this;
 		return this;
 	},
 	},
 	initIndex:function(){
 	initIndex:function(){
+		changeSearchBorder();
+		$(window).resize(function(){
+			changeSearchBorder();
+		});
+		$("#query").keyup(function(){
+			imFind(this);
+			if($("#immediately").children().length>0){
+				$("#immediately").show();
+			}
+		});
+		$("#query").focus(function(){
+			if($("#immediately").children().length>0){
+				$("#immediately").show();
+			}
+		});
+		$("#query").blur(function(){
+			$("#immediately").hide();
+		});
 		//高级搜索
 		//高级搜索
 		$(".searchlink").click(function(){
 		$(".searchlink").click(function(){
 			n=$(".nav-bar");
 			n=$(".nav-bar");
@@ -103,4 +121,11 @@ mCommunity.prototype={
 	}
 	}
 }
 }
 
 
-mCommunity.prototype.init.prototype = mCommunity.prototype;
+mCommunity.prototype.init.prototype = mCommunity.prototype;
+
+function changeSearchBorder(){
+		var width=$("#query").css("width");
+		width=width.substr(0,width.indexOf("p"))-30+"px";
+		$("#immediately").css("width",width);
+		$("#immediately").css("margin-left",$("#query").offset().left+15);
+	}

+ 14 - 3
core/src/web/templates/member/incmobile/index.html

@@ -44,7 +44,7 @@
 			.input-before{
 			.input-before{
 				z-index: 30;
 				z-index: 30;
 				position: absolute;
 				position: absolute;
-				top: 15px;
+				top: 14px;
 				left: 9px;
 				left: 9px;
 				color: #A0A0A0;
 				color: #A0A0A0;
 				font-size:11px;
 				font-size:11px;
@@ -70,6 +70,10 @@
 			.footer .container .inc p{
 			.footer .container .inc p{
 				font-size:10px;
 				font-size:10px;
 			}
 			}
+			#query{
+				height:40px;
+				padding-left:25px;
+			}
 		</style>
 		</style>
 	</head>
 	</head>
 <body class="index-bodybg">
 <body class="index-bodybg">
@@ -79,10 +83,10 @@
 				查企业,查企业失信信息,查企业变更,查你所想,无所不能...
 				查企业,查企业失信信息,查企业变更,查你所想,无所不能...
 			</div>
 			</div>
 			<div style="clear:both;" class="col-sm-8">
 			<div style="clear:both;" class="col-sm-8">
-              <form>
+              <form method="post"  action="/search/enterprise/ent.html">
 						<div class="input-group col-xs-12">
 						<div class="input-group col-xs-12">
 							<i class="glyphicon glyphicon-search input-before"></i>
 							<i class="glyphicon glyphicon-search input-before"></i>
-                 		<input type="text" id="query" class="form-control" placeholder="   找企业" style="height:40px;">
+                 		<input type="text" id="query" class="form-control" name="words" placeholder="找企业"  >
 							<span class="input-group-addon"><span class="glyphicon glyphicon-camera"></span></span>
 							<span class="input-group-addon"><span class="glyphicon glyphicon-camera"></span></span>
              		</div>
              		</div>
 					</form>
 					</form>
@@ -99,5 +103,12 @@
 						</div>
 						</div>
 	      </div>
 	      </div>
 		</footer>
 		</footer>
+		<script src="/js/jquery.js"></script>
+		<script src="/js/qfw.js"></script>
+		<script>
+		//	$("#query").keyup(function(){
+		//		imFind(this);
+		//	});
+		</script>
 </body>
 </body>
 </html>
 </html>

+ 29 - 23
core/src/web/templates/member/incmobile/list.html

@@ -12,9 +12,13 @@
 	<div class="col-xs-12">
 	<div class="col-xs-12">
 	<div class="m-searchbar">
 	<div class="m-searchbar">
 		<div class="containers">
 		<div class="containers">
-			<input type="text" class="searchtext"/>
+			<form id="searchForm" method="post">
+			<input type="text" id="query" class="searchtext"/>
 			<a class="searchbtn"><b class="glyphicon glyphicon-search"></b></a>
 			<a class="searchbtn"><b class="glyphicon glyphicon-search"></b></a>
 			<a href="javascript:" class="searchlink">高级搜索</a>
 			<a href="javascript:" class="searchlink">高级搜索</a>
+				<div id="immediately" class="immediately">
+				</div>
+			</form>
 		</div>
 		</div>
 	</div>
 	</div>
 	<div class="nav-bar hides">
 	<div class="nav-bar hides">
@@ -50,30 +54,10 @@
 	</div>
 	</div>
 	<div class="bottom" >
 	<div class="bottom" >
 		<ul class="inclist">
 		<ul class="inclist">
-			<li class="col-xs-12">
-				<table align=center>
-					<caption >
-						<div class="left">纽科伦(新乡)起重机有大师法师打发斯蒂芬限公司洛阳分公司</div>
-						<div class="note taupe">
-							续存
-						</div>
-					</caption>
-					<tr>
-						<td class="left">注册号:<span>420621NB000007X</span></td>
-						<td>法定代表人:<span>李琳</span></td>
-					</tr>
-					<tr>
-						<td class="left">成立时间:<span>2015-05-26</span></td>
-						<td>所在地:<span>湖北 襄阳市</span></td>
-					</tr>
-					<tr>
-						<td colspan=2> <hr class="list"/></td>
-					</tr>
-				</table>
-			</li>
+			
 		</ul>
 		</ul>
 	</div>
 	</div>
-	<a class="loadmore btn btn-link">加载更多</a>
+	<center><a class="loadmore btn btn-link">加载更多</a></center>
 	</div>
 	</div>
 	<script src="/js/jquery.js"></script>
 	<script src="/js/jquery.js"></script>
 	<script src="/js/qfw.js"></script>
 	<script src="/js/qfw.js"></script>
@@ -85,6 +69,28 @@
 		$(function(){
 		$(function(){
 			mCommunity().initIndex();
 			mCommunity().initIndex();
 		});
 		});
+		var data={{.T.data}}
+		var strVar = "";
+		strVar += "<li class=\"col-xs-12\"><table align=\"center\"><caption><div class=\"left\">$EntName<\/div><b class=\"$status\">$OpStateName<\/b><\/caption><tr><td class=\"left\">注册号:<span>$RegNo<\/span><\/td><td>法定代表人:<span>$LeRep<\/span><\/td><\/tr><tr><td class=\"left\">成立时间:<span>$EstDate<\/span><\/td><td>所在地:<span>$OpLocDistrict<\/span><\/td><\/tr><tr><td colspan=\"2\"><hr class=\"list\"><\/td><\/tr><\/table><\/li>";
+		if(data.length>10){
+			data=eval(data);
+			var li="";
+			for (var i=0;i<5;i++){
+				var tmp=strVar.replace("$EntName",data[i].EntName)
+										 .replace("$RegNo",data[i].RegNo)
+										 .replace("$LeRep",data[i].LeRep)
+										 .replace("$OpLocDistrict",data[i].OpLocDistrict)
+										 .replace("$EstDate",data[i].EstDate)
+										 .replace("$OpStateName",data[i].OpStateName.substr(0,2));
+				if (data[i].OpStateName!="存续"&&data[i].OpStateName.indexOf("在营")==-1){
+					 tmp=tmp.replace("$status","ent-status-r");
+				}else{
+					tmp=tmp.replace("$status","ent-status-g");
+				}
+				li=li+tmp;
+			}
+			$(".inclist").append($(li));
+		}
 	</script>
 	</script>
  </body>
  </body>
 </html>
 </html>