|
@@ -21,8 +21,23 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
+type EntInfo struct {
|
|
|
+ _id string
|
|
|
+ EntName string //企业名称
|
|
|
+ RegNo string //注册号
|
|
|
+ LeRep string // 法定代表人
|
|
|
+ OpLocDistrict string //区域代码
|
|
|
+ EstDate string //注册时间
|
|
|
+ OpStateName string //状态名称
|
|
|
+}
|
|
|
+
|
|
|
//企业社区首页
|
|
|
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{}
|
|
|
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) != "")) {
|
|
|
//n.T["uri"] = n.Uri()
|
|
|
-
|
|
|
+ ismobile := strings.Index(n.Header("User-Agent"), "Mobile")
|
|
|
if len(param) == 0 {
|
|
|
//请求是表单提交,走的查询
|
|
|
//拼装查询对象
|
|
@@ -140,7 +155,7 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
}
|
|
|
//查询生成列表数据
|
|
|
data, pagination := searhWebContentent(querymap, n, reqType)
|
|
|
-
|
|
|
+ log.Println(len(*data))
|
|
|
//查询送积分
|
|
|
queryStr := querymap["query"]
|
|
|
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 {
|
|
|
//反转生成map
|
|
|
paramstr := param[1:]
|
|
@@ -163,9 +196,26 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
|
|
|
querymap := map[string]string{}
|
|
|
|
|
|
json.Unmarshal(bs, &querymap)
|
|
|
- log.Println(querymap)
|
|
|
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
|
|
|
//} else {
|
|
@@ -481,7 +531,6 @@ func searhWebContentent(querymap map[string]string, n *Search, reqType string) (
|
|
|
if client == nil {
|
|
|
return nil, nil
|
|
|
}
|
|
|
- log.Println(query)
|
|
|
searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
|
|
|
if err != nil {
|
|
|
return nil, nil
|