Browse Source

花卉宝端(mallApp)添加限购处理与提示

shizhongqi 4 months ago
parent
commit
4ee9897b46

+ 0 - 2
hdApp/src/admin/billing/affirmGhs.vue

@@ -894,9 +894,7 @@ export default {
 					this.updateItemEvent(this.customData)
 					this.modalCancel()
 				}
-
 			})
-
 		},
 		init() {
 			let that = this

+ 67 - 3
mallApp/src/pages/billing/affirmGhs.vue

@@ -5,7 +5,7 @@
 				<view class="module-com">
 					<view class="commodity-view">
 						<view class="commodity-list">
-							<view class="commodity-item" v-for="(item, index) in list" :key="index">
+							<view class="commodity-item" :class="{'limit-exceed-item': item._limitExceeded}" v-for="(item, index) in list" :key="index">
 								<image class="item-icon" :src="item.cover" />
 								<view class="item-info">
 									<view class="info-line">
@@ -23,6 +23,7 @@
 											<text>{{`${item.bigCount}`}}{{item.bigUnit}}</text>
 										</text>
 									</view>
+									<text v-if="item._limitExceeded" class="limit-exceed-tip">限购 {{ limitExceedLimitBuy }},超出 {{ limitExceedNum }}</text>
 								</view>
 							</view>
 						</view>
@@ -334,7 +335,10 @@ export default {
 			validAddress:false,
 			hbData:[], // 可用红包数据
 			selectedHbId: null, // 选中的红包ID
-			selectedHb: null // 选中的红包对象
+			selectedHb: null, // 选中的红包对象
+			limitExceedProductId:'',
+			limitExceedLimitBuy:'',
+			limitExceedNum:''
 		};
 	},
 	onLoad(){
@@ -357,6 +361,7 @@ export default {
 				mergedMap[key].smallCount = mergedMap[key].smallCount + item.smallCount;
 			} else {
 				mergedMap[key] = this.$util.copyObject(item);
+				mergedMap[key]._limitExceeded = false
 				list.push(mergedMap[key]);
 			}
 		}
@@ -738,7 +743,6 @@ export default {
 			console.log('selectDelivery -- isFreeDelivery: ',isFreeDelivery)
 		},
 		confirmForm(){
-
 			let hdId = this.option.hdId ? this.option.hdId : 0
 			let account = this.option.account ? this.option.account : 0
 			if(Number(hdId)<=0 || Number(account)<=0){
@@ -817,14 +821,36 @@ export default {
 			buyItem(params).then(res => {
 				uni.hideLoading()
 				if(res.code && res.code == 1){
+					this.clearLimitExceededMark()
+					this.limitExceedProductId = ''
+					this.limitExceedLimitBuy = ''
+					this.limitExceedNum = ''
 					let account = this.option.account ? this.option.account : 0
 					let getPayType = res.data.getPayType?res.data.getPayType:0
 					let totalPrice = res.data.totalPrice?res.data.totalPrice:0
 					let orderSn = res.data.orderSn?res.data.orderSn:''
 					let id = res.data.id ? res.data.id : 0
 					this.$util.pageTo({url:"/pages/callback/pay?account="+account+'&id='+id+'&hdId='+hdId+'&pageStatus=1&getPayType='+getPayType+'&totalPrice='+totalPrice+'&orderSn='+orderSn,type:2})
+				}else if(res.code == -1 && res.data && String(res.data.productId || '') !== ''){
+					this.limitExceedProductId = res.data.productId ? String(res.data.productId) : ''
+					this.limitExceedLimitBuy = res.data.limitBuy ? String(res.data.limitBuy) : '0'
+					this.limitExceedNum = res.data.exceed ? String(res.data.exceed) : '0'
+					this.markLimitExceededItem(this.limitExceedProductId)
+					this.$msg(res.msg || '累计已超出限购数')
+					return false
+				}else{
+					this.clearLimitExceededMark()
+					this.limitExceedProductId = ''
+					this.limitExceedLimitBuy = ''
+					this.limitExceedNum = ''
+					if(res.msg){
+						this.$msg(res.msg)
+					}
 				}
 				this.removeMemory()
+			}).catch(err => {
+				uni.hideLoading()
+				this.$msg(err.msg)
 			})
 		},
 		modifyItem() {
@@ -832,6 +858,31 @@ export default {
 			let hdId = this.option.hdId ? this.option.hdId : 0
 			this.$util.pageTo({url:'/pages/item/item?account='+account+'&hdId='+hdId,type:2})
 		},
+		markLimitExceededItem(productId){
+			if(!productId || !Array.isArray(this.list) || this.list.length <= 0){
+				return
+			}
+			const targetId = String(productId)
+			this.list.forEach((item, index) => {
+				const matched = String(item.id) === targetId
+				this.$set(this.list[index], '_limitExceeded', matched)
+			})
+			this.$forceUpdate()
+		},
+		clearLimitExceededMark(){
+			if(!Array.isArray(this.list) || this.list.length <= 0){
+				return
+			}
+			this.list.forEach((item, index) => {
+				this.$set(this.list[index], '_limitExceeded', false)
+			})
+		},
+		isLimitExceededItem(item){
+			if(!item || !this.limitExceedProductId){
+				return false
+			}
+			return String(item.id) === String(this.limitExceedProductId)
+		},
 		getHbData(){
 			getAvailableHb({shopId:this.shopInfo.id}).then(res=>{
 				if(res.code == 1){
@@ -1024,17 +1075,30 @@ export default {
 				.commodity-item {
 					display: flex;
 					margin-bottom: 20upx;
+					&.limit-exceed-item {
+						border: 2upx solid #ff4d4f;
+						border-radius: 12upx;
+						padding: 12upx;
+						box-sizing: border-box;
+					}
 					.item-icon {
 						flex-shrink: 0;
 						width: 140upx;
 						height: 140upx;
 					}
 					.item-info {
+						position: relative;
 						display: flex;
 						flex-direction: column;
 						justify-content: center;
 						flex: 1;
 						margin-left: 20upx;
+						.limit-exceed-tip {
+							margin-top: 10upx;
+							color: #ff4d4f;
+							font-size: 24upx;
+							font-weight: bold;
+						}
 						.info-line {
 							margin-bottom: 20upx;
 							display: flex;

+ 25 - 1
mallApp/src/pages/item/components/subItem.vue

@@ -5,7 +5,10 @@
 		</view>
 		<view class="cmd-info_bx">
 			<view class="tit" >
-				<text style="font-size:22upx;border:1upx solid #3385ff;color:white;background-color:#3385ff;margin-right:5upx;padding-left:5upx;padding-right:5upx;" v-if="info.presell == 1">预售</text>
+				<text class="item-tag item-tag--presell" v-if="info.presell == 1">预售</text>
+				
+				<text class="item-tag item-tag--limit-buy" v-if="Number(info.limitBuy) > 0">限购{{ Number(info.limitBuy) }}份</text>
+
 				{{ info.itemName}}
 			</view>
 			<view class="kc num-open_bx flex-space">
@@ -221,6 +224,27 @@ export default {
 			white-space: nowrap;
 			text-overflow: ellipsis;
 			width:380upx;
+
+			.item-tag {
+				display: inline-block;
+				border: 1upx solid;
+				color: #ffffff;
+				margin-right: 5upx;
+				padding: 0 5upx;
+				line-height: 1.2;
+			}
+
+			.item-tag--presell {
+				font-size: 22upx;
+				border-color: #3385ff;
+				background-color: #3385ff;
+			}
+
+			.item-tag--limit-buy {
+				font-size: 20upx;
+				border-color: red;
+				background-color: red;
+			}
 		}
 		& .kc {
 			position: relative;

+ 1 - 4
mallApp/src/pages/item/item.vue

@@ -401,7 +401,6 @@ export default {
 			this.isFocus = false;
 			this.isFocusOne = false;
 			this.$nextTick(()=>{
-
 				//取消
 				if (val.index === 0) {
 					if(this.customData.bigCount>0 || this.customData.smallCount>0){
@@ -442,9 +441,7 @@ export default {
 					this.updateItemEvent(this.customData)
 					this.modalCancel()
 				}
-
 			})
-
 		},
 		cancelEvent() {
 			this.showSubmitModel = false;
@@ -485,7 +482,7 @@ export default {
 				}
 				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})
+				this.pageTo({url: '/pages/billing/affirmGhs?account='+account+'&hdId='+this.hdId,type:1})
 			} else {
 				this.$msg("请选择花材");
 			}

+ 3 - 1
mallApp/src/plugins/luch-request_0.0.7/request.js

@@ -203,7 +203,9 @@ class Request {
 							}
 							reject(response.data)
 						} else if (response.data.code && response.data.code == -1) {
-							this.handleAuthExpired(currentPages)
+							// this.handleAuthExpired(currentPages)
+							// -1 仅作为业务失败返回,不触发自动登出
+							resolve(response.data)
 						} else if (response.data.code == 2) {
 							this.handleAuthExpired(currentPages)
 						} else {