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>
|
|
|
|
|
<div class="videoBox" v-if="showVideo" @mouseenter="showChangeVideo = true" @mouseleave="showChangeVideo = false">
|
|
|
|
|
<el-upload
|
|
|
|
|
:action="BASEURL + '/upload/image'"
|
|
|
|
|
:on-success="file => handleSuccessTwo(file, 1)"
|
|
|
|
|
:on-error="file => handleError(file, 1)"
|
|
|
|
|
:beforeUpload="file => handleBeforeUpload(file, 1)"
|
|
|
|
|
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>
|
2023-10-17 18:13:53 +08:00
|
|
|
<div class="imgBox" v-else>
|
|
|
|
|
<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)"
|
|
|
|
|
:beforeUpload="file => handleBeforeUpload(file, 1)"
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
|
|
const store = GlobalStore();
|
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
|
|
|
// 显示视频
|
|
|
|
|
const showVideo = ref(true as any);
|
|
|
|
|
|
|
|
|
|
// 显示更换图片
|
|
|
|
|
const showChangeImg = ref(false as any);
|
|
|
|
|
|
|
|
|
|
// 显示更换视频
|
|
|
|
|
const showChangeVideo = ref(false as any);
|
|
|
|
|
|
|
|
|
|
let topText = ref([
|
|
|
|
|
{ id: 1, title: "宣传视频", isActive: true },
|
|
|
|
|
{ id: 2, title: "效果图", isActive: false }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
if (item.id === 1) {
|
|
|
|
|
showVideo.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
showVideo.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uploadFail = () => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: "上传失败,请重试",
|
|
|
|
|
type: "warning"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fileTypeFail = () => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: "请选择正确的文件",
|
|
|
|
|
type: "warning"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const uploadSuccess = () => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: "上传成功",
|
|
|
|
|
type: "success"
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 文件上传 之前
|
|
|
|
|
function handleBeforeUpload(file, type) {
|
|
|
|
|
console.log(file, "上传之前");
|
|
|
|
|
let fileType = file.type.split("/")[0];
|
|
|
|
|
if (fileType == "video" || fileType == "image") {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
fileTypeFail(); //"请选择正确的文件"
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//上传失败
|
|
|
|
|
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, "效果图");
|
|
|
|
|
picUrl.value = res.result.configValue;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// //保存或删除宣传视频
|
|
|
|
|
function saveOrDeleteVideo(url) {
|
|
|
|
|
editProjectInfo({
|
|
|
|
|
projectSn: store.sn,
|
|
|
|
|
videoUrl: url
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log("保存成功", res);
|
|
|
|
|
uploadSuccess(); //"上传成功"
|
|
|
|
|
projectData.value.videoUrl = url;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
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%;
|
|
|
|
|
height: 92%;
|
|
|
|
|
margin: 3% 11%;
|
2023-10-17 18:13:53 +08:00
|
|
|
img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
margin-top: 1%;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
}
|
2023-09-07 11:27:21 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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>
|