123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- <template>
- <div class="Bottom2">
- <div class="box1">
- <div>
- <div
- class="swiper-container"
- :class="`sww${towAc}`"
- :key="towAc + box3Ac"
- >
- <div class="swiper-wrapper">
- <div
- class="swiper-slide"
- v-for="(item, index) in swData"
- :key="index"
- >
- <div
- v-for="(val, ind) in item.son"
- :key="ind"
- @click="cutVr(val)"
- :class="{
- active: oneAc === val.id,
- sm: ind === 0 || ind == item.son.length - 1,
- big: item.son.length < 6,
- }"
- >
- <el-tooltip :content="val.name" placement="top">
- <div>
- <img src="../assets/img/demo.png" alt="" />
- <p>{{ val.name }}</p>
- </div>
- </el-tooltip>
- </div>
- </div>
- </div>
- </div>
- <div class="swiper-button-next swiper-button-next1"></div>
- <div class="swiper-button-prev swiper-button-prev1"></div>
- </div>
- </div>
- <div class="box2">
- <div v-for="(item, index) in data" :key="item.id">
- <div @click="botChange(item)" :class="{ active: towAc === item.id }">
- {{ item.name }}
- </div>
- <img
- src="../assets/img/fenge.png"
- alt=""
- v-if="index < data.length - 1"
- />
- </div>
- </div>
- <div class="box3">
- <div v-for="(item, index) in box3Data" :key="item.id">
- <div @click="botChange2(item)" :class="{ active: box3Ac === item.id }">
- {{ item.name }}
- </div>
- <img
- src="../assets/img/fenge.png"
- alt=""
- v-if="index < box3Data.length - 1"
- />
- </div>
- </div>
- </div>
- </template>
- <script>
- import { exArr1, exArr2, exArr3, exArr4 } from "./zhan";
- import Swiper from "@/assets/swiper/swiper.js";
- export default {
- name: "Bottom2",
- components: {},
- data() {
- return {
- oneAc: "",
- towAc: "1",
- box3Ac: 1,
- data: [],
- swData: [],
- Swiper: null,
- box3Data: [
- { id: 1, name: "航拍", code: "" },
- { id: 2, name: "地面全景", code: "" },
- { id: 3, name: "第一展厅", code: "" },
- { id: 4, name: "第二展厅", code: "" },
- ],
- };
- },
- computed: {},
- methods: {
- // 点击底部的切换分区
- botChange(item) {
- this.towAc = "1";
- this.swData = [];
- this.Swiper = null;
- this.towAc = item.id;
- if (this.box3Ac === 3) this.data = [...exArr3];
- else this.data = [...exArr4];
- this.getSwFu(item.id + "", "1_1");
- },
- botChange2(item) {
- if (this.box3Ac === item.id) return;
- this.towAc = "1";
- this.swData = [];
- this.Swiper = null;
- this.box3Ac = item.id;
- if (item.id === 1) this.data = [...exArr1];
- else if (item.id === 2) this.data = [...exArr2];
- else if (item.id === 3) this.data = [...exArr3];
- else this.data = [...exArr4];
- this.getSwFu("1", "1_1");
- // 给父组件传递信息
- this.$emit("zhanChange", this.box3Ac, item.code);
- },
- // 封装一个重新加载轮播图的方法
- getSwFu(id1, id2) {
- let obj = this.data.find((v) => v.id == id1);
- this.towAc = obj.id;
- let index = id2.indexOf("_");
- let bs = id2.substr(index + 1, id2.length);
- let num1 = Math.ceil(Number(bs) / 6);
- num1 -= num1;
- this.oneAc = id2;
- // 获取分区里面数据的长度
- let num = Math.ceil(obj.son.length / 6);
- for (let i = 0; i < num; i++) {
- this.swData.push({
- son: obj.son.slice(i * 6, (i + 1) * 6),
- });
- }
- this.$nextTick(() => {
- this.Swiper = new Swiper(`.box1 .sww${this.towAc}`, {
- navigation: {
- nextEl: ".swiper-button-next1",
- prevEl: ".swiper-button-prev1",
- },
- slidesPerView: 1,
- initialSlide: num1,
- spaceBetween: 0,
- });
- });
- },
- // 切换VR
- cutVr(val) {
- if (this.oneAc === val.id) return;
- console.log("切换vr");
- this.oneAc = val.id;
- this.$emit("zhanChange", this.box3Ac, val.code);
- },
- // 进来页面的方法
- baseList(bs) {
- if (bs == 3) this.data = exArr3;
- else if (bs == 4) this.data = exArr4;
- else this.data = exArr1;
- },
- },
- watch: {},
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.baseList(1);
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- this.getSwFu("1", "1_1");
- },
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='less' scoped>
- @import "../assets/swiper/swiper.css";
- .Bottom2 {
- width: 100%;
- height: 100%;
- position: relative;
- .box1 {
- position: relative;
- width: 100%;
- height: 152px;
- margin-bottom: 4px;
- background-color: rgba(0, 0, 0, 0.8);
- border-radius: 60px 60px 0 0;
- & > div {
- padding: 8px 50px 5px 50px;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- width: 100%;
- height: 100%;
- }
- .swiper-container {
- width: 100%;
- height: 100%;
- .swiper-slide {
- display: flex;
- justify-content: center;
- & > div {
- border-radius: 20px;
- overflow: hidden;
- position: relative;
- cursor: pointer;
- margin-right: 12px;
- width: 209px;
- height: 100%;
- /deep/.el-tooltip {
- width: 100%;
- height: 100%;
- }
- &:nth-of-type(6) {
- margin-right: 0;
- }
- p {
- opacity: 0.8;
- transition: all 0.3s;
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 30px;
- line-height: 30px;
- text-align: center;
- background-color: rgba(0, 0, 0, 0.8);
- font-size: 14px;
- color: #fff;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- padding: 0 6px;
- }
- img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- &:hover {
- p {
- opacity: 1;
- background-color: rgba(181, 147, 134, 0.8);
- }
- }
- }
- .active {
- p {
- opacity: 1;
- background-color: rgba(181, 147, 134, 0.8);
- }
- }
- .sm {
- width: 170px;
- }
- .big {
- width: 209px;
- }
- }
- }
- .swiper-button-next {
- color: #C48871;
- }
- .swiper-button-prev {
- color: #C48871;
- }
- }
- .box2 {
- background-color: rgba(0, 0, 0, 0.8);
- width: 100%;
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: center;
- padding-bottom: 2px;
- & > div {
- display: flex;
- align-items: center;
- & > img {
- margin: 0 26px;
- width: 2px;
- height: 40px;
- }
- & > div {
- cursor: pointer;
- font-size: 20px;
- color: #fff;
- padding-bottom: 5px;
- opacity: 0.8;
- &:hover {
- opacity: 1;
- padding-top: 2px;
- color: #C48871;
- border-bottom: 2px solid #C48871;
- }
- }
- }
- .active {
- opacity: 1;
- padding-top: 2px;
- pointer-events: none;
- color: #C48871;
- border-bottom: 2px solid #C48871;
- }
- }
- .box3 {
- margin-top: 5px;
- background-color: rgba(0, 0, 0, 0.8);
- width: 100%;
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: center;
- padding-bottom: 2px;
- & > div {
- display: flex;
- align-items: center;
- & > img {
- margin: 0 26px;
- width: 2px;
- height: 40px;
- }
- & > div {
- cursor: pointer;
- font-size: 20px;
- color: #fff;
- padding-bottom: 5px;
- opacity: 0.8;
- &:hover {
- opacity: 1;
- padding-top: 2px;
- color: #C48871;
- border-bottom: 2px solid #C48871;
- }
- }
- }
- .active {
- opacity: 1;
- padding-top: 2px;
- pointer-events: none;
- color: #C48871;
- border-bottom: 2px solid #C48871;
- }
- }
- }
- </style>
|