彭宇 hai 1 ano
pai
achega
1f1dcf0b29
Modificáronse 3 ficheiros con 25 adicións e 18 borrados
  1. 13 13
      components/upload/index.vue
  2. 9 2
      main.js
  3. 3 3
      pages/wenba/wenba.vue

+ 13 - 13
components/upload/index.vue

@@ -7,12 +7,12 @@
 			<view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
 				<view
 					v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg'||item.picUrl.substring(item.picUrl.length-4)=='jpeg' ">
-					<image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
+					<image :src="loadImgSrcLocalhost(item)" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
 						@click="showPhoto(index)">
 					</image>
 				</view>
 				<view v-else>
-					<video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
+					<video :src="loadImgSrcLocalhost(item)" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
 				</view>
 				<view @click="remove(index)"
 					style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
@@ -77,10 +77,10 @@
 										_this.$modal.msg(data.msg)
 									} else {
 										if (_this.progress === 100) {
-											_this.imgArr.push(data.data.url)
+											_this.imgArr.push(data.fileName)
 											_this.$modal.msg('上传成功!')
 											_this.photo = false;
-											this.$emit('updateImg',_this.imgArr);
+                      _this.$emit('updateImg',_this.imgArr);
 										}
 									}
 								},
@@ -91,7 +91,7 @@
 								complete: res => {
 									uni.hideLoading();
 									_this.uploading = false;
-			
+
 								}
 							});
 							task.onProgressUpdate(res => {
@@ -105,13 +105,13 @@
 									_this.loading = true
 								}
 							});
-			
+
 						})
-			
+
 					},
 				})
 			},
-			
+
 			choosevideo() {
 				let _this = this;
 				console.log('视频')
@@ -133,10 +133,10 @@
 								} else {
 									//上传成功
 									if (_this.progress === 100) {
-										_this.imgArr.push(data.data.url)
+										_this.imgArr.push(data.fileName)
 										_this.$modal.msg('上传成功!')
 										_this.photo = false;
-										this.$emit('updateImg',_this.imgArr);
+                    _this.$emit('updateImg',_this.imgArr);
 									}
 								}
 							},
@@ -160,7 +160,7 @@
 								_this.loading = true
 							}
 						});
-			
+
 					},
 				})
 			},
@@ -186,8 +186,8 @@
 			},
 		}
 	}
-	
+
 </script>
 
 <style>
-</style>
+</style>

+ 9 - 2
main.js

@@ -19,8 +19,15 @@ Vue.prototype.loadImgSrc = function(img) {
 	return config.baseIconUrl+img;
 }
 
-const app = new Vue({  
+
+//本地上传图片前缀地址
+Vue.prototype.loadImgSrcLocalhost = function(img) {
+	//项目的地址域名,例如百度
+	return config.baseUrl+img;
+}
+
+const app = new Vue({
 	...App
 })
 
-app.$mount()
+app.$mount()

+ 3 - 3
pages/wenba/wenba.vue

@@ -82,8 +82,8 @@ export default {
     data() {
         return {
 			imageList:[
-				'http://119.3.201.155:9000/xczx01.png',
-				'http://119.3.201.155:9000/xczx02.png'
+				'/profile/upload/2024/03/02/D5hjxYkldNxIef093ae65b2128b1293b86a7b537ed98_20240302170757A001.png',
+				'/profile/upload/2024/03/02/D5hjxYkldNxIef093ae65b2128b1293b86a7b537ed98_20240302170757A001.png'
 			],
             wb: [
 				{
@@ -133,7 +133,7 @@ export default {
                 url: '/pages/wenbaxiangqing/wenbaxiangqing'
             });
         },
-		
+
 		updateImg(imgList){
 			this.imageList = imgList;
 		}