瀏覽代碼

feat:服务展示调整

wangkaiyue 11 月之前
父節點
當前提交
106c618319
共有 4 個文件被更改,包括 35 次插入2 次删除
  1. 29 1
      internal/service/fuwu.go
  2. 1 0
      internal/tags/init.go
  3. 4 0
      internal/tags/list.go
  4. 1 1
      resource/template/pc/fuwu_keyword_index.html

+ 29 - 1
internal/service/fuwu.go

@@ -48,7 +48,7 @@ func initFwKeyWordRoot(ctx context.Context) *seoFwKeyWordRoot {
 		mapping, nameMapping                  = map[string]*FWKeyWordNode{}, map[string]*FWKeyWordNode{}
 		allKeyword, hotKeyWord, commonKeyword []*FWKeyWordNode
 	)
-	res, err := g.DB().Query(ctx, "SELECT id,keyword,configJson FROM new_keyword_unified WHERE unifiedSign=? AND state=1", "fw")
+	res, err := g.DB().Query(ctx, "SELECT id,keyword,configJson FROM new_keyword_unified WHERE unifiedSign=? AND state=1 order by id asc", "fw")
 	if err != nil {
 		g.Log().Errorf(ctx, "initFwKeyWordRoot 获取服务异常 %v", err)
 	}
@@ -233,3 +233,31 @@ func (aRoot *seoFwKeyWordRoot) GetZimuGroup() []*ziMuGroup {
 	aRoot.ziMuGroup = finalVal
 	return finalVal
 }
+
+func (aRoot *seoFwKeyWordRoot) GetSortFw(code string, limit int) []*FWKeyWordNode {
+	var (
+		returnArr []*FWKeyWordNode
+		find      = false
+	)
+	for _, node := range aRoot.commonKeyword {
+		if node.Code == code {
+			find = true
+			continue
+		}
+		if find {
+			returnArr = append(returnArr, node)
+		}
+		if len(returnArr) >= limit {
+			return returnArr
+		}
+	}
+
+	for _, node := range aRoot.commonKeyword {
+		returnArr = append(returnArr, node)
+		if len(returnArr) >= limit {
+			return returnArr
+		}
+	}
+
+	return returnArr
+}

+ 1 - 0
internal/tags/init.go

@@ -73,6 +73,7 @@ func init() {
 
 	g.View().BindFunc("GetMiniTab", GetMiniTab)     //查询Tab数据
 	g.View().BindFunc("GetFWMiniTab", GetFWMiniTab) //查询Tab数据
+	g.View().BindFunc("GetSortFw", GetSortFw)       //查询Tab数据
 	g.View().BindFunc("MapsSub", MapsSub)           //查询Tab数据
 	g.View().BindFunc("GetSTypeParentNodes", service.JySeoSTypeRoot.GetParentNodes)
 	g.View().BindFunc("GetAllSignProjectNodes", service.JySeoSIGNRoot.GetAllProjectNodes)

+ 4 - 0
internal/tags/list.go

@@ -165,3 +165,7 @@ func GetFWMiniTab(fwCode, areaCode string, size int) []*service.InfoList {
 	}
 	return list
 }
+
+func GetSortFw(code string, limit int) []*service.FWKeyWordNode {
+	return service.JySeoFwKeyWordRoot.GetSortFw(code, limit)
+}

+ 1 - 1
resource/template/pc/fuwu_keyword_index.html

@@ -74,7 +74,7 @@
                         <h3 class="aside-card-title">服务采购推荐</h3>
                     </header>
                     <main class="aside-card-content city-aside-list" style="padding: 20px 6px 0 6px;">
-                        {{range $v:=$global.commonKeyword}}
+                        {{range $v:=GetSortFw $global.fwNode.Code 20}}
                             <a class="city-aside-item ellipsis cms-link" target="_blank" href="/fuwu/{{$v.Code}}.html" title="{{$v.KeyWord}}">
                                 <div class="tags-card-item-title ellipsis">{{$v.KeyWord}}</div>
                             </a>