瀏覽代碼

不同相机上传图片和表单提交

Ming 3 年之前
父節點
當前提交
9d41ff3852
共有 1 個文件被更改,包括 30 次插入31 次删除
  1. 30 31
      pages/siteArchive/siteArchiveAdd/siteArchiveAdd.vue

+ 30 - 31
pages/siteArchive/siteArchiveAdd/siteArchiveAdd.vue

@@ -65,8 +65,8 @@
 					<evan-radio v-model="formMess.cable_hole" label="0" class="margin-right-xl">否</evan-radio>
 					<evan-radio v-model="formMess.cable_hole" label="2" class="margin-right-xs">其他</evan-radio>
 					<input type="text" style="width:30%" v-model="formMess.cable_hole_describe">
-					<image mode="aspectFit" :src="this.cable_hole_image?this.cable_hole_image:'/static/cameraIcon.png'"
-						data-mark="cable_hole" @tap="goCamera($event)"></image>
+					<image mode="aspectFit" :src="imageList[0].cable_hole_image?imageList[0].cable_hole_image:'/static/cameraIcon.png'"
+						data-mark="cable_hole" @tap="goCamera('cable_hole_image','cable_hole_picture')"></image>
 				</view>
 			</view>
 			<view class="form-item extraDis radioSec">
@@ -75,10 +75,10 @@
 					<evan-radio v-model="formMess.damage" label="1" class="margin-right-xl">是</evan-radio>
 					<evan-radio v-model="formMess.damage" label="0" class="margin-right-xl">否</evan-radio>
 					<evan-radio v-model="formMess.damage" label="2" class="margin-right-xs">其他</evan-radio>
-					<input type="text" style="width:30%">
+					<input type="text" style="width:30%" v-model="formMess.damage_describe">
 					<!-- <image src="../../../static/cameraIcon.png"></image> -->
-					<image mode="aspectFit" :src="this.damage_image?this.damage_image:'/static/cameraIcon.png'"
-						data-mark="2" @tap="goCamera($event)"></image>
+					<image mode="aspectFit" :src="imageList[0].damage_image?imageList[0].damage_image:'/static/cameraIcon.png'"
+						data-mark="2" @tap="goCamera('damage_image','damage_picture')"></image>
 				</view>
 			</view>
 			<view class="form-item extraDis radioSec">
@@ -546,8 +546,16 @@
 				},
 
 				id: 0,
-				detailInfo: {}
-
+				detailInfo: {},
+				//上传图片
+				imageList:[	
+					{cable_hole_image:'',damage_image:''},
+					{cable_hole_picture:'',damage_picture:''}
+				]
+					
+					
+				
+				
 
 			}
 		},
@@ -573,25 +581,8 @@
 		},
 		methods: {
 
-			goCamera(event) {
-				
-				console.log(event.currentTarget.dataset.mark)
-				const that = this;
-				
-				let pictureUrlImage = '';
-				let pictureUrlPicture = '';
-				switch (event.currentTarget.dataset.mark) {
-					case 'cable_hole':
-						pictureUrlImage = 'cable_hole_image';
-						pictureUrlPicture = 'cable_hole_picture'
-						break;
-					case 'damage':
-						pictureUrlImage = damage_image;
-						pictureUrlPicture = damage_picture;
-						break;
-					default:
-						break;
-				}
+			goCamera(name,upimage) {
+					const that = this;
 
 
 				uni.chooseImage({
@@ -599,18 +590,20 @@
 					sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
 					sourceType: ['camera'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
 					success: function(res) {
-						that.cable_hole_image = res.tempFilePaths[0]
+						that.imageList[0][name] = res.tempFilePaths[0];
 						console.log(res.tempFilePaths[0])
 						uni.uploadFile({
 							url: 'https://wx.ewoogi.com/wx/USKYOF/USKYOF.php/Home/MonitoringReporting/setUpload',
-							filePath: that.formMess.cable_hole_picture,
+							filePath: that.imageList[0][name],
 							name: 'file',
 							formData: {
 								'user': 'test'
 							},
 							success: (uploadFileRes) => {
-								that.formMess.cable_hole_picture = JSON.parse(uploadFileRes.data)
-									.img_url
+								// that.formMess.cable_hole_picture = JSON.parse(uploadFileRes.data)
+								// 	.img_url;
+									that.imageList[1][upimage]=JSON.parse(uploadFileRes.data)
+									.img_url;
 							}
 						});
 					}
@@ -723,8 +716,14 @@
 
 					"cable_hole": this.formMess.cable_hole,
 					"cable_hole_describe": this.formMess.cable_hole_describe,
-					"cable_hole_picture": this.formMess.cable_hole_picture,
+					"cable_hole_picture": this.imageList[1].cable_hole_picture,
+					
+					
 					"damage": this.formMess.damage,
+					"damage_describe": this.formMess.damage_describe,
+					"damage_picture": this.imageList[1].damage_picture,
+					
+					
 					"water_leakage": this.formMess.water_leakage,
 					"annihilator_insufficient_configuration": this.formMess
 						.annihilator_insufficient_configuration,