Kaynağa Gözat

团餐申请修改;添加菜品修改

付晓文。 1 ay önce
ebeveyn
işleme
3af1eb1dde

+ 17 - 5
components/index_nav.vue

@@ -25,10 +25,15 @@
 			Modal,
 		},
 		props: {
-			/** 是否展示储值管理入口(由行业准入接口控制) */
+			/** 行业是否为美食(由分类准入接口控制) */
 			showTopUp: {
 				type: Boolean,
 				default: false
+			},
+			/** 是否展示团餐设置/团餐订单(isApply 审核通过才展示) */
+			showGroupMeal: {
+				type: Boolean,
+				default: false
 			}
 		},
 		data() {
@@ -47,7 +52,8 @@
 					{
 						name: '菜品管理',
 						url: '/static/index/product.png',
-						path: '/pages/merchantDish/dish/list'
+						path: '/pages/merchantDish/dish/list',
+						needTopUp: true
 					},
 					{
 						name: '商品管理',
@@ -94,12 +100,14 @@
 					{
 						name: '团餐设置',
 						url: '/static/index/groupMeal.png',
-						path: '/pages/merchantDish/settings/index'
+						path: '/pages/merchantDish/settings/index',
+						needGroupMeal: true
 					},
 					{
 						name: '团餐订单',
 						url: '/static/index/indent.png',
-						path: '/pages/merchantDish/orders/index'
+						path: '/pages/merchantDish/orders/index',
+						needGroupMeal: true
 					},
 					{
 						name: '全部服务',
@@ -117,7 +125,11 @@
 		},
 		computed: {
 			swiperList() {
-				return this.baseList.filter((item) => !item.needTopUp || this.showTopUp);
+				return this.baseList.filter((item) => {
+					if (item.needTopUp && !this.showTopUp) return false;
+					if (item.needGroupMeal && !this.showGroupMeal) return false;
+					return true;
+				});
 			}
 		},
 		methods: {

+ 32 - 25
pages/groupMeal/goods/form-step1.vue

@@ -25,18 +25,42 @@
 				<u-form-item prop="productImage" label="商品封面图" required labelPosition="top">
 					<view class="upload-content">
 						<view class="upload-tip">支持jpg、png格式,建议尺寸为750px*750px,上传1-4张</view>
-						<u-upload :action="uploadAction" :file-list="fileList.cover" :form-data="uploadFormData"
-							:max-count="4" :multiple="true" width="140" height="140" preview-full-image
-							@on-success="onCoverSuccess" @on-remove="onCoverRemove" />
+						<u-upload
+							:action="uploadAction"
+							:file-list="fileList.cover"
+							:form-data="uploadFormData"
+							:max-count="4"
+							:multiple="true"
+							:deletable="true"
+							del-bg-color="#fa3534"
+							upload-text="选择图片"
+							width="140"
+							height="140"
+							preview-full-image
+							@on-success="onCoverSuccess"
+							@on-remove="onCoverRemove"
+						/>
 					</view>
 				</u-form-item>
 
 				<u-form-item prop="detailImages" label="商品详情图" required borderBottom labelPosition="top">
 					<view class="upload-content">
 						<view class="upload-tip">支持jpg、png格式,最多20张</view>
-						<u-upload :action="uploadAction" :file-list="fileList.detail" :form-data="uploadFormData"
-							:max-count="20" :multiple="true" width="140" height="140" preview-full-image
-							@on-success="onDetailSuccess" @on-remove="onDetailRemove" />
+						<u-upload
+							:action="uploadAction"
+							:file-list="fileList.detail"
+							:form-data="uploadFormData"
+							:max-count="20"
+							:multiple="true"
+							:deletable="true"
+							del-bg-color="#fa3534"
+							upload-text="选择图片"
+							width="140"
+							height="140"
+							preview-full-image
+							@on-success="onDetailSuccess"
+							@on-remove="onDetailRemove"
+						/>
 					</view>
 				</u-form-item>
 
@@ -72,12 +96,8 @@
 </template>
 
 <script>
-	import Upload from '@/components/upload/index.vue';
 	import configService from '@/common/service/config.service';
 	export default {
-		components: {
-			Upload,
-		},
 		data() {
 			return {
 				show: false,
@@ -276,16 +296,8 @@
 							};
 							console.log(123123, this.form)
 							this.fileList = {
-								cover: data.productImage.split(',').map(item => {
-									return {
-										url: item
-									}
-								}),
-								detail: data.detailImages.split(',').map(item => {
-									return {
-										url: item
-									}
-								}),
+								cover: (data.productImage || '').split(',').filter(Boolean).map(item => ({ url: item })),
+								detail: (data.detailImages || '').split(',').filter(Boolean).map(item => ({ url: item })),
 							};
 						})
 					}
@@ -329,11 +341,6 @@
 					this.form[key] = !filtered ? filtered : filtered - 0;
 				});
 			},
-			// 图片处理
-			onUpload(event, type) {
-				this.fileList[type] = event;
-				this.form[type == 'cover' ? 'productImage' : 'detailImages'] = this.fileList[type].map(f => f.url).join();
-			},
 			// 下一步
 			goNextStep() {
 				// 表单校验

+ 19 - 2
pages/index/index.vue

@@ -67,7 +67,7 @@
 				</view>
 			</view>
 			<view class="other">
-				<indexNav :showTopUp="showTopUp" />
+				<indexNav :showTopUp="showTopUp" :showGroupMeal="showGroupMeal" />
 			</view>
 		</view>
 		<!-- 完善信息弹窗,storeStatus == 3 (店铺已经审核通过 ) -->
@@ -127,7 +127,8 @@
 				isPopup: false, //弹窗是否出现
 				referenceId: "", //邀请码
 				logo: '',
-				showTopUp: false // 行业是否支持储值
+				showTopUp: false, // 行业是否为美食
+				showGroupMeal: false // 团餐报名是否审核通过
 			};
 		},
 		onLoad: function() {
@@ -225,12 +226,27 @@
 				prepaidApi
 					.checkIndustryEligibility(this.merchantId)
 					.then((res) => {
+						console.log('11111',res)
 						this.showTopUp = res.data.code === 200 && !!res.data.result;
 					})
 					.catch(() => {
 						this.showTopUp = false;
 					});
 			},
+			/** 查询团餐报名状态,审核通过才展示团餐设置/团餐订单 */
+			checkGroupMealApply() {
+				this.$http
+					.post('/groupmeal/gmMerchantApplicationRecord/isApply', {})
+					.then((res) => {
+						this.showGroupMeal =
+							res.data.code === 200 &&
+							!!res.data.result &&
+							res.data.result.status == 1;
+					})
+					.catch(() => {
+						this.showGroupMeal = false;
+					});
+			},
 		},
 		mounted() {
 			// let info =
@@ -251,6 +267,7 @@
 					that.getNum();
 					that.getStroeStatus();
 					that.checkTopUpEligibility();
+					that.checkGroupMealApply();
 				},
 			});
 		},

+ 88 - 47
pages/merchantDish/dish/form.vue

@@ -27,25 +27,41 @@
 			</view>
 			<view class="upload-row">
 				<text class="label required">商品封面图</text>
-				<view class="tip">支持jpg、png格式,建议尺寸750px*750px</view>
-				<view class="upload-box" @click="pickImage('cover')">
-					<image v-if="form.cover" :src="form.cover" mode="aspectFill"></image>
-					<template v-else>
-						<text class="plus">+</text>
-						<text>上传图片</text>
-					</template>
-				</view>
+				<view class="tip">支持jpg、png格式,建议尺寸为750px*750px,上传1-4张</view>
+				<u-upload
+					:action="uploadAction"
+					:file-list="fileList.cover"
+					:form-data="uploadFormData"
+					:max-count="4"
+					:multiple="true"
+					:deletable="true"
+					del-bg-color="#fa3534"
+					upload-text="选择图片"
+					width="140"
+					height="140"
+					preview-full-image
+					@on-success="onCoverSuccess"
+					@on-remove="onCoverRemove"
+				/>
 			</view>
 			<view class="upload-row">
 				<text class="label required">商品详情图</text>
-				<view class="tip">支持jpg、png格式</view>
-				<view class="upload-box" @click="pickImage('detail')">
-					<image v-if="form.detail" :src="form.detail" mode="aspectFill"></image>
-					<template v-else>
-						<text class="plus">+</text>
-						<text>上传图片</text>
-					</template>
-				</view>
+				<view class="tip">支持jpg、png格式,最多20张</view>
+				<u-upload
+					:action="uploadAction"
+					:file-list="fileList.detail"
+					:form-data="uploadFormData"
+					:max-count="20"
+					:multiple="true"
+					:deletable="true"
+					del-bg-color="#fa3534"
+					upload-text="选择图片"
+					width="140"
+					height="140"
+					preview-full-image
+					@on-success="onDetailSuccess"
+					@on-remove="onDetailRemove"
+				/>
 			</view>
 		</view>
 
@@ -174,6 +190,7 @@
 
 <script>
 import { createMockDishes, buildSpecCombos } from '../mock.js';
+import configService from '@/common/service/config.service';
 
 const DISH_KEY = 'merchantDish_list';
 const DRAFT_KEY = 'merchantDish_draft';
@@ -227,6 +244,13 @@ export default {
 			editId: null,
 			// 是否开通团餐功能(审核通过后可用团餐归属)
 			groupMealOpened: false,
+			uploadAction: configService.apiUrl + '/sys/common/upload',
+			imageHttp: configService.apiUrl + '/',
+			uploadFormData: { biz: 'temp' },
+			fileList: {
+				cover: [],
+				detail: []
+			},
 			form: {
 				belong: 'store',
 				category: 'seasonal',
@@ -346,15 +370,54 @@ export default {
 			this.form.category = item.category;
 			this.form.name = item.name;
 			this.form.productType = item.productType;
-			this.form.cover = item.image;
-			this.form.detail = item.image;
+			this.form.cover = item.image || '';
+			this.form.detail = item.detailImages || item.image || '';
 			this.form.isCombo = item.isCombo ? 1 : 0;
 			this.form.price = String(item.price);
 			this.form.originPrice = String(item.originPrice);
 			this.form.stock = String(item.stock);
 			this.form.specMode = 'single';
+			this.fileList = {
+				cover: this.toFileList(this.form.cover),
+				detail: this.toFileList(this.form.detail)
+			};
 			this.applySpecLock();
 		},
+		toFileList(value) {
+			if (!value) return [];
+			return String(value)
+				.split(',')
+				.filter(Boolean)
+				.map((url) => ({ url }));
+		},
+		processImageList(lists, formKey) {
+			const urls = lists
+				.map((item) => {
+					if (item.response && item.response.message) {
+						return this.imageHttp + item.response.message;
+					}
+					if (item.url) return item.url;
+					return '';
+				})
+				.filter(Boolean);
+			this.form[formKey] = urls.join(',');
+		},
+		onCoverSuccess(res, index, lists) {
+			this.fileList.cover = lists;
+			this.processImageList(lists, 'cover');
+		},
+		onCoverRemove(index, lists) {
+			this.fileList.cover = lists;
+			this.processImageList(lists, 'cover');
+		},
+		onDetailSuccess(res, index, lists) {
+			this.fileList.detail = lists;
+			this.processImageList(lists, 'detail');
+		},
+		onDetailRemove(index, lists) {
+			this.fileList.detail = lists;
+			this.processImageList(lists, 'detail');
+		},
 		onBelongChange(val) {
 			const belong = val || this.form.belong;
 			this.form.belong = belong;
@@ -381,14 +444,6 @@ export default {
 		onTypePick(e) {
 			this.form.productType = e.value;
 		},
-		pickImage(field) {
-			uni.chooseImage({
-				count: 1,
-				success: (res) => {
-					this.form[field] = res.tempFilePaths[0];
-				}
-			});
-		},
 		goCombo() {
 			uni.setStorageSync('merchantDish_combo_editing', this.form.comboItems || []);
 			uni.navigateTo({ url: '/pages/merchantDish/dish/combo' });
@@ -454,8 +509,13 @@ export default {
 				uni.showToast({ title: '请完善必填信息', icon: 'none' });
 				return;
 			}
+			const coverUrls = (this.form.cover || '').split(',').filter(Boolean);
 			const draft = {
 				...this.form,
+				coverImages: this.form.cover,
+				// 列表缩略图取封面第一张
+				cover: coverUrls[0] || '',
+				detailImages: this.form.detail,
 				isEdit: this.isEdit,
 				editId: this.editId,
 				combos: this.form.specMode === 'multi' ? buildSpecCombos(this.form.specs) : []
@@ -543,27 +603,8 @@ export default {
 		color: #999;
 		margin: 8rpx 0 16rpx;
 	}
-	.upload-box {
-		width: 160rpx;
-		height: 160rpx;
-		background: #f7f8fc;
-		border-radius: 12rpx;
-		display: flex;
-		flex-direction: column;
-		align-items: center;
-		justify-content: center;
-		font-size: 22rpx;
-		color: #999;
-		overflow: hidden;
-		.plus {
-			font-size: 48rpx;
-			line-height: 1;
-			margin-bottom: 4rpx;
-		}
-		image {
-			width: 100%;
-			height: 100%;
-		}
+	::v-deep .u-add-tips {
+		margin-top: 10rpx;
 	}
 }
 .spec-block {