Browse Source

处理买卖家中心和帐户中心的头部搜索部分

Administrator 7 years ago
parent
commit
04197bf7f5

+ 19 - 1
src/main/webapp/resources/css/user/base.css

@@ -271,10 +271,28 @@ select {
 }
 }
 
 
 .user_center .search-right {
 .user_center .search-right {
-    margin-top: 22px;
+    margin-top: 32px;
     position: relative;
     position: relative;
 }
 }
 
 
+.user_center .search-right .search-list{
+    position:absolute;
+    left:5px;
+    top:-22px;
+}
+.user_center .search-right .search-list ul li{
+    cursor:pointer;
+    line-height: 22px;
+    height:22px;
+    padding: 0 10px;
+    font-size: 14px;
+    color:#fff;
+}
+.user_center .search-right .search-list ul li.active{
+    color:#4a71c6;
+    background: #fff;
+}
+
 .user_center .search-right input {
 .user_center .search-right input {
     display: inline-block;
     display: inline-block;
     line-height: 36px;
     line-height: 36px;

+ 20 - 1
src/main/webapp/resources/css/vendor/base.css

@@ -235,9 +235,28 @@ select {
     display: inline-block;
     display: inline-block;
 }
 }
 .user_center .search-right {
 .user_center .search-right {
-    margin-top: 22px;
+    margin-top: 32px;
     position: relative;
     position: relative;
 }
 }
+
+.user_center .search-right .search-list{
+    position:absolute;
+    left:5px;
+    top:-22px;
+}
+.user_center .search-right .search-list ul li{
+    cursor:pointer;
+    line-height: 22px;
+    height:22px;
+    padding: 0 10px;
+    font-size: 14px;
+    color:#fff;
+}
+.user_center .search-right .search-list ul li.active{
+    color:#4a71c6;
+    background: #fff;
+}
+
 .user_center .search-right input {
 .user_center .search-right input {
     display: inline-block;
     display: inline-block;
     line-height: 36px;
     line-height: 36px;

+ 80 - 61
src/main/webapp/resources/js/common/controllers/commonCtrls.js

@@ -258,70 +258,87 @@ define([ 'app/app' ], function(app) {
 
 
 	// 搜索框Ctrl
 	// 搜索框Ctrl
 	app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', function($scope, $http, $rootScope, SessionService) {
 	app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', function($scope, $http, $rootScope, SessionService) {
-		$scope.searchType = 'original';// 搜索类型
-		$scope.searchType = {
-			original: false,
-			inaction: false,
-			proffing: false,
-			brand: false,
-			isCmp: function() {
-				var me = this;
-				return me.original || me.inaction || me.proffing;
-			}
-		};
-		if(SessionService.get('brand')) {
-			$scope.searchType.brand = true;
-		}
+		// $scope.searchType = {
+		// 	original: false,
+		// 	inaction: false,
+		// 	proffing: false,
+		// 	brand: false,
+		// 	isCmp: function() {
+		// 		var me = this;
+		// 		return me.original || me.inaction || me.proffing;
+		// 	}
+		// };
+        // 默认搜索类型
+        $scope.searchType = 'component';
 
 
-		var componentSearchType = SessionService.get('component');
-		if(componentSearchType) {
-			$scope.searchType = angular.fromJson(componentSearchType);
-			$scope.searchType.isCmp = function() {
-				var me = this;
-				return me.original || me.inaction || me.proffing;
-			}
-		}
+		// 选搜索类型
+        $scope.setTypeClick = function (type) {
+        	$scope.searchType = type
+            $scope.search()
+		};
+
+        // 搜索
+        $scope.search = function() {
+            if($scope.keyword) {
+                SessionService.set('brand', true);
+                SessionService.unset('component');
+                window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=' + $scope.searchType;
+            }
+        };
 
 
-		// 点击搜索库存、样品、呆滞
-		$scope.cmpTypeClick = function() {
-			if($scope.searchType.isCmp()) {
-				$scope.searchType.brand = false;
-			}
-		};
+		// if(SessionService.get('brand')) {
+		// 	$scope.searchType.brand = true;
+		// }
+        //
+		// var componentSearchType = SessionService.get('component');
+		// if(componentSearchType) {
+		// 	$scope.searchType = angular.fromJson(componentSearchType);
+		// 	$scope.searchType.isCmp = function() {
+		// 		var me = this;
+		// 		return me.original || me.inaction || me.proffing;
+		// 	}
+		// }
+
+		// // 点击搜索库存、样品、呆滞
+		// $scope.cmpTypeClick = function() {
+		// 	if($scope.searchType.isCmp()) {
+		// 		$scope.searchType.brand = false;
+		// 	}
+		// };
 
 
 		// 点击搜索品牌
 		// 点击搜索品牌
-		$scope.brandTypeClick = function() {
-			if($scope.searchType.brand) {
-				$scope.searchType.original = false;
-				$scope.searchType.inaction = false;
-				$scope.searchType.proffing = false;
-			}
-		};
+		// $scope.brandTypeClick = function() {
+		// 	if($scope.searchType.brand) {
+		// 		$scope.searchType.original = false;
+		// 		$scope.searchType.inaction = false;
+		// 		$scope.searchType.proffing = false;
+		// 	}
+		// };
 
 
 		// 选搜索类型
 		// 选搜索类型
-		$scope.setSearchType = function(t) {
-			$scope.searchType = t;
-		};
+		// $scope.setSearchType = function(t) {
+		// 	$scope.searchType = t;
+		// };
 
 
 		// 搜索
 		// 搜索
-		$scope.search = function() {
-			if($scope.keyword) {
-				if($scope.searchType.brand) {
-					SessionService.set('brand', true);
-					SessionService.unset('component');
-					window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=brand';
-				}else if($scope.searchType.isCmp()){
-					SessionService.set('component', angular.toJson($scope.searchType));
-					SessionService.unset('brand');
-					window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=component';
-				}else {
-					SessionService.unset('component');
-					SessionService.unset('brand');
-					window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=all';
-				}
-
-			}
-		};
+		// $scope.search = function() {
+		// 	if($scope.keyword) {
+		// 		if($scope.searchType === 'brand') {
+		// 			SessionService.set('brand', true);
+		// 			SessionService.unset('component');
+		// 			window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=brand';
+		// 		}else if($scope.searchType.isCmp()){
+		// 			SessionService.set('component', angular.toJson($scope.searchType));
+		// 			SessionService.unset('brand');
+		// 			window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=component';
+		// 		}else {
+		// 			SessionService.unset('component');
+		// 			SessionService.unset('brand');
+		// 			window.location.href = 'search?w=' + encodeURI($scope.keyword) + '&type=all';
+		// 		}
+        //
+		// 	}
+		// };
 
 
 		// 搜索框获得焦点,显示联想框
 		// 搜索框获得焦点,显示联想框
 		$scope.onFocus = function() {
 		$scope.onFocus = function() {
@@ -356,17 +373,19 @@ define([ 'app/app' ], function(app) {
 		$scope.onChange = function() {
 		$scope.onChange = function() {
 			if ($scope.keyword) {
 			if ($scope.keyword) {
 				var params = {
 				var params = {
-					keyword: $scope.keyword
+					keyword: $scope.keyword,
+					type: $scope.searchType
 				};
 				};
-				if($rootScope.userInfo) {
-					params.userUU = $rootScope.userInfo.userUU;
-				}
+				// if($rootScope.userInfo) {
+				// 	params.userUU = $rootScope.userInfo.userUU;
+				// }
 				$http.get('search/similarKeywords', {
 				$http.get('search/similarKeywords', {
 					params : params
 					params : params
 				}).success(function(data){
 				}).success(function(data){
 					$scope.associates = data;// 联想词数组
 					$scope.associates = data;// 联想词数组
+					console.log('1', data)
 				}).error(function(response) {
 				}).error(function(response) {
-
+					console.log(response)
 				});
 				});
 			} else {
 			} else {
 				$scope.associates = [];// 联想词数组
 				$scope.associates = [];// 联想词数组

+ 8 - 0
src/main/webapp/resources/view/sso/header.html

@@ -219,6 +219,14 @@
             </ul>
             </ul>
         </div>
         </div>
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
+            <div class="search-list">
+                <ul class="list-inline">
+                    <li ng-class="{'active': searchType === 'component'}" ng-click="setTypeClick('component')">型号</li>
+                    <li ng-class="{'active': searchType === 'product'}" ng-click="setTypeClick('product')">物料名称</li>
+                    <li ng-class="{'active': searchType === 'store'}" ng-click="setTypeClick('store')">卖家</li>
+                    <li ng-class="{'active': searchType === 'brand'}" ng-click="setTypeClick('brand')">品牌</li>
+                </ul>
+            </div>
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <a class="seek" ng-click="search()">搜索</a>
             <a class="seek" ng-click="search()">搜索</a>
             <ul class="association" ng-show="associate || associateEnter"  ng-class="{'none': !associate || !associateEnter}" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()">
             <ul class="association" ng-show="associate || associateEnter"  ng-class="{'none': !associate || !associateEnter}" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()">

+ 8 - 0
src/main/webapp/resources/view/usercenter/header.html

@@ -219,6 +219,14 @@
             </ul>
             </ul>
         </div>
         </div>
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
+            <div class="search-list">
+                <ul class="list-inline">
+                    <li ng-class="{'active': searchType === 'component'}" ng-click="setTypeClick('component')">型号</li>
+                    <li ng-class="{'active': searchType === 'product'}" ng-click="setTypeClick('product')">物料名称</li>
+                    <li ng-class="{'active': searchType === 'store'}" ng-click="setTypeClick('store')">卖家</li>
+                    <li ng-class="{'active': searchType === 'brand'}" ng-click="setTypeClick('brand')">品牌</li>
+                </ul>
+            </div>
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <a class="seek" ng-click="search()">搜索</a>
             <a class="seek" ng-click="search()">搜索</a>
             <ul class="association" ng-show="associate || associateEnter"  ng-class="{'none': !associate || !associateEnter}" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()">
             <ul class="association" ng-show="associate || associateEnter"  ng-class="{'none': !associate || !associateEnter}" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()">

+ 8 - 1
src/main/webapp/resources/view/vendor/header.html

@@ -216,6 +216,14 @@
             </ul>
             </ul>
         </div>
         </div>
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
         <div id="mall-search" class="search-right fr" ng-controller="SearchCtrl">
+            <div class="search-list">
+                <ul class="list-inline">
+                    <li ng-class="{'active': searchType === 'component'}" ng-click="setTypeClick('component')">型号</li>
+                    <li ng-class="{'active': searchType === 'product'}" ng-click="setTypeClick('product')">物料名称</li>
+                    <li ng-class="{'active': searchType === 'store'}" ng-click="setTypeClick('store')">卖家</li>
+                    <li ng-class="{'active': searchType === 'brand'}" ng-click="setTypeClick('brand')">品牌</li>
+                </ul>
+            </div>
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <input type="text" ng-model="keyword" ng-change="onChange()" ng-search="search()" ng-focus="onFocus()" ng-blur="onBlur()" ng-keyup="onKeyup()"placeholder="品牌/物料名称/型号" />
             <a class="seek" ng-click="search()">搜索</a>
             <a class="seek" ng-click="search()">搜索</a>
             <ul class="association" ng-show="associate || associateEnter" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()" ng-class="{'none': !associate || !associateEnter}">
             <ul class="association" ng-show="associate || associateEnter" ng-mouseenter="onAssociateEnter()" ng-mouseleave="onAssociateLeave()" ng-class="{'none': !associate || !associateEnter}">
@@ -228,7 +236,6 @@
                 <li class="similar-title" ng-if="associates.component && associates.component.length > 0">型号:</li>
                 <li class="similar-title" ng-if="associates.component && associates.component.length > 0">型号:</li>
                 <li ng-repeat="as in associates.component" ng-bind="as.code" ng-class="{'active': $index==selectIndex}"
                 <li ng-repeat="as in associates.component" ng-bind="as.code" ng-class="{'active': $index==selectIndex}"
                     ng-click="onAssociateClick(as.code)"></li>
                     ng-click="onAssociateClick(as.code)"></li>
-
             </ul>
             </ul>
         </div>
         </div>
     </div>
     </div>