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

Merge branch 'master' of http://39.101.143.165:8090/hxl13994548489/LocalLivingServicesUniapp

baijunde 8 месяцев назад
Родитель
Сommit
4210c8a027
2 измененных файлов с 35 добавлено и 8 удалено
  1. 34 7
      pages/product/creatProduct.vue
  2. 1 1
      pages/product/details.vue

+ 34 - 7
pages/product/creatProduct.vue

@@ -1016,12 +1016,25 @@ export default {
 		},
 		onSaleTimeChange(val) {
 			if (val && val.startDate && val.endDate) {
-				// const timeRange = [val.startDate, val.endDate];
-				// this.form.sellingDay.push(timeRange)
 				const timeRange = `${val.startDate}-${val.endDate}`;
-				this.form.sellingDay.push([timeRange])
+
+				// 检查是否已存在相同的时间范围
+				const isDuplicate = this.form.sellingDay.some(dayItem =>
+					dayItem[0] === timeRange
+				);
+
+				if (isDuplicate) {
+					// 已存在相同时间范围,提示用户
+					uni.showToast({
+						title: '该时间段已存在,请勿重复添加',
+						icon: 'none'
+					});
+				} else {
+					// 不存在重复,添加新的时间范围
+					this.form.sellingDay.push([timeRange]);
+					this.$forceUpdate(); // 强制刷新视图
+				}
 			}
-			this.$forceUpdate(); // 强制刷新视图
 		},
 		deleteTime(index) {
 			this.form.sellingDay.splice(index, 1);
@@ -1100,12 +1113,26 @@ export default {
 		onWeekTimeChange(val) {
 			if (val && val.startDate && val.endDate) {
 				const timeRange = `${val.startDate}-${val.endDate}`;
-				// const timeRange = [val.startDate, val.endDate];
+
 				this.form.localProductSellingWeeks.forEach(item => {
 					if (item.weekDay == this.addWeekDay) {
-						item.sellingStartTimeList.push([timeRange])
+						// 检查是否已存在相同的时间范围
+						const isDuplicate = item.sellingStartTimeList.some(timeItem =>
+							timeItem[0] === timeRange
+						);
+
+						if (isDuplicate) {
+							// 已存在相同时间范围,提示用户
+							uni.showToast({
+								title: '该时间段已存在,请勿重复添加',
+								icon: 'none'
+							});
+						} else {
+							// 不存在重复,添加新的时间范围
+							item.sellingStartTimeList.push([timeRange]);
+						}
 					}
-				})
+				});
 			}
 			this.$forceUpdate(); // 强制刷新视图
 		},

+ 1 - 1
pages/product/details.vue

@@ -52,7 +52,7 @@
 				</view>
 				<view class="img_box">
 					<span class="line">商品详情页</span>
-					<view class="img_list" v-if="detailImages">
+					<view class="img_list" v-if="!form.richText && detailImages">
 						<view class="img" v-for="(item, index) in detailImages" :key="index">
 							<image :src="item" mode=""></image>
 						</view>