Przeglądaj źródła

修改门头照+跳转

付晓文。 2 miesięcy temu
rodzic
commit
e5503d2ca4
2 zmienionych plików z 14 dodań i 22 usunięć
  1. 2 3
      pages/groupMeal/goods/form-step2.vue
  2. 12 19
      pages/store/headPhoto.vue

+ 2 - 3
pages/groupMeal/goods/form-step2.vue

@@ -271,9 +271,8 @@ export default {
 		},
 		goBackToList() {
 			setTimeout(() => {
-				uni.redirectTo({
-					url: '/pages/groupMeal/goods/list'
-				});
+				// 返回两层(step2 + step1),回到进入表单前的列表页,避免页面栈残留 step1
+				uni.navigateBack({ delta: 2 });
 			}, 500);
 		},
 		buildDetails() {

+ 12 - 19
pages/store/headPhoto.vue

@@ -16,7 +16,7 @@
 					</view>
 					<view class="grid col-4 grid-square flex-sub booder-top">
 						<view class="bg-img" v-for="(item, index) in form.photo" :key="index" @tap="ViewImage"
-							:data-url="form.headPhoto[index]">
+							:data-url="item">
 							<image :src="item" mode="aspectFill"></image>
 							<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
 								<text class='cuIcon-close'></text>
@@ -76,7 +76,7 @@
 				let obj = JSON.parse(decodeURIComponent(data.params));
 				console.log('111111',obj)
 				// this.video = obj.video ? obj.video : ''
-				obj.photo = obj.photo ? obj.headPhoto.split(',').filter(id => id !== '') : []
+				obj.photo = obj.headPhoto ? obj.headPhoto.split(',').filter(id => id !== '') : []
 				this.form = obj
 				
 			}
@@ -95,6 +95,9 @@
 			}
 		},
 		methods: {
+			syncHeadPhoto() {
+				this.form.headPhoto = (this.form.photo || []).join(',')
+			},
 			back() {
 				uni.navigateBack()
 			},
@@ -116,10 +119,8 @@
 					confirmText: '确定',
 					success: res => {
 						if (res.confirm) {
-							console.log('删除前的图片', this.form.headPhoto)
-							// this.photoList.splice(e.currentTarget.dataset.index, 1)
 							this.form.photo.splice(e.currentTarget.dataset.index, 1)
-							console.log('删除后的图片', this.form.photo)
+							this.syncHeadPhoto()
 						}
 					}
 				})
@@ -142,19 +143,11 @@
 								success: (files) => {
 									let data = JSON.parse(files.data);
 									if (data.success) {
-										let temp = this.form.headPhoto.split(',')
-										if (this.form.headPhoto.split(',').length > 0) {
-											// this.photoList = this.photoList.concat(res.tempFilePaths)
-											this.form.photo.push(configService.apiUrl + '/' + data.message)
-											this.form.headPhoto+(configService.apiUrl + '/' + data.message)
-											temp.push(configService.apiUrl + '/' + data.message)
-											 this.form.headPhoto = temp.join(',')
-											console.log('上传后的图片', this.form.headPhoto)
-										} else {
-												console.log('22222')
-											// this.photoList =res.tempFilePaths
-											this.form.headPhoto = [configService.apiUrl + '/' + data.message]
+										if (!this.form.photo) {
+											this.form.photo = []
 										}
+										this.form.photo.push(configService.apiUrl + '/' + data.message)
+										this.syncHeadPhoto()
 									}
 								}
 							})
@@ -165,14 +158,14 @@
 			},
 			ViewImage(e) {
 				uni.previewImage({
-					urls: this.form.headPhoto,
+					urls: this.form.photo,
 					current: e.currentTarget.dataset.url
 				});
 			},
 			sumbit() {
 				let data = {
 					merchantId: uni.getStorageSync(USER_INFO).merchantId,
-					headPhoto: this.form.headPhoto,
+					headPhoto: (this.form.photo || []).join(','),
 					id:this.form.headPhotoId
 				}
 				if (this.form.headPhotoStatus == null) {