Просмотр исходного кода

获取限购花材信息(仅 limitBuy > 0 的项参与校验)

shizhongqi 2 месяцев назад
Родитель
Сommit
41ca3c4be2
2 измененных файлов с 52 добавлено и 38 удалено
  1. 27 20
      hdApp/src/pagesPurchase/ghsProduct.vue
  2. 25 18
      mallApp/src/pages/item/item.vue

+ 27 - 20
hdApp/src/pagesPurchase/ghsProduct.vue

@@ -680,26 +680,33 @@ export default {
 					return
 				}
                 
-				// 请求后端接口,获取限购花材信息
-				// let newList = list.map(item => {
-				// 	return {
-				// 		id: item.id,
-				// 		bigCount: item.bigCount,
-				// 		//smallCount: item.smallCount
-				// 	}
-				// })
-				// getLimitBuyInfo({ghsId: this.options.id, list: newList}).then(res => {
-				// 	const limitBuyInfo = Array.isArray(res.data) ? res.data : []
-				// 	const warnList = limitBuyInfo.filter(item => item.specialPrice === false && item.reachLimitBuyNum === true)
-				// 	if(warnList.length > 0){
-				// 		this.limitBuyWarnList = warnList
-				// 		this.cartItemShow = true
-				// 		this.$msg("有花材超出限购")
-				// 		return
-				// 	}
-				// 	this.limitBuyWarnList = []
-				// 	this.setLimitBuyInfoByType({ type: this.pageType, info: limitBuyInfo });
-				// })
+				// 请求后端接口,获取限购花材信息(仅 limitBuy > 0 的项参与校验)
+				let newList = list
+					.filter(item => Number(item.limitBuy) > 0)
+					.map(item => {
+						return {
+							id: item.id,
+							bigCount: item.bigCount,
+							//smallCount: item.smallCount
+						}
+					})
+				if (newList.length > 0) {
+					getLimitBuyInfo({ghsId: this.options.id, list: newList}).then(res => {
+						const limitBuyInfo = Array.isArray(res.data) ? res.data : []
+						const warnList = limitBuyInfo.filter(item => item.specialPrice === false && item.reachLimitBuyNum === true)
+						if(warnList.length > 0){
+							this.limitBuyWarnList = warnList
+							this.cartItemShow = true
+							this.$msg("有花材超出限购")
+							return
+						}
+						this.limitBuyWarnList = []
+						this.setLimitBuyInfoByType({ type: this.pageType, info: limitBuyInfo });
+					})
+				} else {
+					this.limitBuyWarnList = []
+					this.setLimitBuyInfoByType({ type: this.pageType, info: [] });
+				}
 				this.setSelectInfoByType({ type: this.pageType, info: list });
 				this.pageTo({url: '/admin/billing/affirmGhs?id='+this.options.id,type: 2})
 			} else {

+ 25 - 18
mallApp/src/pages/item/item.vue

@@ -513,24 +513,31 @@ export default {
 					this.$msg("缺少店铺信息")
 					return
 				}
-				// let newList = list.map(item => {
-				// 	return {
-				// 		id: item.id,
-				// 		bigCount: item.bigCount
-				// 	}
-				// })
-				// getLimitBuyInfo({ ghsId, list: newList }).then(res => {
-				// 	const limitBuyInfo = Array.isArray(res.data) ? res.data : []
-				// 	const warnList = limitBuyInfo.filter(item => item.specialPrice === false && item.reachLimitBuyNum === true)
-				// 	if (warnList.length > 0) {
-				// 		this.limitBuyWarnList = warnList
-				// 		this.cartItemShow = true
-				// 		this.$msg("有花材超出限购")
-				// 		return
-				// 	}
-				// 	this.limitBuyWarnList = []
-				// 	this.setLimitBuyInfoByType({ type: this.pageType, info: limitBuyInfo });
-				// })
+				let newList = list
+					.filter(item => Number(item.limitBuy) > 0)
+					.map(item => {
+						return {
+							id: item.id,
+							bigCount: item.bigCount
+						}
+					})
+				if (newList.length > 0) {
+					getLimitBuyInfo({ ghsId, list: newList }).then(res => {
+						const limitBuyInfo = Array.isArray(res.data) ? res.data : []
+						const warnList = limitBuyInfo.filter(item => item.specialPrice === false && item.reachLimitBuyNum === true)
+						if (warnList.length > 0) {
+							this.limitBuyWarnList = warnList
+							this.cartItemShow = true
+							this.$msg("有花材超出限购")
+							return
+						}
+						this.limitBuyWarnList = []
+						this.setLimitBuyInfoByType({ type: this.pageType, info: limitBuyInfo });
+					})
+				} else {
+					this.limitBuyWarnList = []
+					this.setLimitBuyInfoByType({ type: this.pageType, info: [] });
+				}
 				this.setSelectInfoByType({ type: this.pageType, info: list });
 				let account = this.option.account ? this.option.account : 0
 				this.pageTo({url: '/pages/billing/affirmGhs?account='+account+'&hdId='+this.hdId,type:2})