Bottom2.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="Bottom2">
  3. <div class="box1">
  4. <div>
  5. <div
  6. class="swiper-container"
  7. :class="`sww${towAc}`"
  8. :key="towAc + box3Ac"
  9. >
  10. <div class="swiper-wrapper">
  11. <div
  12. class="swiper-slide"
  13. v-for="(item, index) in swData"
  14. :key="index"
  15. >
  16. <div
  17. v-for="(val, ind) in item.son"
  18. :key="ind"
  19. @click="cutVr(val)"
  20. :class="{
  21. active: oneAc === val.id,
  22. sm: ind === 0 || ind == item.son.length - 1,
  23. big: item.son.length < 6,
  24. }"
  25. >
  26. <el-tooltip :content="val.name" placement="top">
  27. <div>
  28. <img src="../assets/img/demo.png" alt="" />
  29. <p>{{ val.name }}</p>
  30. </div>
  31. </el-tooltip>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="swiper-button-next swiper-button-next1"></div>
  37. <div class="swiper-button-prev swiper-button-prev1"></div>
  38. </div>
  39. </div>
  40. <div class="box2" v-if="box3Ac === 3 || box3Ac === 4">
  41. <div v-for="(item, index) in data" :key="item.id">
  42. <div @click="botChange(item)" :class="{ active: towAc === item.id }">
  43. {{ item.name }}
  44. </div>
  45. <img
  46. src="../assets/img/fenge.png"
  47. alt=""
  48. v-if="index < data.length - 1"
  49. />
  50. </div>
  51. </div>
  52. <div class="box3">
  53. <div v-for="(item, index) in box3Data" :key="item.id">
  54. <div @click="botChange2(item)" :class="{ active: box3Ac === item.id }">
  55. {{ item.name }}
  56. </div>
  57. <img
  58. src="../assets/img/fenge.png"
  59. alt=""
  60. v-if="index < box3Data.length - 1"
  61. />
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import { exArr1, exArr2, exArr3, exArr4 } from "./zhan";
  68. import Swiper from "@/assets/swiper/swiper.js";
  69. export default {
  70. name: "Bottom2",
  71. components: {},
  72. data() {
  73. return {
  74. oneAc: "",
  75. towAc: "1",
  76. box3Ac: 1,
  77. data: [],
  78. swData: [],
  79. Swiper: null,
  80. box3Data: [
  81. { id: 1, name: "航拍", code: "" },
  82. { id: 2, name: "地面全景", code: "" },
  83. { id: 3, name: "第一展厅", code: "" },
  84. { id: 4, name: "第二展厅", code: "" },
  85. ],
  86. };
  87. },
  88. computed: {},
  89. methods: {
  90. // 点击底部的切换分区
  91. botChange(item) {
  92. this.towAc = "1";
  93. this.towAc = item.id;
  94. if (this.box3Ac === 3) this.data = [...exArr3];
  95. else this.data = [...exArr4];
  96. this.getSwFu(item.id + "", "1_1", true);
  97. },
  98. botChange2(item) {
  99. this.$emit("zhanShowFu");
  100. if (this.box3Ac === item.id) return;
  101. this.towAc = "1";
  102. this.box3Ac = item.id;
  103. if (item.id === 1) this.data = [...exArr1];
  104. else if (item.id === 2) this.data = [...exArr2];
  105. else if (item.id === 3) this.data = [...exArr3];
  106. else this.data = [...exArr4];
  107. this.getSwFu("1", "1_1", true);
  108. // 给父组件传递信息
  109. this.$emit("gaoduChange", this.box3Ac);
  110. // this.$emit("zhanChange", this.box3Ac, item.code);
  111. },
  112. // 封装一个重新加载轮播图的方法
  113. getSwFu(id1, id2, flag) {
  114. this.$nextTick(() => {
  115. this.swData = [];
  116. this.Swiper = null;
  117. let obj = this.data.find((v) => v.id == id1);
  118. this.towAc = obj.id;
  119. let index = id2.indexOf("_");
  120. let bs = id2.substr(index + 1, id2.length);
  121. let num1 = Math.ceil(Number(bs) / 6);
  122. num1 -= 1;
  123. if (!flag) {
  124. this.oneAc = id2;
  125. }
  126. // 获取分区里面数据的长度
  127. let num = Math.ceil(obj.son.length / 6);
  128. for (let i = 0; i < num; i++) {
  129. this.swData.push({
  130. son: obj.son.slice(i * 6, (i + 1) * 6),
  131. });
  132. }
  133. setTimeout(() => {
  134. this.Swiper = new Swiper(`.box1 .sww${this.towAc}`, {
  135. navigation: {
  136. nextEl: ".swiper-button-next1",
  137. prevEl: ".swiper-button-prev1",
  138. },
  139. slidesPerView: 1,
  140. initialSlide: num1,
  141. spaceBetween: 0,
  142. });
  143. }, 200);
  144. });
  145. },
  146. // 切换VR
  147. cutVr(val) {
  148. if (this.oneAc === val.id) return;
  149. this.oneAc = val.id;
  150. this.$emit("zhanChange", val.code);
  151. },
  152. // 进来页面的方法
  153. baseList(bs) {
  154. if (bs == 3) this.data = [...exArr3];
  155. else if (bs == 4) this.data = [...exArr4];
  156. else this.data = exArr1;
  157. },
  158. },
  159. watch: {},
  160. //生命周期 - 创建完成(可以访问当前this实例)
  161. created() {
  162. this.baseList(1);
  163. },
  164. //生命周期 - 挂载完成(可以访问DOM元素)
  165. mounted() {
  166. this.getSwFu("1", "1_1", true);
  167. },
  168. beforeCreate() {}, //生命周期 - 创建之前
  169. beforeMount() {}, //生命周期 - 挂载之前
  170. beforeUpdate() {}, //生命周期 - 更新之前
  171. updated() {}, //生命周期 - 更新之后
  172. beforeDestroy() {}, //生命周期 - 销毁之前
  173. destroyed() {}, //生命周期 - 销毁完成
  174. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  175. };
  176. </script>
  177. <style lang='less' scoped>
  178. @import "../assets/swiper/swiper.css";
  179. .Bottom2 {
  180. width: 100%;
  181. height: 100%;
  182. position: relative;
  183. .box1 {
  184. position: relative;
  185. width: 100%;
  186. height: 152px;
  187. margin-bottom: 4px;
  188. background-color: rgba(0, 0, 0, 0.8);
  189. border-radius: 60px 60px 0 0;
  190. & > div {
  191. padding: 8px 50px 5px 50px;
  192. position: absolute;
  193. top: 0;
  194. left: 0;
  195. width: 100%;
  196. height: 100%;
  197. width: 100%;
  198. height: 100%;
  199. }
  200. .swiper-container {
  201. width: 100%;
  202. height: 100%;
  203. .swiper-slide {
  204. display: flex;
  205. justify-content: center;
  206. & > div {
  207. border-radius: 20px;
  208. overflow: hidden;
  209. position: relative;
  210. cursor: pointer;
  211. margin-right: 12px;
  212. width: 209px;
  213. height: 100%;
  214. /deep/.el-tooltip {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. &:nth-of-type(6) {
  219. margin-right: 0;
  220. }
  221. p {
  222. opacity: 0.8;
  223. transition: all 0.3s;
  224. position: absolute;
  225. bottom: 0;
  226. left: 0;
  227. width: 100%;
  228. height: 30px;
  229. line-height: 30px;
  230. text-align: center;
  231. background-color: rgba(0, 0, 0, 0.8);
  232. font-size: 14px;
  233. color: #fff;
  234. overflow: hidden;
  235. text-overflow: ellipsis;
  236. white-space: nowrap;
  237. padding: 0 6px;
  238. }
  239. img {
  240. width: 100%;
  241. height: 100%;
  242. object-fit: cover;
  243. }
  244. &:hover {
  245. p {
  246. opacity: 1;
  247. background-color: rgba(181, 147, 134, 0.8);
  248. }
  249. }
  250. }
  251. .active {
  252. p {
  253. opacity: 1;
  254. background-color: rgba(181, 147, 134, 0.8);
  255. }
  256. }
  257. .sm {
  258. width: 170px;
  259. }
  260. .big {
  261. width: 209px;
  262. }
  263. }
  264. }
  265. .swiper-button-next {
  266. color: #c48871;
  267. }
  268. .swiper-button-prev {
  269. color: #c48871;
  270. }
  271. }
  272. .box2 {
  273. background-color: rgba(0, 0, 0, 0.8);
  274. width: 100%;
  275. height: 40px;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. padding-bottom: 2px;
  280. & > div {
  281. display: flex;
  282. align-items: center;
  283. & > img {
  284. margin: 0 26px;
  285. width: 2px;
  286. height: 40px;
  287. }
  288. & > div {
  289. cursor: pointer;
  290. font-size: 16px;
  291. color: #fff;
  292. padding-bottom: 5px;
  293. opacity: 0.8;
  294. &:hover {
  295. opacity: 1;
  296. padding-top: 2px;
  297. color: #c48871;
  298. border-bottom: 2px solid #c48871;
  299. }
  300. }
  301. }
  302. .active {
  303. opacity: 1;
  304. padding-top: 2px;
  305. pointer-events: none;
  306. color: #c48871;
  307. border-bottom: 2px solid #c48871;
  308. }
  309. }
  310. .box3 {
  311. margin-top: 5px;
  312. background-color: rgba(0, 0, 0, 0.8);
  313. width: 100%;
  314. height: 56px;
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. padding-bottom: 2px;
  319. & > div {
  320. display: flex;
  321. align-items: center;
  322. & > img {
  323. margin: 0 26px;
  324. width: 2px;
  325. height: 40px;
  326. }
  327. & > div {
  328. cursor: pointer;
  329. font-size: 20px;
  330. color: #fff;
  331. padding-bottom: 5px;
  332. opacity: 0.8;
  333. &:hover {
  334. opacity: 1;
  335. padding-top: 2px;
  336. color: #c48871;
  337. border-bottom: 2px solid #c48871;
  338. }
  339. }
  340. }
  341. .active {
  342. opacity: 1;
  343. padding-top: 2px;
  344. // pointer-events: none;
  345. color: #c48871;
  346. border-bottom: 2px solid #c48871;
  347. }
  348. }
  349. }
  350. </style>