From 244d89b41c0e0e995d38f635a126a0959b9ba25b Mon Sep 17 00:00:00 2001
From: wjt <1797368093@qq.com>
Date: 星期二, 25 六月 2024 18:16:42 +0800
Subject: [PATCH] 问题处理

---
 policy/components/upload.vue |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/policy/components/upload.vue b/policy/components/upload.vue
index 8538aa7..6721977 100644
--- a/policy/components/upload.vue
+++ b/policy/components/upload.vue
@@ -2,7 +2,7 @@
 	<view>
 		<view class="grid-box">
 			<view class="image-box" v-for="(item,index) in imageList" :key="index">
-				<image :src="item" mode="aspectFit"></image>
+				<image :src="baseUrl+item" mode="aspectFit"></image>
 				<image src="/static/policy/close.png" mode="widthFix" @click="delImage(index)" class="close"></image>
 			</view>
 			<view class="cam-box" @click="upload" v-if="imageList.length < max">
@@ -13,6 +13,8 @@
 </template>
 
 <script>
+	import { upload } from '@/common/upload.js'
+	import { config } from '@/common/config.js'
 	export default {
 		props: {
 			max: {
@@ -21,12 +23,13 @@
 			},
 			maxSize: {
 				type: Number,
-				default: 2 * 1024 * 1024
+				default: 10 * 1024 * 1024
 			}
 		},
 		data() {
 			return {
-				imageList: []
+				imageList: [],
+				baseUrl: config.baseUrl
 			}
 		},
 		methods: {
@@ -42,9 +45,25 @@
 							})
 							return
 						}
-						this.imageList.push(val.tempFilePaths[0])
+						// console.log(val.tempFilePaths)
+						// this.imageList.push(...val.tempFilePaths)
+						val.tempFilePaths.forEach(async item => {
+							await this.uploadImage(item)
+						})
 					}
 				})
+			},
+			async uploadImage(file) {
+				try{
+					const code = await upload(file)
+					this.imageList.push(code.fileName)
+				} catch(err) {
+					uni.showToast({
+						title: '鏂囦欢涓婁紶澶辫触锛岃绋嶅悗閲嶈瘯',
+						icon: 'none'
+					})
+					console.log(err)
+				}
 			},
 			delImage(index) {
 				this.imageList.splice(index,1)
@@ -60,10 +79,13 @@
 		width: 200rpx;
 		height: 200rpx;
 		text-align: center;
-		line-height: 200rpx;
+		// line-height: 200rpx;
+		display: flex;
+		justify-content: center;
+		align-items: center;
 		image{
-			width: 28rpx;
-			height: 28rpx;
+			width: 60rpx;
+			height: 60rpx;
 		}
 	}
 	.grid-box{

--
Gitblit v1.9.1