2023-09-06 11:28:22 +08:00
|
|
|
<template>
|
2023-10-17 18:13:53 +08:00
|
|
|
<div class="leftTop">
|
|
|
|
|
<Card title="项目展示">
|
|
|
|
|
<div class="top-tab">
|
|
|
|
|
<div
|
|
|
|
|
class="tab-box"
|
|
|
|
|
:style="boxStyle(item)"
|
|
|
|
|
v-for="(item, index) in topText"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
@click="activeBtn(item, index)"
|
|
|
|
|
>
|
|
|
|
|
{{ item.title }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-04-17 21:57:06 +08:00
|
|
|
|
|
|
|
|
<div class="href-content" v-if="showVideo == 1">
|
|
|
|
|
<el-carousel indicator-position="none" height="450px" style="width: 76%;">
|
|
|
|
|
<el-carousel-item v-for="(item, index) in videoList" :key="item.id">
|
|
|
|
|
<ckplayerComp
|
|
|
|
|
:name="index"
|
|
|
|
|
:poster="''"
|
|
|
|
|
:deviceIp="`http://${item.account}:${item.password}`"
|
|
|
|
|
:videoUrls="item.serialNumber"
|
|
|
|
|
:autoPlay="true"
|
|
|
|
|
></ckplayerComp>
|
|
|
|
|
</el-carousel-item>
|
|
|
|
|
</el-carousel>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="videoBox" v-if="showVideo == 2" @mouseenter="showChangeVideo = true" @mouseleave="showChangeVideo = false">
|
2023-10-17 18:13:53 +08:00
|
|
|
<el-upload
|
|
|
|
|
:action="BASEURL + '/upload/image'"
|
|
|
|
|
:on-success="file => handleSuccessTwo(file, 1)"
|
|
|
|
|
:on-error="file => handleError(file, 1)"
|
2023-10-18 17:58:53 +08:00
|
|
|
:beforeUpload="file => handleBeforeUploadVideo(file, 1)"
|
2023-10-17 18:13:53 +08:00
|
|
|
name="files"
|
|
|
|
|
:show-file-list="false"
|
|
|
|
|
>
|
|
|
|
|
<!-- 更换视频 -->
|
|
|
|
|
<span class="change-video" v-if="showChangeVideo">更换视频</span>
|
|
|
|
|
</el-upload>
|
2023-10-16 16:14:37 +08:00
|
|
|
<video :src="BASEURL + '/image/' + projectData.videoUrl" class="videos" autoplay controls loop></video>
|
2023-09-07 11:27:21 +08:00
|
|
|
</div>
|
2024-04-17 21:57:06 +08:00
|
|
|
<div class="imgBox" v-if="showVideo == 3">
|
2023-10-17 18:13:53 +08:00
|
|
|
<div class="imgs" @mouseenter="showChangeImg = true" @mouseleave="showChangeImg = false">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="BASEURL + '/upload/image'"
|
|
|
|
|
:on-success="file => handleSuccess(file, 1)"
|
|
|
|
|
:on-error="file => handleError(file, 1)"
|
2023-10-18 17:58:53 +08:00
|
|
|
:beforeUpload="file => handleBeforeUploadPic(file, 1)"
|
2023-10-17 18:13:53 +08:00
|
|
|
name="files"
|
|
|
|
|
:show-file-list="false"
|
|
|
|
|
>
|
|
|
|
|
<!-- 更换图片 -->
|
|
|
|
|
<span class="change-video" v-if="showChangeImg">更换图片</span>
|
|
|
|
|
</el-upload>
|
|
|
|
|
<img :src="BASEURL + '/image/' + picUrl" alt="" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-09-07 11:27:21 +08:00
|
|
|
</Card>
|
|
|
|
|
</div>
|
2023-09-06 11:28:22 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2023-09-07 11:27:21 +08:00
|
|
|
import Card from "@/components/card.vue";
|
2023-10-16 16:14:37 +08:00
|
|
|
import { ref, onMounted, watch } from "vue";
|
2023-10-17 18:13:53 +08:00
|
|
|
import { GlobalStore } from "@/stores";
|
|
|
|
|
import { ElMessage } from "element-plus";
|
|
|
|
|
|
|
|
|
|
import { editProjectInfo, eidtProjectShowConfig, queryBySnData } from "@/api/modules/projectOverview";
|
2024-04-17 21:57:06 +08:00
|
|
|
import { selectLiveVideoListApi } from "@/api/modules/video";
|
|
|
|
|
import ckplayerComp from "./ckplayerComp.vue";
|
2023-10-17 18:13:53 +08:00
|
|
|
|
|
|
|
|
const store = GlobalStore();
|
2024-04-17 21:57:06 +08:00
|
|
|
const videoList = ref([] as any);
|
2023-10-16 16:14:37 +08:00
|
|
|
// ts
|
|
|
|
|
type Props = {
|
|
|
|
|
projectData?: any; // 传入项目信息
|
|
|
|
|
};
|
|
|
|
|
// withDefaults 定义默认值(传入的数据类型同默认值)
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2023-10-17 18:13:53 +08:00
|
|
|
projectData: {}
|
2023-10-16 16:14:37 +08:00
|
|
|
});
|
|
|
|
|
// 项目信息
|
2023-10-17 18:13:53 +08:00
|
|
|
const projectData = ref({} as any);
|
2023-10-16 16:14:37 +08:00
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.projectData,
|
|
|
|
|
newVal => {
|
|
|
|
|
// console.log(newVal, "newVal");
|
|
|
|
|
if (newVal) {
|
|
|
|
|
// props.xData = newVal;
|
|
|
|
|
projectData.value = newVal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2023-10-17 18:13:53 +08:00
|
|
|
//效果图
|
|
|
|
|
const picUrl = ref("" as any);
|
|
|
|
|
|
2023-10-16 16:14:37 +08:00
|
|
|
const BASEURL = import.meta.env.VITE_API_URL;
|
2023-10-17 18:13:53 +08:00
|
|
|
// 显示视频
|
2024-04-17 21:57:06 +08:00
|
|
|
const showVideo = ref(1 as any);
|
2023-10-17 18:13:53 +08:00
|
|
|
|
|
|
|
|
// 显示更换图片
|
|
|
|
|
const showChangeImg = ref(false as any);
|
|
|
|
|
|
|
|
|
|
// 显示更换视频
|
|
|
|
|
const showChangeVideo = ref(false as any);
|
|
|
|
|
|
|
|
|
|
let topText = ref([
|
2024-04-17 21:57:06 +08:00
|
|
|
{ id: 1, title: "现场视频", isActive: true },
|
|
|
|
|
{ id: 2, title: "宣传视频", isActive: false },
|
|
|
|
|
{ id: 3, title: "效果图", isActive: false }
|
2023-10-17 18:13:53 +08:00
|
|
|
]);
|
2024-04-17 21:57:06 +08:00
|
|
|
const getVideoList = async () => {
|
|
|
|
|
let res: any = await selectLiveVideoListApi({
|
|
|
|
|
projectSn: store.sn
|
|
|
|
|
});
|
|
|
|
|
console.log(res,'445566')
|
|
|
|
|
if(res.result && res.result.extend1){
|
|
|
|
|
videoList.value = JSON.parse(res.result.extend1).result.videoList;
|
|
|
|
|
console.log(videoList.value,'112233')
|
|
|
|
|
// 为了解决视频播放器渲染,第二个总是会默认显示一半,我动态设置样式让视图刷新,只要设置百分百就有问题,所以只能使用此方法
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// 获取所有的 video 元素
|
|
|
|
|
var videos = document.querySelectorAll(".href-content video")
|
|
|
|
|
// var videos = document.getElementsByTagName("video");
|
|
|
|
|
// 遍历所有的 video 元素
|
|
|
|
|
for (var i = 0; i < videos.length; i++) {
|
|
|
|
|
// 修改视频元素的样式
|
|
|
|
|
videos[i].style.width = "99.9%";
|
|
|
|
|
videos[i].style.height = "99.9%";
|
|
|
|
|
}
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-10-17 18:13:53 +08:00
|
|
|
|
|
|
|
|
function boxStyle(item: any) {
|
|
|
|
|
if (item.isActive) {
|
|
|
|
|
let choiseStyle = {
|
|
|
|
|
color: "#fff"
|
|
|
|
|
};
|
|
|
|
|
return choiseStyle;
|
|
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
let tabIndex = ref(1 as any);
|
|
|
|
|
function activeBtn(item: any) {
|
|
|
|
|
let currentState = item.isActive;
|
|
|
|
|
if (!currentState) {
|
|
|
|
|
topText.value.forEach(el => {
|
|
|
|
|
el.isActive = false;
|
|
|
|
|
});
|
|
|
|
|
item.isActive = !currentState;
|
|
|
|
|
tabIndex.value = item.id;
|
|
|
|
|
}
|
2024-04-17 21:57:06 +08:00
|
|
|
showVideo.value = item.id;
|
|
|
|
|
console.log(showVideo.value)
|
2023-10-17 18:13:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uploadFail = () => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: "上传失败,请重试",
|
|
|
|
|
type: "warning"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-18 17:58:53 +08:00
|
|
|
const fileTypeFail = (text: any) => {
|
2023-10-17 18:13:53 +08:00
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
2023-10-18 17:58:53 +08:00
|
|
|
message: text,
|
2023-10-17 18:13:53 +08:00
|
|
|
type: "warning"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const uploadSuccess = () => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: "上传成功",
|
|
|
|
|
type: "success"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-18 17:58:53 +08:00
|
|
|
// 视频文件上传 之前
|
|
|
|
|
function handleBeforeUploadVideo(file: any) {
|
2023-10-17 18:13:53 +08:00
|
|
|
console.log(file, "上传之前");
|
|
|
|
|
let fileType = file.type.split("/")[0];
|
2023-10-18 17:58:53 +08:00
|
|
|
if (fileType == "video") {
|
2023-10-17 18:13:53 +08:00
|
|
|
return true;
|
|
|
|
|
} else {
|
2023-10-18 17:58:53 +08:00
|
|
|
fileTypeFail("请选择正确的视频文件"); //"请选择正确的文件"
|
2023-10-17 18:13:53 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-18 17:58:53 +08:00
|
|
|
|
|
|
|
|
// 图片文件上传 之前
|
|
|
|
|
function handleBeforeUploadPic(file: any) {
|
|
|
|
|
console.log(file, "上传之前");
|
|
|
|
|
let fileType = file.type.split("/")[0];
|
|
|
|
|
if (fileType == "image") {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
fileTypeFail("请选择正确的图片文件"); //"请选择正确的文件"
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-17 18:13:53 +08:00
|
|
|
//上传失败
|
|
|
|
|
function handleError(file: any) {
|
|
|
|
|
console.log(file, "上传失败");
|
|
|
|
|
uploadFail(); //"上传失败,请重试"
|
|
|
|
|
}
|
|
|
|
|
// 效果图上传成功
|
|
|
|
|
function handleSuccess(file: any) {
|
|
|
|
|
console.log("效果图上传成功", file);
|
|
|
|
|
if (file.code == 200 || file.status == "SUCCESS") {
|
|
|
|
|
console.log(file);
|
|
|
|
|
let url = file.data[0].imageUrl;
|
|
|
|
|
saveEffectData(url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 视频上传成功
|
|
|
|
|
function handleSuccessTwo(file: any) {
|
|
|
|
|
if (file.code == 200 || file.status == "SUCCESS") {
|
|
|
|
|
console.log(file, "上传成功");
|
|
|
|
|
let url = file.data[0].imageUrl;
|
|
|
|
|
// this.imgUrl = url;
|
|
|
|
|
saveOrDeleteVideo(url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//效果图 保存
|
|
|
|
|
function saveEffectData(url: any) {
|
|
|
|
|
// let configValue = JSON.stringify(url);
|
|
|
|
|
let data = {
|
|
|
|
|
projectSn: store.sn,
|
|
|
|
|
showType: 3,
|
|
|
|
|
showTitle: "效果图", //'效果图'
|
|
|
|
|
configValue: url
|
|
|
|
|
};
|
|
|
|
|
eidtProjectShowConfig(data).then((res: any) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
getQueryBySnData();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询效果图
|
|
|
|
|
function getQueryBySnData() {
|
|
|
|
|
queryBySnData({
|
|
|
|
|
projectSn: store.sn,
|
|
|
|
|
showType: 3
|
|
|
|
|
}).then((res: any) => {
|
|
|
|
|
console.log(res, "效果图");
|
2023-12-08 18:34:22 +08:00
|
|
|
if (res.result) {
|
|
|
|
|
picUrl.value = res.result.configValue;
|
|
|
|
|
}
|
2023-10-17 18:13:53 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// //保存或删除宣传视频
|
|
|
|
|
function saveOrDeleteVideo(url) {
|
|
|
|
|
editProjectInfo({
|
|
|
|
|
projectSn: store.sn,
|
|
|
|
|
videoUrl: url
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log("保存成功", res);
|
|
|
|
|
uploadSuccess(); //"上传成功"
|
|
|
|
|
projectData.value.videoUrl = url;
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-13 11:08:23 +08:00
|
|
|
//将方法暴露给父组件
|
|
|
|
|
defineExpose({
|
|
|
|
|
getQueryBySnData
|
|
|
|
|
})
|
2024-04-17 21:57:06 +08:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await getVideoList();
|
2023-10-17 18:13:53 +08:00
|
|
|
getQueryBySnData();
|
|
|
|
|
});
|
2023-09-06 11:28:22 +08:00
|
|
|
</script>
|
|
|
|
|
|
2023-09-07 11:27:21 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.leftTop {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2023-10-17 18:13:53 +08:00
|
|
|
position: relative;
|
2023-09-07 11:27:21 +08:00
|
|
|
.videoBox {
|
|
|
|
|
width: 100%;
|
2023-10-17 18:13:53 +08:00
|
|
|
height: 92%;
|
|
|
|
|
margin-top: 8%;
|
2023-09-07 11:27:21 +08:00
|
|
|
background: url("@/assets/images/comprehensiveManage/project10.png") no-repeat;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
.videos {
|
2023-10-17 18:13:53 +08:00
|
|
|
width: 78%;
|
|
|
|
|
height: 90%;
|
|
|
|
|
margin-left: 11%;
|
|
|
|
|
margin-top: 1%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.imgBox {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 92%;
|
|
|
|
|
margin-top: 8%;
|
|
|
|
|
background: url("@/assets/images/comprehensiveManage/project10.png") no-repeat;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
.imgs {
|
2023-09-07 11:27:21 +08:00
|
|
|
width: 78%;
|
2023-10-18 17:58:53 +08:00
|
|
|
height: 82%;
|
2023-09-07 11:27:21 +08:00
|
|
|
margin: 3% 11%;
|
2023-10-17 18:13:53 +08:00
|
|
|
img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2023-10-18 17:58:53 +08:00
|
|
|
margin-top: 5%;
|
2023-10-17 18:13:53 +08:00
|
|
|
}
|
2023-09-07 11:27:21 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-04-17 21:57:06 +08:00
|
|
|
.href-content {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 92%;
|
|
|
|
|
margin-top: 8%;
|
|
|
|
|
background: url("@/assets/images/comprehensiveManage/project10.png") no-repeat;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
2023-09-07 11:27:21 +08:00
|
|
|
}
|
2023-10-17 18:13:53 +08:00
|
|
|
|
2024-04-17 21:57:06 +08:00
|
|
|
// .href-content {
|
|
|
|
|
// width: 95%;
|
|
|
|
|
// height: 92%;
|
|
|
|
|
// margin: 0 auto;
|
|
|
|
|
// margin-top: 8%;
|
|
|
|
|
// }
|
|
|
|
|
|
2023-10-17 18:13:53 +08:00
|
|
|
.change-video {
|
|
|
|
|
position: absolute;
|
|
|
|
|
background: url("@/assets/images/cardImg.png") no-repeat;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
color: #fff;
|
|
|
|
|
padding: 1% 2%;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
left: 45%;
|
|
|
|
|
top: 55%;
|
|
|
|
|
z-index: 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.top-tab {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 12%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 0 30%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
.tab-box {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
color: rgba(255, 255, 255, 0.3);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-07 11:27:21 +08:00
|
|
|
::v-deep .h-card .content {
|
|
|
|
|
background: none;
|
|
|
|
|
}
|
2023-10-16 16:14:37 +08:00
|
|
|
</style>
|