Browse Source

修改评价上传图片

leaf 4 months ago
parent
commit
32e20569eb

+ 28 - 29
pages/index/CfAppraise.vue

@@ -38,9 +38,9 @@
 						</view>
 						<!-- 最多三张 -->
 						<view class="picture-item" v-if="true">
-							<uni-file-picker class="file-picker" limit="3" :auto-upload="false" del-icon="true"
-								file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model="fileList"
-								@select="onSelectFile" @delete="onDelFile">
+							<uni-file-picker class="file-picker" limit="3" :auto-upload="false" :del-icon="true"
+								file-extname='png,git,jpeg,pdf,jpg' file-mediatype="image" v-model="fileList" @select="onSelectFile"
+								@delete="onDelFile">
 								<view class="cf-appraise-edit-add">
 									<text class="iconfont">&#xe69f;</text>
 								</view>
@@ -70,19 +70,19 @@
 	import rest from '@/stores/rest'
 
 	import CfAppraiseStar from './CfAppraiseStar.vue'
-	
+
 
 	const props = defineProps({
 		ptwybh: {
 			type: String,
 			default: ""
 		},
-		isEdit : {
+		isEdit: {
 			type: Boolean,
 			default: false
 		}
 	})
-	
+
 
 	const loaded = ref(false)
 	const starText = [
@@ -104,16 +104,15 @@
 
 	// 上传图片
 	const onSelectFile = async (res) => {
-		console.log("上传",res)
+		console.log("上传", res)
 		if (!res.tempFilePaths.length) return;
 		uni.showLoading({
 			title: '',
 			mask: true
 		});
 		for (var i = 0; i < res.tempFilePaths.length; i++) {
-			let blobUrl = res.tempFiles[i].file;
-			console.log("上传",blobUrl)
-			let uploadedFile = await rest.upload(blobUrl);
+			let uploadedFile = await rest.upload(res.tempFilePaths[i]);
+
 			if (!uploadedFile) {
 				dlg.error("上传失败,请重试!");
 				uni.hideLoading();
@@ -140,33 +139,33 @@
 	}
 
 
-	const onApply = async() => {
+	const onApply = async () => {
 		const formData = {
 			orderId: props.ptwybh,
-		    zhpj: info.value.comprehensiveVal,
-		    jyxg: info.value.starVal[0],
-		    kfys: info.value.starVal[1],
-		    jyzl: info.value.starVal[2],
-		    wlfw: info.value.starVal[3],
-		    content: info.value.text,
-		    image: info.value.imgList,
-		    anonymity: info.value.anonymous ? 1 : 0
+			zhpj: info.value.comprehensiveVal,
+			jyxg: info.value.starVal[0],
+			kfys: info.value.starVal[1],
+			jyzl: info.value.starVal[2],
+			wlfw: info.value.starVal[3],
+			content: info.value.text,
+			image: info.value.imgList,
+			anonymity: info.value.anonymous ? 1 : 0
 		}
 		let fields = {
 			'orderId': '订单ID不能为空',
-		    'zhpj': '综合评价不能为空',
-		    'jyxg': '就医效果不能为空',
-		    'kfys': '开方医生不能为空',
-		    'jyzl': '煎药质量不能为空',
-		    'wlfw': '物流服务不能为空'
+			'zhpj': '综合评价不能为空',
+			'jyxg': '就医效果不能为空',
+			'kfys': '开方医生不能为空',
+			'jyzl': '煎药质量不能为空',
+			'wlfw': '物流服务不能为空'
 		};
 		for (let key in fields) {
-		    if (!formData[key]) {
-		        dlg.error(fields[key]);
-		        return;
-		    }
+			if (!formData[key]) {
+				dlg.error(fields[key]);
+				return;
+			}
 		}
-		console.log("processedData", formData)
+		console.log("processedData", formData, files.value)
 		// await rest.post('/zyyp/prescription-evaluate/create',formData)
 		dlg.success('操作成功')
 	}

+ 12 - 2
stores/rest.ts

@@ -36,6 +36,16 @@ function getHeader() {
 }
 
 
+function getFileHeader() {
+	let header = { "Authorization": "Bearer test1" };
+	//获取token
+	let token = getToken()
+	if (token) {
+		header["Authorization"] = "Bearer " + token;
+	}
+	return header;
+}
+
 
 const fetch = async (method : any, url : string, data : any, loading = false) => {
 
@@ -102,8 +112,8 @@ const uploadSync = (filePath) => {
 		uni.uploadFile({
 			url: BASE_URL + '/admin-api/infra/file/upload',
 			// file: image,
-			header: getHeader(),
-			file: filePath,
+			header: getFileHeader(),
+			filePath: filePath,
 			name: 'file',
 			success: (res) => {
 				let result = JSON.parse(res.data);

+ 18 - 17
uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue

@@ -9,7 +9,7 @@
 				</view>
 				<view v-if="(item.progress && item.progress !== 100) ||item.progress===0 " class="file-picker__progress">
 					<progress class="file-picker__progress-item" :percent="item.progress === -1?0:item.progress" stroke-width="4"
-					 :backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
+						:backgroundColor="item.errMsg?'#ff5a5f':'#EBEBEB'" />
 				</view>
 				<view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item,index)">
 					点击重试
@@ -30,7 +30,7 @@
 <script>
 	export default {
 		name: "uploadImage",
-		emits:['uploadFiles','choose','delFile'],
+		emits: ['uploadFiles', 'choose', 'delFile'],
 		props: {
 			filesList: {
 				type: Array,
@@ -38,7 +38,7 @@
 					return []
 				}
 			},
-			disabled:{
+			disabled: {
 				type: Boolean,
 				default: false
 			},
@@ -64,9 +64,9 @@
 				type: Boolean,
 				default: true
 			},
-			readonly:{
-				type:Boolean,
-				default:false
+			readonly: {
+				type: Boolean,
+				default: false
 			}
 		},
 		computed: {
@@ -107,8 +107,8 @@
 				}
 
 				let classles = ''
-				for(let i in obj){
-					classles+= `${i}:${obj[i]};`
+				for (let i in obj) {
+					classles += `${i}:${obj[i]};`
 				}
 				return classles
 			},
@@ -134,8 +134,8 @@
 					}
 				}
 				let classles = ''
-				for(let i in obj){
-					classles+= `${i}:${obj[i]};`
+				for (let i in obj) {
+					classles += `${i}:${obj[i]};`
 				}
 				return classles
 			}
@@ -152,10 +152,10 @@
 			},
 			prviewImage(img, index) {
 				let urls = []
-				if(Number(this.limit) === 1&&this.disablePreview&&!this.disabled){
+				if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {
 					this.$emit("choose")
 				}
-				if(this.disablePreview) return
+				if (this.disablePreview) return
 				this.filesList.forEach(i => {
 					urls.push(i.url)
 				})
@@ -273,14 +273,15 @@
 		align-items: center;
 		justify-content: center;
 		position: absolute;
-		top: 3px;
-		right: 3px;
-		height: 26px;
-		width: 26px;
+		top: 0; //3px;
+		right: 0; //3px;
+		height: 48rpx;
+		width: 48rpx;
 		border-radius: 50%;
 		background-color: rgba(0, 0, 0, 0.5);
 		z-index: 2;
 		transform: rotate(-45deg);
+		scale: 0.667;
 	}
 
 	.icon-del {
@@ -289,4 +290,4 @@
 		background-color: #fff;
 		border-radius: 2px;
 	}
-</style>
+</style>