소스 검색

搜索优化

shish 2 년 전
부모
커밋
76a89d3f55
2개의 변경된 파일58개의 추가작업 그리고 48개의 파일을 삭제
  1. 51 47
      hdApp/src/mixins/cgProduct.js
  2. 7 1
      hdApp/src/pagesPurchase/ghsProduct.vue

+ 51 - 47
hdApp/src/mixins/cgProduct.js

@@ -944,56 +944,60 @@ export default {
 				this.suitScrollPushList();
 			}
 		},
-		searchFn() {
+		searchFn(limit=1) {
 			let list = copyObject(this.productInfo);
 			if(!this.$util.isEmpty(this.py)){
-				//大于等于2个字符才开始搜索 shish 20210622
-				if(this.py.length <=1){
-					return
-				}
-				//红色粉色紫色绿色白色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
-				if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('粉色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('红色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('黄色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('紫色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('绿色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('白色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('cs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('橙色') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.indexOf('银色') == 0 && this.py.length <= 2){
-					return
+
+				if(limit == 1){
+					//大于等于2个字符才开始搜索 shish 20210622
+					if(this.py.length <=1){
+						return
+					}
+					//红色粉色紫色绿色白色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
+					if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('粉色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('红色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('黄色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('紫色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('绿色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('白色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.toLocaleLowerCase().indexOf('cs') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('橙色') == 0 && this.py.length <= 2){
+						return
+					}
+					if(this.py.indexOf('银色') == 0 && this.py.length <= 2){
+						return
+					}
 				}
+
 				let commonChildList = [];
 				list.forEach(ele => {
 					if (!this.$util.isEmpty(ele.child)) {

+ 7 - 1
hdApp/src/pagesPurchase/ghsProduct.vue

@@ -23,7 +23,7 @@
 				<button class="admin-button-com middle blue" @click="selectFlowerNumFn()">图片分类</button>
 			</view>
 			<view class="search-bar">
-				<app-search-module v-model="py" placeholder="拼音首字母也可以搜索" @input="searchFn" />
+				<app-search-module v-model="py" placeholder="拼音首字母也可以搜索" @input="goSearchFn" />
 			</view>
 			<view style="padding:0 0upx 0 20upx;" >
 				<button class="admin-button-com middle blue" v-if="ghsInfo.presell && ghsInfo.presell == 1" style="background-color:green;border:1upx solid green;" @click="aheadCg(ghsInfo)">预订花材</button>
@@ -357,6 +357,12 @@ export default {
 
 	},
 	methods: {
+		goSearchFn(){
+			let ghsShopId = this.ghsInfo.shopId ? this.ghsInfo.shopId : 0
+			//源花汇暂时开放一个字也能搜索
+			let limit = ghsShopId == 10649 ? 0 : 1
+			this.searchFn(limit)
+		},
 		hideCartItem(){
 			this.cartItemShow = false
 		},