Browse Source

处理热门搜索接口改CMS

wangcz 7 years ago
parent
commit
0a8f29fe18

+ 6 - 30
src/main/webapp/resources/js/index/app.js

@@ -24219,44 +24219,20 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
      */
     app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', 'AccountEnterprise', function($scope, $http, $rootScope, SessionService, AccountEnterprise) {
         $scope.hotwords = new Array();
-        var hasBrand = false;
-        var hasComponent = false;
 
-        // 热词搜索品牌
-        var hotBrand = function () {
-            $http.get($scope.toB2cLink + '/api/product/brand/mostSearchBrands'
+        // 热词搜索
+        var hotSearchList = function () {
+            $http.get('https://mall.usoftchina.com/cmsApi?method=queryContentPage&module=index_hotModels&orderBy=order_number%20ASC'
             ).success(function(data){
-                hasBrand = true;
-
-                angular.forEach(data, function (value) {
-                    $scope.hotwords.push({name: value.nameEn, url: $scope.toB2cLink + '/search?w='+ value.nameEn +'&type=brand'})
-                })
-                if (hasBrand) {
-                    hotComponent();
-                }
-            }).error(function(response) {
-                console.log(response)
-            });
-        };
-
-        // 热词搜索器件
-        var hotComponent = function () {
-            $http.get($scope.toB2cLink + '/api/product/component/mostSearchComponent'
-            ).success(function(data){
-                hasComponent = true;
-                if (hasBrand && hasComponent) {
-                    angular.forEach(data, function (value) {
-                        $scope.hotwords.push({name: value.code, url: $scope.toB2cLink + '/search?w='+ value.code +'&type=component'})
-                    })
-                }
+                $scope.hotwords = data.data
             }).error(function(response) {
                 console.log(response)
             });
         };
 
         AccountEnterprise.getB2cUrl({}, function(data) {
-            $scope.toB2cLink = data.url
-            hotBrand();
+            $scope.toB2cLink = data.url;
+            hotSearchList();
         });
 
         // 默认搜索类型

+ 1 - 1
src/main/webapp/resources/tpl/index/common/header.html

@@ -217,7 +217,7 @@
                             <div class="active-search">
                                 <ul class="list-untyled active-search-body" style="padding: 0;">
                                     <li class="active-search-item">热门搜索</li>
-                                    <li class="active-search-item" ng-repeat="hw in hotwords"><a ng-href="{{hw.url}}" ng-bind="hw.name"></a></li>
+                                    <li class="active-search-item" ng-repeat="hw in hotwords"><a ng-href="{{hw.detailsLink}}" ng-bind="hw.title"></a></li>
                                 </ul>
                             </div>
                         </div>