Bottom2.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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">
  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.swData = [];
  94. this.Swiper = null;
  95. this.towAc = item.id;
  96. if (this.box3Ac === 3) this.data = [...exArr3];
  97. else this.data = [...exArr4];
  98. this.getSwFu(item.id + "", "1_1");
  99. },
  100. botChange2(item) {
  101. if (this.box3Ac === item.id) return;
  102. this.towAc = "1";
  103. this.swData = [];
  104. this.Swiper = null;
  105. this.box3Ac = item.id;
  106. if (item.id === 1) this.data = [...exArr1];
  107. else if (item.id === 2) this.data = [...exArr2];
  108. else if (item.id === 3) this.data = [...exArr3];
  109. else this.data = [...exArr4];
  110. this.getSwFu("1", "1_1");
  111. // 给父组件传递信息
  112. this.$emit("zhanChange", this.box3Ac, item.code);
  113. },
  114. // 封装一个重新加载轮播图的方法
  115. getSwFu(id1, id2) {
  116. let obj = this.data.find((v) => v.id == id1);
  117. this.towAc = obj.id;
  118. let index = id2.indexOf("_");
  119. let bs = id2.substr(index + 1, id2.length);
  120. let num1 = Math.ceil(Number(bs) / 6);
  121. num1 -= num1;
  122. this.oneAc = id2;
  123. // 获取分区里面数据的长度
  124. let num = Math.ceil(obj.son.length / 6);
  125. for (let i = 0; i < num; i++) {
  126. this.swData.push({
  127. son: obj.son.slice(i * 6, (i + 1) * 6),
  128. });
  129. }
  130. this.$nextTick(() => {
  131. this.Swiper = new Swiper(`.box1 .sww${this.towAc}`, {
  132. navigation: {
  133. nextEl: ".swiper-button-next1",
  134. prevEl: ".swiper-button-prev1",
  135. },
  136. slidesPerView: 1,
  137. initialSlide: num1,
  138. spaceBetween: 0,
  139. });
  140. });
  141. },
  142. // 切换VR
  143. cutVr(val) {
  144. if (this.oneAc === val.id) return;
  145. console.log("切换vr");
  146. this.oneAc = val.id;
  147. this.$emit("zhanChange", this.box3Ac, val.code);
  148. },
  149. // 进来页面的方法
  150. baseList(bs) {
  151. if (bs == 3) this.data = exArr3;
  152. else if (bs == 4) this.data = exArr4;
  153. else this.data = exArr1;
  154. },
  155. },
  156. watch: {},
  157. //生命周期 - 创建完成(可以访问当前this实例)
  158. created() {
  159. this.baseList(1);
  160. },
  161. //生命周期 - 挂载完成(可以访问DOM元素)
  162. mounted() {
  163. this.getSwFu("1", "1_1");
  164. },
  165. beforeCreate() {}, //生命周期 - 创建之前
  166. beforeMount() {}, //生命周期 - 挂载之前
  167. beforeUpdate() {}, //生命周期 - 更新之前
  168. updated() {}, //生命周期 - 更新之后
  169. beforeDestroy() {}, //生命周期 - 销毁之前
  170. destroyed() {}, //生命周期 - 销毁完成
  171. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  172. };
  173. </script>
  174. <style lang='less' scoped>
  175. @import "../assets/swiper/swiper.css";
  176. .Bottom2 {
  177. width: 100%;
  178. height: 100%;
  179. position: relative;
  180. .box1 {
  181. position: relative;
  182. width: 100%;
  183. height: 152px;
  184. margin-bottom: 4px;
  185. background-color: rgba(0, 0, 0, 0.8);
  186. border-radius: 60px 60px 0 0;
  187. & > div {
  188. padding: 8px 50px 5px 50px;
  189. position: absolute;
  190. top: 0;
  191. left: 0;
  192. width: 100%;
  193. height: 100%;
  194. width: 100%;
  195. height: 100%;
  196. }
  197. .swiper-container {
  198. width: 100%;
  199. height: 100%;
  200. .swiper-slide {
  201. display: flex;
  202. justify-content: center;
  203. & > div {
  204. border-radius: 20px;
  205. overflow: hidden;
  206. position: relative;
  207. cursor: pointer;
  208. margin-right: 12px;
  209. width: 209px;
  210. height: 100%;
  211. /deep/.el-tooltip {
  212. width: 100%;
  213. height: 100%;
  214. }
  215. &:nth-of-type(6) {
  216. margin-right: 0;
  217. }
  218. p {
  219. opacity: 0.8;
  220. transition: all 0.3s;
  221. position: absolute;
  222. bottom: 0;
  223. left: 0;
  224. width: 100%;
  225. height: 30px;
  226. line-height: 30px;
  227. text-align: center;
  228. background-color: rgba(0, 0, 0, 0.8);
  229. font-size: 14px;
  230. color: #fff;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. white-space: nowrap;
  234. padding: 0 6px;
  235. }
  236. img {
  237. width: 100%;
  238. height: 100%;
  239. object-fit: cover;
  240. }
  241. &:hover {
  242. p {
  243. opacity: 1;
  244. background-color: rgba(181, 147, 134, 0.8);
  245. }
  246. }
  247. }
  248. .active {
  249. p {
  250. opacity: 1;
  251. background-color: rgba(181, 147, 134, 0.8);
  252. }
  253. }
  254. .sm {
  255. width: 170px;
  256. }
  257. .big {
  258. width: 209px;
  259. }
  260. }
  261. }
  262. .swiper-button-next {
  263. color: #C48871;
  264. }
  265. .swiper-button-prev {
  266. color: #C48871;
  267. }
  268. }
  269. .box2 {
  270. background-color: rgba(0, 0, 0, 0.8);
  271. width: 100%;
  272. height: 40px;
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. padding-bottom: 2px;
  277. & > div {
  278. display: flex;
  279. align-items: center;
  280. & > img {
  281. margin: 0 26px;
  282. width: 2px;
  283. height: 40px;
  284. }
  285. & > div {
  286. cursor: pointer;
  287. font-size: 20px;
  288. color: #fff;
  289. padding-bottom: 5px;
  290. opacity: 0.8;
  291. &:hover {
  292. opacity: 1;
  293. padding-top: 2px;
  294. color: #C48871;
  295. border-bottom: 2px solid #C48871;
  296. }
  297. }
  298. }
  299. .active {
  300. opacity: 1;
  301. padding-top: 2px;
  302. pointer-events: none;
  303. color: #C48871;
  304. border-bottom: 2px solid #C48871;
  305. }
  306. }
  307. .box3 {
  308. margin-top: 5px;
  309. background-color: rgba(0, 0, 0, 0.8);
  310. width: 100%;
  311. height: 40px;
  312. display: flex;
  313. align-items: center;
  314. justify-content: center;
  315. padding-bottom: 2px;
  316. & > div {
  317. display: flex;
  318. align-items: center;
  319. & > img {
  320. margin: 0 26px;
  321. width: 2px;
  322. height: 40px;
  323. }
  324. & > div {
  325. cursor: pointer;
  326. font-size: 20px;
  327. color: #fff;
  328. padding-bottom: 5px;
  329. opacity: 0.8;
  330. &:hover {
  331. opacity: 1;
  332. padding-top: 2px;
  333. color: #C48871;
  334. border-bottom: 2px solid #C48871;
  335. }
  336. }
  337. }
  338. .active {
  339. opacity: 1;
  340. padding-top: 2px;
  341. pointer-events: none;
  342. color: #C48871;
  343. border-bottom: 2px solid #C48871;
  344. }
  345. }
  346. }
  347. </style>