Quellcode durchsuchen

商品管理bug修复

lishanshan vor 8 Monaten
Ursprung
Commit
cbf3674d70
3 geänderte Dateien mit 787 neuen und 677 gelöschten Zeilen
  1. 102 37
      pages/product/creatProduct.vue
  2. 12 9
      pages/product/details.vue
  3. 673 631
      pages/product/index.vue

+ 102 - 37
pages/product/creatProduct.vue

@@ -202,7 +202,7 @@
 				</view>
 				<view class="item" v-if="form.categoryId != '1945013773786701826'">
 					<view class="label">
-						商品市场价<span v-if="tabIndex == '1'">*</span>
+						商品市场价<span>*</span>
 					</view>
 					<view class="picker">
 						<u-input type="number" v-model.number="form.soldPrice" placeholder="请输入"
@@ -231,13 +231,14 @@
 						售卖时间<span v-if="tabIndex == '1'">*</span>
 					</view>
 					<view>
-						<u-radio-group style="width: 100%;background-color: #ffffff;padding: 16rpx 0;border-radius: 16rpx;">
-							<u-radio @change="form.sellingTimeType = '1'" name="long" style="width: 100%;">
+						<u-radio-group v-model="form.sellingTimeType"
+							style="width: 100%;background-color: #ffffff;padding: 16rpx 0;border-radius: 16rpx;">
+							<u-radio name="1" style="width: 100%;">
 								<view>
 									不限制
 								</view>
 							</u-radio>
-							<u-radio @change="form.sellingTimeType = '2'" name="date" style="width: 100%;margin-top: 16rpx;">
+							<u-radio name="2" style="width: 100%;margin-top: 16rpx;">
 								<span>
 									每天
 								</span>
@@ -245,23 +246,22 @@
 									<u-button type="primary" size="mini" @click="selectSaleDate">添加时间</u-button>
 								</span>
 							</u-radio>
-							<u-radio @change="form.sellingTimeType = '3'" name="week" style="width: 100%;margin-top: 16rpx;">
+							<!-- 每天售卖时间选择 -->
+							<uni-card v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0"
+								:is-shadow="false" is-full style="border:1rpx solid #E5E5E5;margin-top: 16rpx;">
+								<view v-for="item, index in form.sellingDay" :key="index"
+									style="display: flex; justify-content: space-between;">
+									<span>{{ item[0] }}</span>
+									<span style="color: #dd524d;" @click="deleteTime(index)"><u-icon name="minus-circle-fill"
+											style="margin-left: 17rpx;"></u-icon></span>
+								</view>
+							</uni-card>
+							<u-radio name="3" style="width: 100%;margin-top: 16rpx;">
 								<span>
 									每周
 								</span>
 							</u-radio>
 						</u-radio-group>
-						<!-- 每天售卖时间选择 -->
-						<uni-card v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0"
-							:is-shadow="false" is-full style="border:1rpx solid #E5E5E5;">
-							<view v-for="item, index in form.sellingDay" :key="index"
-								style="display: flex; justify-content: space-between;">
-								<span>{{ item[0] }}</span>
-								<!-- <span>{{ item[0] ? item[0] + '-' + item[1] : '' }}</span> -->
-								<span style="color: #dd524d;" @click="deleteTime(index)"><u-icon name="minus-circle-fill"
-										style="margin-left: 17rpx;"></u-icon></span>
-							</view>
-						</uni-card>
 						<view class="item_tips saletime" v-show="form.sellingTimeType == '2' && form.sellingDay.length == 0">
 							请添加起止时间段
 						</view>
@@ -410,7 +410,7 @@
 							</view>
 						</view>
 					</view>
-					<view class="item upload">
+<view class="item upload">
 						<view class="label">
 							使用说明
 						</view>
@@ -442,8 +442,8 @@
 		<rangTime ref="rangTime" :mode="mode" @onSubmit="onEndTimeChange" :title="timeTitle" />
 		<rangTime ref="rangSaleTime" :mode="mode" @onSubmit="onSaleTimeChange" :title="timeTitle" />
 		<rangTime ref="rangWeekTime" :mode="mode" @onSubmit="onWeekTimeChange" :title="timeTitle" />
-		<refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel" @confirm="saveFound"
-			@close="cutRule" />
+		<!-- <refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel" @confirm="saveFound"
+			@close="cutRule" /> -->
 		<view class="popup" v-if="isSelectType">
 			<view class="model">
 				<view class="title">
@@ -656,13 +656,55 @@ export default {
 
 		// 上传封面图成功回调
 		handleSuccess(res, index, lists) {
-			this.form.productImage = this.imageHttp + res.message
-
+			try {
+				// 更新fmImageList为最新的列表(由u-upload组件维护)
+				this.fmImageList = lists;
+
+				// 处理图片列表,生成URL字符串
+				let temp = [];
+				lists.forEach(item => {
+					if (item.response && item.response.message) {
+						temp.push(this.imageHttp + item.response.message);
+					} else if (item.url) {
+						// 处理已存在的图片
+						temp.push(item.url);
+					}
+				});
+				// 将多张图片URL以逗号分隔拼接
+				this.form.productImage = temp.join(',');
+			} catch (error) {
+				uni.showToast({
+					title: '封面图更新失败',
+					icon: 'none'
+				});
+			}
 		},
 		// 移除封面图文件回调
 		handleRemove(index, lists) {
-			this.fmImageList = [];
+			try {
+				// 更新fmImageList为最新的列表(由u-upload组件维护)
+				this.fmImageList = lists;
+
+				// 处理图片列表,生成URL字符串
+				let temp = [];
+				lists.forEach(item => {
+					if (item.response && item.response.message) {
+						temp.push(this.imageHttp + item.response.message);
+					} else if (item.url) {
+						// 处理已存在的图片
+						temp.push(item.url);
+					}
+				});
+				// 将多张图片URL以逗号分隔拼接
+				this.form.productImage = temp.join(',');
+			} catch (error) {
+				uni.showToast({
+					title: '封面图移除失败',
+					icon: 'none'
+				});
+			}
 		},
+
 		//上传详情图
 		detailsSuccess(res, index, lists) {
 			console.log(lists)
@@ -1099,13 +1141,20 @@ export default {
 				});
 				return
 			}
-			if (this.tabIndex == '1' && !this.form.soldPrice) {
+			if (!this.form.soldPrice) {
 				uni.showToast({
 					title: '请输入商品市场价',
 					icon: 'none'
 				});
 				return
 			}
+			if (this.form.soldPrice <= this.form.price) {
+				uni.showToast({
+					title: '商品市场价必须大于商品售价',
+					icon: 'none'
+				});
+				return
+			}
 			if (this.tabIndex == '1' && !this.form.sellingTimeType) {
 				uni.showToast({
 					title: '请选择售卖时间',
@@ -1134,10 +1183,10 @@ export default {
 				});
 				return
 			} else {
-				if(this.form.sellingTimeType == '3') {
+				if (this.form.sellingTimeType == '3') {
 					this.form.sellingDay = []
-				} else if(this.form.sellingTimeType == '2') {
-					this.form.localProductSellingWeeks = this.localProductSellingWeeks
+				} else if (this.form.sellingTimeType == '2') {
+					this.form.localProductSellingWeeks = []
 				}
 				if (this.productId == '') {
 					this.$http.post("/app/product/add", this.form).then(res => {
@@ -1202,10 +1251,17 @@ export default {
 					this.jifenChecked = res.data.result.integralAward ? true : false
 					this.jindouChecked = res.data.result.goldAward ? true : false
 					this.showText = res.data.result.productCategory
-					this.fmImageList.push({
-						url: res.data.result.productImage
-					})
-
+					// 处理封面图,支持多张图片
+					if (res.data.result.productImage) {
+						let productImages = res.data.result.productImage.split(',');
+						productImages.forEach(imageUrl => {
+							if (imageUrl.trim()) { // 过滤空字符串
+								this.fmImageList.push({
+									url: imageUrl
+								});
+							}
+						});
+					}
 					if (res.data.result.detailImages) {
 						let xqtemp = []
 						xqtemp = res.data.result.detailImages.split(',')
@@ -1217,9 +1273,9 @@ export default {
 						console.log(this.xqImage)
 					}
 
-					this.showDate = res.data.result.saleStartDate.slice(0, 10) + '-' + res.data.result.saleEndDate.slice(0,
-						10)
-					if (res.data.resultuseType == 2) {
+					// this.showDate = res.data.result.saleStartDate.slice(0, 10) + '-' + res.data.result.saleEndDate.slice(0,
+					// 	10)
+					if (res.data.result.useType == 2) {
 						this.showSellDate = res.data.result.availableStartDate.slice(0, 10) + '-' + res.data.result
 							.availableEndDate.slice(0, 10)
 					} else if (res.data.result.useType == 1) {
@@ -1232,7 +1288,7 @@ export default {
 						this.showRule = res.data.result.refundLabelName + '·' + res.data.result.refundConfirmName
 					}
 					// 兼容旧数据
-					this.form.video = res.data.result.video || ''
+					this.video = res.data.result.video || ''
 					if (!res.data.result.sellingDay) {
 						this.form.sellingDay = []
 					}
@@ -1242,9 +1298,13 @@ export default {
 					if (!res.data.result.serviceDescription) {
 						this.form.serviceDescription = []
 					}
-					this.form.richText = res.data.result.richText || ''
-					console.log(this.showRule)
-
+					// 初始化编辑器内容
+					if (res.data.result.richText) {
+						this.form.richText = res.data.result.richText || ''
+						this.editorCtx.setContents({
+							html: this.form.richText
+						})
+					}
 					uni.setStorage({
 						key: 'group',
 						data: res.data.result.productGroups
@@ -1860,4 +1920,9 @@ export default {
 	display: flex;
 	justify-content: space-around;
 }
+
+.sellingTimeCard {
+	border: 1rpx solid #E5E5E5;
+	margin-top: 16rpx;
+}
 </style>

+ 12 - 9
pages/product/details.vue

@@ -130,6 +130,7 @@
 						<span v-if="form.sellingTimeType == '2'">每天</span>
 						<span v-if="form.sellingTimeType == '3'">每周</span>
 					</view>
+					<!-- 每天售卖时间 -->
 					<view class="card_data" v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0">
 						<uni-card :is-shadow="false" is-full style="border:1rpx solid #E5E5E5;">
 							<view v-for="item, index in form.sellingDay" :key="index" style="display: flex; justify-content: center;">
@@ -138,7 +139,7 @@
 						</uni-card>
 					</view>
 					<view class="card_data" v-show="form.sellingTimeType == '3'">
-						<!-- 每周售卖时间选择 -->
+						<!-- 每周售卖时间 -->
 						<uni-table v-show="form.sellingTimeType == '3'">
 							<!-- 表头 -->
 							<uni-tr class="table-header">
@@ -315,14 +316,16 @@ export default {
 				if (!res.data.result.localProductSellingWeeks) {
 					this.form.localProductSellingWeeks = this.localProductSellingWeeks
 				}
+				// 处理封面图,支持多张图片
 				if (res.data.result.productImage) {
-					let productImagelist = []
-					productImagelist = res.data.result.productImage.split(',')
-					productImagelist.map(item => {
-						this.fmImageList.push({
-							url: item
-						})
-					})
+					let productImages = res.data.result.productImage.split(',');
+					productImages.forEach(imageUrl => {
+						if (imageUrl.trim()) { // 过滤空字符串
+							this.fmImageList.push({
+								url: imageUrl
+							});
+						}
+					});
 				}
 				if (this.form.specItems) {
 					this.form.specItems.forEach(item => {
@@ -489,7 +492,7 @@ export default {
 		.img_list {
 			display: flex;
 			flex-wrap: wrap;
-			justify-content: space-between;
+			justify-content: start;
 			// gap: 27rpx;
 
 			.img {

Datei-Diff unterdrückt, da er zu groß ist
+ 673 - 631
pages/product/index.vue


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.