|
|
@@ -24088,13 +24088,47 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
* B2C搜索
|
|
|
*/
|
|
|
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'
|
|
|
+ ).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'})
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).error(function(response) {
|
|
|
+ console.log(response)
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
AccountEnterprise.getB2cUrl({}, function(data) {
|
|
|
$scope.toB2cLink = data.url
|
|
|
- // 热门搜索跳转
|
|
|
- angular.forEach($scope.hotwords, function (value, key) {
|
|
|
- $scope.hotwords[key].url = $scope.toB2cLink + '/' + value.url
|
|
|
- })
|
|
|
- })
|
|
|
+ hotBrand();
|
|
|
+ });
|
|
|
+
|
|
|
// 默认搜索类型
|
|
|
$scope.searchType = 'component';
|
|
|
$scope.placeholderSearch = '请输入型号';
|
|
|
@@ -24188,13 +24222,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.associateEnter = false;
|
|
|
};
|
|
|
|
|
|
- // 热词
|
|
|
- $scope.hotwords = [{name : 'SCT2080KEC', url : 'product/component/1100400300009990/', id : 0},
|
|
|
- {name : '电池组', url : 'product/kinds/346', id : 1},
|
|
|
- {name : 'Vishay',url : 'product/brand/30327265e42a871be050007f01003d96/', id : 2},
|
|
|
- {name : 'Panasonic Battery', url : 'product/brand/30327265e4e7871be050007f01003d96/', id : 3}];
|
|
|
-
|
|
|
-
|
|
|
// 跳转到B2C
|
|
|
$scope.b2cLink = function (url) {
|
|
|
window.location.href = $scope.toB2cLink + url;
|