Browse Source

合并代码

baijunde 2 months ago
parent
commit
15ece46331

+ 7 - 0
common/router/modules/routes.js

@@ -617,6 +617,13 @@ const routes = [{
 			title: '编辑商品1',
 		},
 	},
+	{
+		path: '/pages/groupMeal/goods/form-step1',
+		name: 'groupMealGoodsFormStep2',
+		meta: {
+			title: '编辑商品1',
+		},
+	},
 	{
 		path: '/pages/groupMeal/goods/form-day',
 		name: 'groupMealGoodsFormDay',

+ 43 - 28
pages/groupMeal/goods/form-step1.vue

@@ -25,14 +25,17 @@
 				<u-form-item prop="productImage" label="商品封面图" required labelPosition="top">
 					<view class="upload-content">
 						<view class="upload-tip">支持jpg、png格式,建议尺寸为750px*750px,上传1-4张</view>
-						<Upload
+						<u-upload
+							:action="uploadAction"
+							:file-list="fileList.cover"
+							:form-data="uploadFormData"
+							:max-count="4"
+							:multiple="true"
 							width="140"
 							height="140"
-							:maxCount="4"
-							:multiple="true"
-							:fileList.sync="fileList.cover"
-							:previewFullImage="true"
-							@complete="onUpload($event, 'cover')"
+							preview-full-image
+							@on-success="onCoverSuccess"
+							@on-remove="onCoverRemove"
 						/>
 					</view>
 				</u-form-item>
@@ -40,14 +43,17 @@
 				<u-form-item prop="detailImages" label="商品详情图" required borderBottom labelPosition="top">
 					<view class="upload-content">
 						<view class="upload-tip">支持jpg、png格式,最多20张</view>
-						<Upload
+						<u-upload
+							:action="uploadAction"
+							:file-list="fileList.detail"
+							:form-data="uploadFormData"
+							:max-count="20"
+							:multiple="true"
 							width="140"
 							height="140"
-							:maxCount="20"
-							:multiple="true"
-							:fileList.sync="fileList.detail"
-							:previewFullImage="true"
-							@complete="onUpload($event, 'detail')"
+							preview-full-image
+							@on-success="onDetailSuccess"
+							@on-remove="onDetailRemove"
 						/>
 					</view>
 				</u-form-item>
@@ -103,14 +109,17 @@ export default {
 			return {
 				show: false,
 				showSpecial: false,
+				uploadAction: configService.apiUrl + '/sys/common/upload',
+				imageHttp: configService.apiUrl + '/',
+			uploadFormData: { biz: 'temp' },
 				form: {
 					name: '',
 					category: '',
 					categoryName: '',
 					specialCategoryId: '',
 					specialCategoryName: '',
-					productImage: 'https://test.baoxianzhanggui.com/locallive-java/product/企业微信截图_1781494923590_1781494943931.png',
-					detailImages: 'https://test.baoxianzhanggui.com/locallive-java/product/企业微信截图_1781494923590_1781494943931.png',
+					productImage: '',
+					detailImages: '',
 					price: '',
 					sellingPrice: '',
 					dailyStock:null,
@@ -223,7 +232,6 @@ export default {
 			
 		if (query.id) {
 			this.query = query;
-		  await	this.getCategoryList()
 			await this.getData();
 		}
 		// 清除
@@ -233,15 +241,32 @@ export default {
 		
 	},
 	onShow() {
-		
+		this.getCategoryList()
 	},
 	onReady() {
 		this.$refs.uForm.setRules(this.rules);
 	},
 	methods: {
+		onCoverSuccess(res, index, lists) {
+			this.fileList.cover = lists;
+			this.processImageList(lists, 'productImage');
+		},
+		onCoverRemove(index, lists) {
+			this.fileList.cover = lists;
+			this.processImageList(lists, 'productImage');
+		},
+		onDetailSuccess(res, index, lists) {
+			this.fileList.detail = lists;
+			this.processImageList(lists, 'detailImages');
+		},
+		onDetailRemove(index, lists) {
+			this.fileList.detail = lists;
+			this.processImageList(lists, 'detailImages');
+		},
 		//获取特色分类
 		getCategoryList(){
 			this.$http.get('/groupmeal/gmSpecialCategory/listAll').then(res => {
+				console.log(res)
 				if (res.data.code === 200 && res.data.result) {
 					this.categoryList = res.data.result.map(item => {
 						return {
@@ -417,18 +442,8 @@ $uni-color-primary: #2979ff;
 			color: #999999;
 			margin-bottom: 20rpx;
 		}
-
-		::v-deep .u-add-tips {
-			display: none !important;
-		}
-
-		::v-deep .u-add-wrap {
-			background: url('/static/groupMeal/upload.png') center center / 100% 100% no-repeat !important;
-			border: none !important;
-		}
-
-		::v-deep .u-add-btn {
-			display: none !important;
+::v-deep .u-add-tips {
+			margin-top: 10rpx;
 		}
 	}
 }

+ 1 - 1
pages/groupMeal/goods/list.vue

@@ -328,7 +328,7 @@ export default {
 		addGoods() {
 			this.isManaging = false;
 			uni.navigateTo({
-				url: '/pages/groupMeal/goods/form'
+				url: '/pages/groupMeal/goods/form-step1'
 			});
 		},
 		// 编辑商品