shish 2 лет назад
Родитель
Сommit
d467f46d8d

+ 0 - 1
ghsApp/src/pagesOrder/detail.vue

@@ -382,7 +382,6 @@
 
 	</view>
 </template>
-
 <script>
 import { mapGetters } from "vuex";
 import stepStatus from "./components/stepStatus";

+ 4 - 0
hdApp/src/api/product/index.js

@@ -106,6 +106,10 @@ export const  pxClassDel = data => {
 	return https.get('/product/ghs-item', data)
 }
 
+export const getGhsProductListV2 = data => {
+	return https.get('/product/ghs-item-v2', data)
+}
+
 export const getProductDetail = data => {
 	return https.get("/product/detail", data);
 };

+ 161 - 110
hdApp/src/mixins/cgProduct.js

@@ -1,4 +1,4 @@
-import { getGoodsDataApi,getProductDataApi,getPxClassDataApi,getGhsProductList } from "@/api/product";
+import { getGoodsDataApi,getProductDataApi,getPxClassDataApi,getGhsProductList,getGhsProductListV2 } from "@/api/product";
 import { mapGetters, mapActions } from "vuex";
 import { copyObject } from "@/utils/util";
 export default {
@@ -24,7 +24,8 @@ export default {
 			top_list:'',
 			filterProductInfo:'',
 			//当前页面默认使用的单位 0大单位 1小单位
-			globalUnitType:0
+			globalUnitType:0,
+			globalItemList:[]
 		};
 	},
 	onLoad(options) {
@@ -236,7 +237,31 @@ export default {
 				this.customData.smallCount = null
 			}
 		},
-		//采购时请求供货商花材
+		async initGhsDataV2(id,shopId,showAll) {
+			try {
+				let params = { py: this.py, id:id, shopId:shopId, showAll:showAll }
+				const { data } = await getGhsProductListV2(params);
+				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)
+					if(!this.$util.isEmpty(currentInfo)){
+						this.setSelectInfoByType({ type: this.pageType, info: currentInfo })
+					}else{
+						//临时解决方案
+						this.resetSelectInfoByType(this.pageType);
+					}
+				}
+				this.classIndex = 0;
+				this.scroll_into_view = 'class_0';
+				this.scrollPushList();
+			} catch (error) {
+				uni.hideLoading()
+			} finally {
+				uni.hideLoading()
+			}
+		},
 		async initGhsData(id,shopId,showAll) {
 			//extendInfo调用时的扩展参数,如shopId
 			try {
@@ -323,18 +348,30 @@ export default {
 				let node2 = this.top_list[i+1];
 				if(node2 && top_page >= node1 && top_page < node2){
 					this.classIndex = i;
-					this.filterProductInfo[this.classIndex].isActive = true;
-					this.filterProductInfo[this.classIndex+1].isActive = true;
+					if(this.filterProductInfo[this.classIndex]){
+						this.filterProductInfo[this.classIndex].isActive = true;
+					}
+					if(this.filterProductInfo[this.classIndex+1]){
+						this.filterProductInfo[this.classIndex+1].isActive = true;
+					}
 					if(this.filterProductInfo[this.classIndex+1].child.length<5){
-						this.filterProductInfo[this.classIndex+2].isActive = true;
+						if(this.filterProductInfo[this.classIndex+2]){
+							this.filterProductInfo[this.classIndex+2].isActive = true;
+						}
 					}
 					break;
 				}else if(node2 && top_page === node2){
 					this.classIndex = i + 1;
-					this.filterProductInfo[this.classIndex].isActive = true;
-					this.filterProductInfo[this.classIndex+1].isActive = true;
+					if(this.filterProductInfo[this.classIndex]){
+						this.filterProductInfo[this.classIndex].isActive = true;
+					}
+					if(this.filterProductInfo[this.classIndex+1]){
+						this.filterProductInfo[this.classIndex+1].isActive = true;
+					}
 					if(this.filterProductInfo[this.classIndex+1].child.length<5){
-						this.filterProductInfo[this.classIndex+2].isActive = true;
+						if(this.filterProductInfo[this.classIndex+2]){
+							this.filterProductInfo[this.classIndex+2].isActive = true;
+						}
 					}
 					break;
 				}
@@ -611,8 +648,6 @@ export default {
 				}
 			}
 			this.setSelectInfoByType({ type: this.pageType, info: list });
-
-			console.log('this.selectList','减少花材之后:',this.selectList)
 			//记忆已经选择的花材
 			this.rememberProduct()
 		},
@@ -643,10 +678,7 @@ export default {
 		},
 		//多风格-添加商品
 		addGoodsEvent(item) {
-			console.log(item,'itemitem')
 			const list = this.selectList;
-			//过滤空数据
-			// if(item.bigCount==0||!item.bigCount){return}
 			let has = false;
 			for (let index = 0; index < list.length; index++) {
 				const element = list[index];
@@ -868,7 +900,6 @@ export default {
 			const query = uni.createSelectorQuery().in(this); //获得实力
 			//获取多个节点方式
 			query.selectAll(".suitSelectAll").boundingClientRect(data=>{
-				// console.log(data); //得到class类名为  selectAll的数组集合
 				this.suit_top_list = data.map(item=>{
 					return Math.ceil(item.top);
 				});
@@ -878,20 +909,27 @@ export default {
 		suit_async_detail_msg(options){
 			//options  为滚动信息。  options.detail.scrollTop  值为相对于scroll-view。
 			let top_page = options.detail.scrollTop + this.suit_top_list[0];
-
 			for(let i = 0;i < this.suit_top_list.length; i++){
 				let node1 = this.suit_top_list[i];
 				let node2 = this.suit_top_list[i+1];
 				if(node2 && top_page >= node1 && top_page < node2){
 					this.suitClassIndex = i;
-					this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
-					this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
+					if(this.suitFilterProductInfo[this.suitClassIndex]){
+						this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
+					}
+					if(this.suitFilterProductInfo[this.suitClassIndex+1]){
+						this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
+					}
 					// this.suitScrollPushList();
 					break;
 				}else if(node2 && top_page === node2){
 					this.suitClassIndex = i + 1;
-					this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
-					this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
+					if(this.suitFilterProductInfo[this.suitClassIndex]){
+						this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
+					}
+					if(this.suitFilterProductInfo[this.suitClassIndex+1]){
+						this.suitFilterProductInfo[this.suitClassIndex+1].isActive = true;
+					}
 					// this.suitScrollPushList();
 					break;
 				}
@@ -899,7 +937,9 @@ export default {
 		},
 		suit_scroll_bottom(){
 			this.suitClassIndex = this.suitFilterProductInfo.length-1
-			this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
+			if(this.suitFilterProductInfo[this.suitClassIndex]){
+				this.suitFilterProductInfo[this.suitClassIndex].isActive = true;
+			}
 			// this.suitScrollPushList();
 		},
 		//搜索对应花材
@@ -945,101 +985,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});

+ 7 - 3
hdApp/src/pagesPurchase/bookProduct.vue

@@ -22,7 +22,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" @click="delMemory()">清除已选</button>
@@ -320,6 +320,10 @@ export default {
 
 	},
 	methods: {
+		goSearchFn(){
+			let limit = 1
+			this.searchFn(limit)
+		},
 		getReadMe(info){
 			this.$util.pageTo({url:'/pagesPurchase/bookReadMe?shopId='+info.shopId})
 		},
@@ -454,7 +458,7 @@ export default {
 					//获取供货商花材
 					if(id>0){
 						this.visitMall(id)
-						this.initGhsData(id,shopId,1)
+						this.initGhsDataV2(id,shopId,1)
 						//不是新人或者已经下过单的或者活动没有开启不显示新人红包
 						if(this.ghsInfo.hasCg == 1 || this.ghsInfo.new == 0 || this.ghsInfo.xrFl == 0 || this.ghsInfo.sendNewGift == 1){
 							this.isNewCustom = false
@@ -469,7 +473,7 @@ export default {
 			} else {
 				this.ghsId = this.option.id
 				//获取供货商花材
-				this.initGhsData(id,shopId,1)
+				this.initGhsDataV2(id,shopId,1)
 				getGhsDataApi({id: this.option.id}).then(res => {
 					this.ghsInfo = res.data
 					this.shopId = res.data.shopId

+ 3 - 3
hdApp/src/pagesPurchase/components/bookItem.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="item-cmd_bx" @click="customNum(info.variety)">
 		<view class="img_bx" style="background:#eeeeee" @click.stop="showBigImg">
-			<image :src="info.cover" lazy-load="true" :lazy-load-margin="0"></image>
+
 		</view>
 		<view class="cmd-info_bx">
 			<view class="tit" >
@@ -12,10 +12,10 @@
 				<view>
 					<view class="flex-space" style="color:#333333;position:absolute;top:13upx;">
 						<block v-if="info.ratioType == 0">
-						{{info.ratio}}{{info.smallUnit}}/{{info.bigUnit}}
+						{{info.ratio}}{{info.smallUnit}}
 						</block>
 						<block v-else>
-						若干{{info.smallUnit}}/{{info.bigUnit}}
+						若干{{info.smallUnit}}
 						</block>
 					</view>
 					<view class="price" style="font-weight:bold;font-size:23upx;">

+ 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