Ver Fonte

花卉宝端(mallApp)购物车提交时获取限购信息--判断是否超出限购,并把限购信息传递到确认订单结算页(affirmGhs.vue)

shizhongqi há 2 meses atrás
pai
commit
097f28ec7d

+ 7 - 0
mallApp/src/api/order/index.js

@@ -137,3 +137,10 @@ export const orderUpdatePrice = data => {
 export const getDebtList = data => {
 	return https.get("/order/debt-list", data);
 };
+
+/** *
+ * 获取限购信息
+ */
+export const getLimitBuyInfo = data => {
+	return https.post("/order/limit-buy-info", data);
+};

+ 8 - 2
mallApp/src/mixins/cgProduct.js

@@ -53,7 +53,7 @@ export default {
 	onUnload() {},
 
 	computed: {
-		...mapGetters(["getSelectInfo"]),
+		...mapGetters(["getSelectInfo", "getLimitBuyInfo"]),
 		//当前页面选中的商品列表
 		selectList() {
 			return this.getSelectInfo[this.pageType] || [];
@@ -208,7 +208,12 @@ export default {
 		}
 	},
 	methods: {
-		...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
+		...mapActions([
+			"setSelectInfoByType",
+			"resetSelectInfoByType",
+			"setLimitBuyInfoByType",
+			"resetLimitBuyInfoByType"
+		]),
 		//记忆已选的花材
 		rememberProduct(){
 			//采购或预订的记忆花材
@@ -224,6 +229,7 @@ export default {
 		removeMemory(){
 			uni.removeStorageSync('selectList'+this.pageType)
 			this.resetSelectInfoByType(this.pageType)
+			this.resetLimitBuyInfoByType(this.pageType)
 			if(this.pageType == 'cg' && !this.$util.isEmpty(this.option.account)){
 				uni.removeStorageSync('selectList'+this.pageType+'_hd_'+this.option.account)
 			}

+ 52 - 3
mallApp/src/pages/item/item.vue

@@ -121,6 +121,9 @@
 										</view>
 									</view>
 								</view>
+								<view class="limit-buy-tip" v-if="getLimitBuyWarn(item)">
+									{{ getLimitBuyWarn(item) }}
+								</view>
 								<view style="text-align:right;">
 									<view class="open-bx" >
 										<i class="iconfont iconjian" @click.stop="delCurrent(item)" v-if="item.bigCount > 0 || item.smallCount > 0"></i>
@@ -159,6 +162,7 @@ import allMoreSelectInputMins from "@/mixins/allMoreSelectInput";
 import productMins from "@/mixins/cgProduct";
 import { COMMODITY_TYPE } from "@/utils/declare";
 import { getInfo } from "@/api/shop";
+import { getLimitBuyInfo } from "@/api/order";
 export default {
 	name: "item",
 	components: {
@@ -206,6 +210,7 @@ export default {
 			newCustomGift:{xrFlAmount:0},
 			isNewCustom:false,
 			cartItemShow:false,
+			limitBuyWarnList: [],
 			shopName:'',
 			shopImg:'',
 			hdId:0,
@@ -297,11 +302,19 @@ export default {
 		},
 		delMemory(){
 			this.cartItemShow = false
+			this.limitBuyWarnList = []
 			this.removeMemory()
 		},
 		hideCartItem(){
 			this.cartItemShow = false
 		},
+		getLimitBuyWarn(item) {
+			const info = this.limitBuyWarnList.find(warnItem => warnItem.id == item.id)
+			if (!info) {
+				return ''
+			}
+			return `超出限购${info.currentBuyNum + info.exceedNum}份`
+		},
 		loginSuccess() {
 			this.initData()
 		},
@@ -495,15 +508,41 @@ export default {
 					this.$msg("请选择花材")
 					return
 				}
-				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:1})
+				const ghsId = Number(this.option.account) || Number(uni.getStorageSync('account')) || 0
+				if (!ghsId) {
+					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.setSelectInfoByType({ type: this.pageType, info: list });
+					this.setLimitBuyInfoByType({ type: this.pageType, info: limitBuyInfo });
+					let account = this.option.account ? this.option.account : 0
+					this.pageTo({url: '/pages/billing/affirmGhs?account='+account+'&hdId='+this.hdId,type:1})
+				}).catch(() => {
+					this.$msg("限购信息获取失败,请稍后重试")
+				})
 			} else {
 				this.$msg("请选择花材");
 			}
 		},
 		change(e) {
 			this.resetSelectInfoByType(this.pageType);
+			this.resetLimitBuyInfoByType(this.pageType);
 			if (this.tabIndex == e.index) {
 				return false;
 			} else {
@@ -900,6 +939,7 @@ export default {
 				justify-content: center;
 				flex: 1;
 				margin-left: 20upx;
+				position: relative;
 				.info-line {
 					margin-bottom: 20upx;
 					display: flex;
@@ -924,6 +964,15 @@ export default {
 
 				}
 
+				.limit-buy-tip {
+					position: absolute;
+					left: 0;
+					top: 86upx;
+					color: red;
+					font-size: 24upx;
+					text-align: left;
+				}
+
 
 	.open-bx {
 		align-items: center;

+ 17 - 1
mallApp/src/store/modules/product.js

@@ -1,10 +1,14 @@
 export default {
 	state: {
-		selectInfo: {} //选择商品信息  用页面pageType当key  查询对应模块选择的商品列表
+		selectInfo: {}, //选择商品信息  用页面pageType当key  查询对应模块选择的商品列表
+		limitBuyInfo: {} //限购信息  用页面pageType当key  查询对应模块限购列表
 	},
 	getters: {
 		getSelectInfo(state) {
 			return state.selectInfo || {};
+		},
+		getLimitBuyInfo(state) {
+			return state.limitBuyInfo || {};
 		}
 	},
 	actions: {
@@ -17,6 +21,15 @@ export default {
 			commit("SET_SELECTINFO_BY_TYPE", { type, info: [] });
 		},
 
+		//设置不同类别限购信息(采购模块供确认页计价使用)
+		setLimitBuyInfoByType({ commit }, { type, info }) {
+			commit("SET_LIMITBUYINFO_BY_TYPE", { type, info });
+		},
+		//清空不同类别限购信息
+		resetLimitBuyInfoByType({ commit }, type) {
+			commit("SET_LIMITBUYINFO_BY_TYPE", { type, info: [] });
+		},
+
 		//重要!!!!selectJobType区分不同业务,如开单、报损、调拨,selectJobId用于区分相同业务下的不同主体,如调拨给不同门店,开店给不同的客户
 
 		//保存已选花材列表(新写法)
@@ -34,6 +47,9 @@ export default {
 		["SET_SELECTINFO_BY_TYPE"](state, { type, info }) {
 			state.selectInfo = {...state.selectInfo,[type]: info};
 		},
+		["SET_LIMITBUYINFO_BY_TYPE"](state, { type, info }) {
+			state.limitBuyInfo = {...state.limitBuyInfo,[type]: info};
+		},
 		//新写法
 		SET_SELECTED_ITEM(state, { selectJobType, info,selectJobId }) {
 			state.selectInfo = { ...state.selectInfo, [selectJobType+'_'+selectJobId]: info }