This commit is contained in:
xuli
2025-11-28 16:42:57 +08:00
parent c8ad7a076c
commit 5d2472eac5
16 changed files with 770 additions and 521 deletions

View File

@@ -45,11 +45,11 @@
<view class="report-list" style="display:block;">
<view class="r-title">问题点位照片或视频 <text>*</text></view>
<view class="img-flex">
<view class="img-show" v-for="(item,index) in imgArr" :key="index">
<img :src="item" />
<view class="img-show" v-for="(item,index) in imgArr" :key="index" @click="showMediaPreview(item)">
<img :src="item.shortUrl" />
</view>
<view class="img-show" v-for="(item,index) in videoArr" :key="index">
<video :src="item" controls></video>
<view class="img-show" v-for="(item,index) in videoArr" :key="index" @click="showMediaPreview(item)">
<video :src="item.url" controls></video>
</view>
<!-- #ifdef APP-PLUS -->
<view class="img-con" @click="chooseMedia">
@@ -69,33 +69,42 @@
</view>
</mescroll-uni>
</view>
<!-- 图片放大 -->
<mediaPreview :visible="isVisible" :url="mediaUrl" @close="handlePreviewClose"></mediaPreview>
</view>
</template>
<script setup>
import { ref,onMounted,onUnmounted,nextTick,computed,reactive } from 'vue'
import { ref,onMounted,onUnmounted,nextTick,computed,reactive, watch } from 'vue'
import { onLoad,onHide} from '@dcloudio/uni-app';
import customHeader from '@/components/customHeader.vue';
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import mediaPreview from "@/components/mediaPreview.vue"
import { getUserInfo } from '@/api/auth.js'
import { problemDetail,problemAdd,problemEdit,minioUpload } from '@/api/polling.js'
import {compressImageUni,getMinioThumbUrl} from '@/utils/common.js'
import {compressImageUni,getFileType} from '@/utils/common.js'
import {showAlert,showLoading,hideLoading} from '@/utils/message.js'
import { MINIO_KEY } from '@/enums/cacheEnums';
let taskId = ref('');//任务id
let groupId = ref('');//组id
let problemId = ref('');//问题id
let realname = ref('');
let desc = ref('');//描述
let minioObj = {};
onLoad(async option => {
// console.log(option)
taskId.value = option.taskId;
groupId.value = option.groupId;
problemId.value = option.problemId;
minioObj = JSON.parse(uni.getStorageSync(MINIO_KEY) || "\{\}")
let userinfo = await getUserInfo({});
realname.value = userinfo.realname
})
// 查询列表
let list = ref([]);
let optionObj = ref({})
@@ -132,7 +141,7 @@ const getList = async () => {
let res = await problemDetail(param);
let data = res||{};
let pointIds = data.pointId.split(",");
let pointIds = data.pointId?.split(",") || [];
data.pointList.forEach(item2=>{
item2.active=false;
for (let i = 0; i < pointIds.length; i++) {
@@ -143,6 +152,25 @@ const getList = async () => {
}
})
// 视频回显
imgArr.value = [];
mediaArr.value=[];
videoArr.value=[];
let fileList =data.problemVedio?.split(",") || [];
fileList.forEach(item=>{
mediaArr.value.push(item)
if(getFileType(item)=='image'){
imgArr.value.push({
shortUrl:minioObj.minioThumbUrl +"/"+item,
url:minioObj.minioUrl +"/"+item,
})
}else if(getFileType(item)=='video'){
videoArr.value.push({
shortUrl:minioObj.minioThumbUrl +"/"+item,
url:minioObj.minioUrl +"/"+item,
})
}
})
optionObj.value = data;
}
@@ -158,14 +186,14 @@ const chooseMedia = () => {
maxDuration: 60, // 拍摄视频最长拍摄时间
camera: 'back',
success: (res) => {
console.log(res)
console.log("chooseMedia=>",res)
res.tempFiles.forEach(async file => {
// tempFilePath
console.log(`文件类型: ${file.fileType}, 文件路径: ${file.tempFilePath}`);
let compressImg = file.tempFilePath;
// 图片进行压缩
if (file.fileType === 'image') {
// #ifdef APP-PLUS
// #ifdef APP-PLUS
// 压缩图片
compressImg = await compressImageUni(file.tempFilePath);
// #endif
@@ -183,9 +211,17 @@ const chooseMedia = () => {
let data = res.data;
mediaArr.value.push(data.fileName);
if (file.fileType === 'image') {// 图片
imgArr.value.push(data.fileUrl)
// imgArr.value.push(data.fileUrl)
imgArr.value.push({
shortUrl:minioObj.minioThumbUrl +"/"+data.fileName,
url:minioObj.minioUrl +"/"+data.fileName,
})
} else if (file.type === 'video') {// 视频
videoArr.value.push(data.fileUrl)
// videoArr.value.push(data.fileUrl)
videoArr.value.push({
shortUrl:minioObj.minioThumbUrl +"/"+data.fileName,
url:minioObj.minioUrl +"/"+data.fileName,
})
}
})
@@ -194,6 +230,21 @@ const chooseMedia = () => {
});
}
// 放大视频或图片
let isVisible= ref(false);//放大处理
let mediaUrl= ref('');//放大地址
let videoShow = ref(true);
const showMediaPreview=(item)=>{
isVisible.value = true;
videoShow.value = false;
mediaUrl.value = item.url
}
const handlePreviewClose=()=>{
isVisible.value = false;
videoShow.value = true;
}
// 红点点击
const handleRound=(item)=>{
item.active=!item.active
@@ -214,25 +265,26 @@ const handleSubmit=()=>{
problemId:problemId.value,
pointId:pointIds.join(","),
problemVedio:mediaArr.value.join(","),
problemDesc:optionObj.problemDesc
problemDesc:optionObj.value.problemDesc
}
console.log("problemEdit=>",param)
// console.log("problemEdit=>",param)
problemEdit(param).then(res=>{
showAlert("新增上报问题成功")
showAlert("修改问题上报成功")
}).finally(()=>{
hideLoading();
})
}else{
let param = {
let param = {
taskId:taskId.value,
groupId:groupId.value,
pointId:pointIds.join(","),
problemVedio:mediaArr.value.join(","),
problemDesc:optionObj.problemDesc
problemDesc:optionObj.value.problemDesc
}
console.log("problemAdd=>",param)
// console.log("problemAdd=>",param)
problemAdd(param).then(res=>{
showAlert("编辑上报问题成功")
showAlert("新建问题上报成功");
problemId.value = res;
}).finally(()=>{
hideLoading();
})