shish 2 лет назад
Родитель
Сommit
62a5019c21
2 измененных файлов с 106 добавлено и 93 удалено
  1. 104 91
      hdApp/src/mixins/cgProduct.js
  2. 2 2
      hdApp/src/pagesPurchase/ghsProduct.vue

+ 104 - 91
hdApp/src/mixins/cgProduct.js

@@ -24,7 +24,8 @@ export default {
 			top_list:'',
 			filterProductInfo:'',
 			//当前页面默认使用的单位 0大单位 1小单位
-			globalUnitType:0
+			globalUnitType:0,
+			globalItemList:[]
 		};
 	},
 	onLoad(options) {
@@ -240,7 +241,8 @@ export default {
 			try {
 				let params = { py: this.py, id:id, shopId:shopId, showAll:showAll }
 				const { data } = await getGhsProductListV2(params);
-				this.productInfo = data;
+				this.productInfo = data.classItem||[];
+				this.globalItemList = data.itemList || []
 				if(this.pageType == 'cg' || this.pageType == 'bookCg'){
 					let targetId = this.option.id ? this.option.id : 0
 					let currentInfo = uni.getStorageSync('selectList'+this.pageType+'_ghs_'+targetId)
@@ -968,101 +970,112 @@ export default {
 			}
 		},
 		searchFn(limit=1) {
-			let list = copyObject(this.productInfo);
-			if(!this.$util.isEmpty(this.py)){
-
-				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)) {
-						ele.child.forEach(obj => {
-							let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
-							let hasPy = false
-							if(hasName == false){
-								let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
-								hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
-							}
-							if (hasName || hasPy) {
-								if(this.$util.isEmpty(commonChildList)){
-									commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,isActive:true,child:[obj]}];
-								}else{
-									commonChildList.forEach(res => {
-										if(res.classId==ele.classId){
-											res.child.push(obj)
-										}else{
-											commonChildList.push({classId: ele.classId, className: ele.className,isActive:true,child:[obj]});
-										}
-									})
-								}
-							}
-						});
-					}
-				})
-				list = this.$util.unique(commonChildList)
-				this.filterProductInfo = list;
-				this.classIndex = 0;
-				this.scroll_into_view = 'class_'+0;
-			}else{
+			let list = this.globalItemList
+			if(this.$util.isEmpty(this.py)){
 				this.filterProductInfo = '';
 				this.classIndex = 0;
 				this.scroll_into_view = 'class_'+0;
 				this.scrollPushList();
 			}
-		},
-
+			var reg = /^[0-9a-zA-Z]*$/g
+			let notChinese = reg.test(this.py) == true ? true : false
+			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
+				}
+			}
 
-		/**
-			* 请求课程数据
-			*/
+			//将已选的花材按productId键名组合
+			let selectListData = []
+			if(!this.$util.isEmpty(this.selectList)){
+				this.selectList.forEach((i)=>{
+					selectListData[i.id] = i
+				})
+			}
+			let filterItemData = [];
+			list.forEach(currentItem => {
+				//组合已记忆已选择的花材
+				let currentPId = currentItem.id
+				let selectProduct = selectListData[currentPId] || []
+				if(!this.$util.isEmpty(selectProduct)){
+					currentItem.bigCount = selectProduct.bigCount || 0
+					currentItem.userPrice = selectProduct.userPrice || 0
+					currentItem.smallCount = selectProduct.smallCount || 0
+				}else{
+					currentItem.bigCount = 0
+					currentItem.userPrice = 0
+					currentItem.smallCount = 0
+				}
+				let has = false
+				if (notChinese){
+					let elePy = (currentItem.py && currentItem.py.toLocaleUpperCase()) || "";
+					has = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0 ? true : false
+				}else{
+					has = currentItem.name && currentItem.name.indexOf(this.py) >= 0 ? true : false
+				}
+				if (has) {
+					if(this.$util.isEmpty(filterItemData)){
+						filterItemData = [{classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]}]
+					}else{
+						filterItemData.forEach(res => {
+							if(res.classId==currentItem.classId){
+								res.child.push(currentItem)
+							}else{
+								filterItemData.push({classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]})
+							}
+						})
+					}
+				}
+			})
+			let searchList = this.$util.unique(filterItemData)
+			this.filterProductInfo = searchList;
+			this.classIndex = 0;
+			this.scroll_into_view = 'class_'+0;
+		},
 		async initPxClassData() {
 			try {
 				const { data } = await getPxClassDataApi({pageSize:50});

+ 2 - 2
hdApp/src/pagesPurchase/ghsProduct.vue

@@ -532,7 +532,7 @@ export default {
 					//获取供货商花材
 					if(id>0){
 						this.visitMall(id)
-						this.initGhsData(id,shopId,0)
+						this.initGhsDataV2(id,shopId,0)
 						//不是新人或者已经下过单的或者活动没有开启不显示新人红包
 						if(this.ghsInfo.hasCg == 1 || this.ghsInfo.new == 0 || this.ghsInfo.xrFl == 0 || this.ghsInfo.sendNewGift == 1){
 							this.isNewCustom = false
@@ -548,7 +548,7 @@ export default {
 			} else {
 				this.ghsId = this.option.id
 				//获取供货商花材
-				this.initGhsData(id,shopId,0);
+				this.initGhsDataV2(id,shopId,0)
 				getGhsDataApi({id: this.option.id}).then(res => {
 					this.ghsInfo = res.data
 					this.shopId = res.data.shopId