123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- <template>
- <div class="Hot" :class="{ active: show }" @click.stop="">
- <div class="close" @click="$emit('hotClose')">
- <img src="../assets/img/hotClose.png" alt="" />
- </div>
- <!-- 查看图片 -->
- <viewer class="viewerCla" ref="viewer" :images="lookPics">
- <img :src="lookPics[0]" alt="" />
- </viewer>
- <!-- 轮播图 -->
- <div class="swBox">
- <div class="swiper-container" ref="mySwiper" :key="type">
- <div class="swiper-wrapper">
- <div class="swiper-slide" v-for="(item, index) in data" :key="index">
- <div
- class="infoTxt"
- :class="{ videoAc: type === 'video' }"
- v-if="item.title || hotIdOrName.name"
- >
- <h3>{{ hotIdOrName.name }}</h3>
- <div v-html="item.content" v-show="type !== 'video'"></div>
- </div>
- <!-- 图片 -->
- <template
- v-if="type === 'img' || type === '2d' || type === 'article'"
- >
- <img
- @click="
- lookImg(`${hotBaseUrl}${hotIdOrName.id}/${type}/${item.id}`)
- "
- v-lazy="`${hotBaseUrl}${hotIdOrName.id}/${type}/${item.id}`"
- alt=""
- />
- </template>
- <!-- 视频 -->
- <template v-else-if="type === 'video'">
- <div class="videoBox">
- <div>
- <!-- 线上开发加上 -->
- <!-- :src="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.video[0].src}`" -->
- <!-- 本地化加上 -->
- <!-- :src="`scene_view_data/${KKNum}/user/${item.media.video[0].src}`" -->
- <video
- v-if="item.media && item.media.video[0]"
- controls
- :src="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.video[0].src}`"
- ></video>
- </div>
- </div>
- </template>
- <!-- 模型 -->
- <template v-else-if="type === 'link'">
- <!-- 线上开发加上 -->
- <!-- :src="item.media.link[0].src" -->
- <!-- 本地化加上 -->
- <!-- :src="item.media.link[0].src.replace('https://4dscene.4dage.com/culturalrelics','')" -->
- <div class="ifrBox">
- <iframe
- v-if="item.media && item.media.link[0]"
- :src="item.media.link[0].src"
- frameborder="0"
- ></iframe>
- </div>
- </template>
- <!-- 音乐 -->
- <template v-else>
- <!-- 线上开发加上 -->
- <!-- :audioSrc="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.audio[0].src}`" -->
- <!-- 本地化加上 -->
- <!-- :audioSrc="`scene_view_data/${KKNum}/user/${item.media.audio[0].src}`" -->
- <Audio
- :Aid="item.media.audio[0].src"
- v-if="item.media && item.media.audio[0] && audioIndex === index"
- :audioSrc="`https://4dkk.4dage.com/scene_edit_data/${KKNum}/user/${item.media.audio[0].src}`"
- />
- </template>
- </div>
- </div>
- <div class="swiper-pagination" v-show="data.length > 1"></div>
- <div
- class="swiper-button-prev swiper-button-white"
- v-show="data.length > 1"
- :class="{ noneAc: true }"
- ></div>
- <div
- class="swiper-button-next swiper-button-white"
- v-show="data.length > 1"
- :class="{ noneAc: true }"
- ></div>
- </div>
- </div>
- <!-- 查看图片的详细名称 -->
- <div
- class="imgNameBox"
- v-show="type === 'img'"
- :class="{ hideImgNameBox: !imgNameBox }"
- >
- <div class="imgNameBox_Row">
- <div
- @click="cutNameFu(index)"
- class="row"
- :class="{ rowAc: index === imgInd }"
- :title="item.name"
- v-for="(item, index) in data"
- :key="item.id"
- >
- {{ item.name }}
- </div>
- </div>
- <!-- 收起按钮 -->
- <div class="hideName" @click="imgNameBox = false">
- <i class="el-icon-caret-right"></i>
- </div>
- </div>
- <!-- 右下角的按钮 -->
- <div class="mainrr">
- <div
- class="row"
- v-show="item.show"
- v-for="item in rightList"
- :key="item.id"
- @click="type = item.type"
- :class="{ active: item.type === type }"
- >
- <img
- :src="
- require(`@/assets/img/Hot/inco${item.id}${
- item.type === type ? 'Ac' : ''
- }.png`)
- "
- alt=""
- />
- <!-- 图片类型才有的展开按钮 -->
- <div
- class="showName"
- v-show="item.type === 'img' && !imgNameBox"
- @click="imgNameBox = true"
- >
- <i class="el-icon-caret-top"></i>
- </div>
- <p>
- {{ item.name }}{{ info[item.type] && info[item.type].length
- }}{{ myinfo[item.type] && myinfo[item.type].length }}
- </p>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { hotData, hotBaseUrl } from "./data";
- // 过滤不显示的 数据
- const hotDataRes = [...hotData];
- hotDataRes.forEach((v) => {
- if (v["img"] && v["img"].length) {
- v["img"] = v["img"].filter((v) => !v.show);
- }
- if (v["2d"] && v["2d"].length) {
- v["2d"] = v["2d"].filter((v) => !v.show);
- }
- if (v["article"] && v["article"].length) {
- v["article"] = v["article"].filter((v) => !v.show);
- }
- });
- // console.log("----------", hotDataRes);
- import Audio from "./Audio.vue";
- import Swiper from "./swiper.js";
- export default {
- props: {
- info: {
- type: Object,
- default: () => {},
- },
- hotIdOrName: {
- type: Object,
- default: () => {},
- },
- },
- name: "Hot",
- components: { Audio },
- data() {
- //这里存放数据
- return {
- hotBaseUrl, //热点图片的前缀 url
- lookPics: [],
- show: false,
- data: [],
- type: "",
- rightList: [
- { name: "三维", id: 2, show: false, type: "link" },
- { name: "二维", id: 5, show: false, type: "2d" },
- { name: "音频", id: 3, show: false, type: "audio" },
- { name: "视频", id: 1, show: false, type: "video" },
- // 定制化
- { name: "文章", id: 6, show: false, type: "article" },
- { name: "图片", id: 4, show: false, type: "img" },
- ],
- Swiper: null,
- KKNum: window.KKNum,
- audioIndex: 0,
- myinfo: {},
- imgInd: 0,
- imgNameBox: true,
- };
- },
- //监听属性 类似于data概念
- computed: {},
- //监控data中的数据变化
- watch: {
- type(val) {
- // console.log('-----------',val);
- if (val === "video") {
- this.$nextTick(() => {
- setTimeout(() => {
- let videoDoms = document.querySelectorAll(".Hot video");
- videoDoms[0].play();
- }, 200);
- });
- } else if (val === "audio") this.audioIndex = 0;
- this.Swiper = null;
- // 定制化
- this.imgInd = 0;
- this.imgNameBox = true;
- const flag = ["img", "2d", "article"];
- if (flag.includes(val)) {
- this.data = this.myinfo[val];
- } else this.data = this.info[val];
- this.$nextTick(() => {
- setTimeout(() => {
- this.Swiper = new Swiper(".Hot .swiper-container", {
- slidesPerView: 1,
- // 如果需要前进后退按钮
- navigation: {
- nextEl: ".swiper-button-next",
- prevEl: ".swiper-button-prev",
- },
- pagination: {
- el: ".swiper-pagination",
- type: "fraction",
- },
- on: {
- slideChange: () => {
- if (val === "video") {
- let dom = document.querySelectorAll(
- ".Hot .swiper-pagination-bullet"
- );
- let index;
- dom.forEach((v, i) => {
- if (v.className.includes("swiper-pagination-bullet-active"))
- index = i;
- });
- this.$nextTick(() => {
- setTimeout(() => {
- let videoDoms = document.querySelectorAll(".Hot video");
- videoDoms.forEach((v, i) => {
- if (i === index) v.play();
- else v.pause();
- });
- }, 200);
- });
- }
- if (val === "audio") this.audioIndex = this.Swiper.activeIndex;
- if (flag.includes(val)) {
- this.imgInd = this.Swiper.activeIndex;
- }
- },
- },
- });
- }, 100);
- });
- },
- info: {
- handler(val) {
- // 通过id获取配置化信息
- // console.log("------------------------", this.hotIdOrName);
- const myinfo = hotDataRes.find((v) => v.hotId === this.hotIdOrName.id);
- this.info = val;
- let obj = {
- video: 3,
- link: 0,
- audio: 2,
- image: 5,
- };
- for (const k in val) {
- if (val[k].length) this.rightList[obj[k]].show = true;
- }
- // 定制化
- if (myinfo) {
- this.myinfo = myinfo;
- if (myinfo.img && myinfo.img.length) this.rightList[5].show = true;
- if (myinfo["2d"] && myinfo["2d"].length)
- this.rightList[1].show = true;
- if (myinfo["article"] && myinfo["article"].length)
- this.rightList[4].show = true;
- }
- if (val["link"] && val["link"].length) this.type = "link";
- else if (myinfo && myinfo["2d"] && myinfo["2d"].length)
- this.type = "2d";
- else if (val["audio"] && val["audio"].length) this.type = "audio";
- else if (val["video"] && val["video"].length) this.type = "video";
- else if (myinfo && myinfo["article"] && myinfo["article"].length)
- this.type = "article";
- else if (myinfo && myinfo.img && myinfo.img.length) this.type = "img";
- // if (val["image"] && val["image"].length) this.type = "image";
- },
- immediate: true,
- },
- },
- //方法集合
- methods: {
- // 点击查看大图
- lookImg(url) {
- let dom = this.$refs.viewer.$viewer;
- this.lookPics = [url];
- dom.show();
- },
- // 点击右下角 的 名字 切换轮播图
- cutNameFu(index) {
- if (this.imgInd === index) return;
- // console.log('----------');
- this.Swiper.slideTo(index);
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- setTimeout(() => {
- this.show = true;
- }, 300);
- // 如果有对应的点位音频,删除
- this.$nextTick(() => {
- let time = -1;
- let num = 0;
- time = window.setInterval(() => {
- const dotAudioDomId = document.querySelector("#dotAudioDomId");
- num++;
- // console.log("xxxxxxxxxxxx", dotAudioDomId);
- if (dotAudioDomId) {
- clearInterval(time);
- document.body.removeChild(dotAudioDomId);
- }
- if (num >= 5) clearInterval(time);
- }, 800);
- });
- },
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='less' scoped>
- @import "./swiper.css";
- .viewerCla img {
- display: none;
- }
- .Hot {
- opacity: 0.3;
- pointer-events: none;
- transition: opacity 0.3s;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 99;
- width: 100%;
- height: 100%;
- background-color: rgba(255, 251, 245, 0.9);
- backdrop-filter: blur(4px);
- .close {
- cursor: pointer;
- width: 60px;
- position: absolute;
- z-index: 10;
- top: 45px;
- right: 45px;
- img {
- width: 60px;
- }
- }
- .mainrr {
- display: flex;
- position: absolute;
- bottom: 15px;
- right: 20px;
- z-index: 10;
- .row {
- position: relative;
- cursor: pointer;
- width: 50px;
- text-align: center;
- margin-left: 15px;
- color: #666666;
- & > img {
- width: 50px;
- }
- p {
- font-size: 12px;
- }
- .likeMove {
- color: #930909;
- position: absolute;
- top: 10px;
- width: 100%;
- text-align: center;
- }
- }
- .active {
- color: #930909;
- font-weight: 700;
- p {
- font-size: 12px;
- }
- }
- .showName {
- position: absolute;
- z-index: 998;
- top: -20px;
- left: 5px;
- width: 40px;
- height: 40px;
- display: flex;
- justify-content: center;
- cursor: pointer;
- }
- }
- .swBox {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- .swiper-container {
- cursor: grab;
- height: 100%;
- .swiper-slide {
- position: relative;
- .infoTxt {
- z-index: 10;
- position: absolute;
- top: 40px;
- left: 40px;
- width: 310px;
- & > h3 {
- font-size: 20px;
- color: #930909;
- font-weight: 700;
- line-height: 28px;
- margin-bottom: 15px;
- }
- & > div {
- color: #666666;
- font-size: 16px;
- }
- }
- .videoAc {
- pointer-events: none;
- width: 1200px;
- height: 680px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- padding: 74px 0 0 140px;
- z-index: 30;
- h3 {
- color: #ffffff;
- }
- }
- .videoBox {
- width: 1200px;
- height: 680px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-image: url("../assets/img/Hot/videoBac.png");
- background-size: 100% 100%;
- padding: 135px 90px 0 140px;
- & > div {
- width: 100%;
- height: 100%;
- overflow: hidden;
- video {
- height: 100%;
- width: 100%;
- }
- }
- }
- .ifrBox {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- overflow: hidden;
- iframe {
- width: 100%;
- height: 100%;
- }
- }
- img {
- cursor: pointer;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- max-width: 900px;
- max-height: 700px;
- object-fit: cover;
- }
- }
- .swiper-pagination {
- bottom: 50px;
- }
- .swiper-button-next {
- // opacity: 1;
- // pointer-events: auto;
- width: 40px;
- height: 60px;
- right: 60px;
- background-image: url("../assets/img/Hot/right.png");
- background-size: 100% 100%;
- color: transparent;
- }
- .swiper-button-prev {
- // opacity: 1;
- // pointer-events: auto;
- width: 40px;
- height: 60px;
- left: 60px;
- background-image: url("../assets/img/Hot/left.png");
- background-size: 100% 100%;
- color: transparent;
- }
- /deep/.swiper-pagination-bullet {
- width: 70px;
- height: 4px;
- border-radius: 1px;
- opacity: 1;
- background-color: #999999;
- }
- /deep/.swiper-pagination-bullet-active {
- background-color: #930909;
- }
- }
- }
- .imgNameBox {
- opacity: 1;
- transition: all 0.3s;
- position: absolute;
- z-index: 998;
- width: 400px;
- padding: 10px 0px 20px 30px;
- right: 0;
- bottom: 100px;
- background-color: #930909;
- // background-image: url("../assets/img/Hot/nameBac.png");
- // background-size: 100% 100%;
- border-radius: 6px;
- max-height: 700px;
- .imgNameBox_Row {
- padding-right: 20px;
- width: 100%;
- height: 100%;
- max-height: 640px;
- overflow-y: auto;
- &::-webkit-scrollbar {
- /*滚动条整体样式*/
- width: 5px;
- /*高宽分别对应横竖滚动条的尺寸*/
- height: 1px;
- }
- &::-webkit-scrollbar-thumb {
- /*滚动条里面小方块*/
- border-radius: 1px;
- -webkit-box-shadow: inset 0 0 5px transparent;
- background: #d8b275;
- }
- &::-webkit-scrollbar-track {
- /*滚动条里面轨道*/
- -webkit-box-shadow: inset 0 0 5px transparent;
- border-radius: 10px;
- background: transparent;
- }
- .row {
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: #fff;
- height: 50px;
- line-height: 49px;
- cursor: pointer;
- border-bottom: 1px solid #fff;
- &:hover {
- color: #d8b275;
- }
- }
- .rowAc {
- color: #d8b275;
- // pointer-events: none;
- }
- }
- .hideName {
- position: absolute;
- z-index: 9999;
- cursor: pointer;
- top: 50%;
- left: 0;
- transform: translateY(-50%);
- width: 40px;
- height: 40px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- font-size: 20px;
- color: yellow;
- }
- }
- .hideImgNameBox {
- opacity: 0;
- right: -400px;
- }
- }
- .active {
- opacity: 1;
- pointer-events: auto;
- }
- </style>
|