bottom.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <div
  3. class="bottom"
  4. :style="`height:${box3Ac > 2 ? '210' : '170'}px;bottom:${
  5. !swiShow ? '0' : box3Ac > 2 ? '-210' : '-170'
  6. }px`"
  7. >
  8. <div class="openBox" @click.stop="swiShow = !swiShow">
  9. <van-icon name="arrow-up" v-if="swiShow" />
  10. <van-icon name="arrow-down" v-else />
  11. </div>
  12. <div class="main">
  13. <div class="box1">
  14. <div>
  15. <div class="swiper-container" :key="box3Ac + box2Ac">
  16. <div class="swiper-wrapper">
  17. <div
  18. class="swiper-slide"
  19. v-for="(item, index) in swData"
  20. :key="index"
  21. >
  22. <div
  23. v-for="(val, ind) in item.son"
  24. :key="ind"
  25. @click="box1Cut(val)"
  26. :class="{
  27. active: box1Ac === val.id,
  28. }"
  29. >
  30. <img
  31. v-lazy="
  32. `https://4dkk.4dage.com/720yun_fd_manage/${val.code}/preview.jpg`
  33. "
  34. alt=""
  35. v-if="box3Ac < 3"
  36. />
  37. <img v-lazy="codeChange(val.code, val.id)" alt="" v-else />
  38. <van-notice-bar
  39. speed="30"
  40. v-if="box1Ac === val.id"
  41. delay="0"
  42. :scrollable="true"
  43. >
  44. {{ val.name }}
  45. </van-notice-bar>
  46. <p v-else>{{ val.name }}</p>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="box2" v-if="box3Ac > 2">
  54. <div class="huadong" :style="`width:${box2Data.length * 70}px`">
  55. <div class="row" v-for="(item, index) in box2Data" :key="item.id">
  56. <span
  57. @click="box2Cut(item, index)"
  58. :class="{ active: item.id === box2Ac }"
  59. >{{ item.name }}</span
  60. >
  61. <div class="xian" v-if="index < box2Data.length - 1"></div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="box3">
  66. <div class="row" v-for="item in box3Data" :key="item.id">
  67. <span
  68. @click="box3Cut(item)"
  69. :class="{ active: item.id === box3Ac }"
  70. >{{ item.name }}</span
  71. >
  72. <div class="xian" v-if="item.id !== 4"></div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import { Notify } from "vant";
  80. import { exArr1, exArr2, exArr3, exArr4 } from "./zhan.js";
  81. import Swiper from "@/assets/swiper/swiper.js";
  82. export default {
  83. components: {},
  84. data() {
  85. //这里存放数据
  86. return {
  87. // 控制底部轮播图的收起展开
  88. swiShow: false,
  89. box3Data: [
  90. { id: 1, name: "航拍", code: "" },
  91. { id: 2, name: "地面全景", code: "" },
  92. { id: 3, name: "第一展厅", code: "" },
  93. { id: 4, name: "第二展厅", code: "" },
  94. ],
  95. box3Ac: 1,
  96. box2Ac: "",
  97. box1Ac: "",
  98. box2Data: [],
  99. // 轮播图数据
  100. swData: [],
  101. Swiper: null,
  102. };
  103. },
  104. //监听属性 类似于data概念
  105. computed: {},
  106. //监控data中的数据变化
  107. watch: {
  108. swiShow(val) {
  109. this.$emit("incoMove", val);
  110. },
  111. },
  112. //方法集合
  113. methods: {
  114. // 处理链接
  115. codeChange(code, id) {
  116. let index = code.indexOf("&");
  117. let url = code.substr(0, index);
  118. if (index > 0) {
  119. let arr = [
  120. "4-3_7",
  121. "4-3_8",
  122. "4-3_12",
  123. "4-3_12",
  124. "4-3_14",
  125. "4-3_15",
  126. "4-3_16",
  127. "4-3_17",
  128. "4-3_19",
  129. "4-3_20",
  130. "4-3_21",
  131. "4-3_22",
  132. "4-3_23",
  133. "4-3_24",
  134. "4-5_7",
  135. "4-5_8",
  136. "4-5_9",
  137. "4-6_2",
  138. "4-6_3",
  139. "4-6_4",
  140. "4-6_5",
  141. "4-6_6",
  142. "4-6_7",
  143. "4-6_8",
  144. "4-6_9",
  145. "4-6_10",
  146. ];
  147. if (arr.find((v) => v === id)) return `img/${id}.jpg`;
  148. else
  149. return `https://4dkk.4dage.com/scene_view_data/${url}/user/thumb-2k.jpg`;
  150. } else
  151. return `https://4dkk.4dage.com/scene_view_data/${code}/user/thumb-2k.jpg`;
  152. },
  153. // 给父组件调用的收起底部的方法
  154. openBotton(val) {
  155. this.swiShow = val;
  156. },
  157. // 封装一个切换最底部的方法
  158. getBox3Fu(id) {
  159. if (id === 1) this.box2Data = [...exArr1];
  160. else if (id === 2) this.box2Data = [...exArr2];
  161. else if (id === 3) this.box2Data = [...exArr3];
  162. else if (id === 4) this.box2Data = [...exArr4];
  163. if (id < 3) return;
  164. this.box2Ac = this.box2Data[0].id;
  165. setTimeout(() => {
  166. let scrolDom = document.querySelector(".box2");
  167. scrolDom.scrollLeft = 0;
  168. }, 100);
  169. },
  170. box1Cut(val) {
  171. if (this.box1Ac === val.id) return;
  172. // code为空的不跳
  173. if (val.code === "")
  174. return Notify({ type: "warning", message: "数据计算中,敬请期待" });
  175. this.box1Ac = val.id;
  176. this.$emit("changeVR", val.code);
  177. // 同步list组件的当前vr选中
  178. this.$emit("VRActive", val.id);
  179. },
  180. box3Cut(item) {
  181. this.$emit("lishShow");
  182. if (this.box3Ac === item.id) return;
  183. this.box3Ac = item.id;
  184. this.$emit("mengBan", this.box3Ac);
  185. this.getBox3Fu(item.id);
  186. this.getSwFu("1", "1_1", true);
  187. },
  188. box2Cut(item, index, flag) {
  189. if (this.box2Ac === item.id) return;
  190. this.box2Ac = item.id;
  191. // 设置被选中的元素居中显示
  192. this.$nextTick(() => {
  193. let scrolDom = document.querySelector(".box2");
  194. scrolDom.scrollLeft = (index - 1) * 70;
  195. });
  196. if (flag) return;
  197. this.getSwFu(item.id + "", "1_1", true);
  198. this.$emit("fenQuB_L", item.id);
  199. },
  200. // 封装一个重新加载轮播图的方法
  201. getSwFu(id1, id2, flag) {
  202. this.$nextTick(() => {
  203. this.swData = [];
  204. this.Swiper = null;
  205. let obj = this.box2Data.find((v) => v.id == id1);
  206. // this.towAc = obj.id;
  207. let index = id2.indexOf("_");
  208. let bs = id2.substr(index + 1, id2.length);
  209. let num1 = Math.ceil(Number(bs) / 3);
  210. num1 -= 1;
  211. if (!flag) {
  212. this.box1Ac = id2;
  213. }
  214. // 获取分区里面数据的长度
  215. let num = Math.ceil(obj.son.length / 3);
  216. for (let i = 0; i < num; i++) {
  217. this.swData.push({
  218. son: obj.son.slice(i * 3, (i + 1) * 3),
  219. });
  220. }
  221. setTimeout(() => {
  222. this.Swiper = new Swiper(`.box1 .swiper-container`, {
  223. slidesPerView: 1.1,
  224. initialSlide: num1,
  225. spaceBetween: 0,
  226. });
  227. }, 0);
  228. });
  229. },
  230. },
  231. //生命周期 - 创建完成(可以访问当前this实例)
  232. created() {
  233. this.box2Data = [...exArr1];
  234. },
  235. //生命周期 - 挂载完成(可以访问DOM元素)
  236. mounted() {
  237. this.getSwFu(1, "1_1", true);
  238. // document.querySelector(".huadong").style.width =
  239. // this.box2Data.length * 80 + "px";
  240. },
  241. beforeCreate() {}, //生命周期 - 创建之前
  242. beforeMount() {}, //生命周期 - 挂载之前
  243. beforeUpdate() {}, //生命周期 - 更新之前
  244. updated() {}, //生命周期 - 更新之后
  245. beforeDestroy() {}, //生命周期 - 销毁之前
  246. destroyed() {}, //生命周期 - 销毁完成
  247. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  248. };
  249. </script>
  250. <style lang='less' scoped>
  251. @import "../assets/swiper/swiper.css";
  252. .bottom {
  253. position: absolute;
  254. bottom: 0px;
  255. left: 0;
  256. z-index: 8;
  257. width: 100%;
  258. padding: 0 8px 5px 8px;
  259. transition: bottom 0.5s;
  260. .openBox {
  261. position: absolute;
  262. width: 111px;
  263. height: 21px;
  264. top: -20px;
  265. left: 50%;
  266. transform: translateX(-50%);
  267. background-image: url("../assets/img/bottomOpen.png");
  268. background-size: 100% 100%;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. font-size: 20px;
  273. color: #f1a588;
  274. }
  275. .main {
  276. width: 100%;
  277. height: 100%;
  278. border-radius: 40px 40px 0 0;
  279. overflow: hidden;
  280. .box1 {
  281. position: relative;
  282. width: 100%;
  283. height: 110px;
  284. background-color: rgba(0, 0, 0, 0.5);
  285. margin-bottom: 5px;
  286. & > div {
  287. padding: 8px 20px 5px 20px;
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. width: 100%;
  292. height: 100%;
  293. width: 100%;
  294. height: 100%;
  295. }
  296. .swiper-container {
  297. width: 100%;
  298. height: 100%;
  299. .swiper-slide {
  300. display: flex;
  301. justify-content: flex-start;
  302. & > div {
  303. border-radius: 10px;
  304. overflow: hidden;
  305. position: relative;
  306. width: 30%;
  307. height: 100%;
  308. margin-right: 10px;
  309. /deep/.van-notice-bar {
  310. padding: 0;
  311. opacity: 0.8;
  312. transition: all 0.3s;
  313. position: absolute;
  314. bottom: 0;
  315. left: 0;
  316. width: 100%;
  317. height: 30px;
  318. line-height: 30px;
  319. background-color: rgba(0, 0, 0, 0.6);
  320. font-size: 14px;
  321. color: #fff;
  322. }
  323. p {
  324. opacity: 0.8;
  325. transition: all 0.3s;
  326. position: absolute;
  327. bottom: 0;
  328. left: 0;
  329. width: 100%;
  330. height: 30px;
  331. line-height: 30px;
  332. text-align: center;
  333. background-color: rgba(0, 0, 0, 0.6);
  334. font-size: 14px;
  335. color: #fff;
  336. overflow: hidden;
  337. text-overflow: ellipsis;
  338. white-space: nowrap;
  339. padding: 0 6px;
  340. }
  341. // /deep/.van-notice-bar__wrap {
  342. // justify-content: center;
  343. // }
  344. img {
  345. width: 100%;
  346. height: 100%;
  347. object-fit: cover;
  348. }
  349. }
  350. .active {
  351. /deep/.van-notice-bar {
  352. opacity: 1;
  353. background-color: rgba(181, 147, 134, 0.8);
  354. }
  355. }
  356. }
  357. }
  358. }
  359. .box2::-webkit-scrollbar {
  360. width: 0px;
  361. height: 0px;
  362. }
  363. .box2 {
  364. margin-top: 5px;
  365. height: 40px;
  366. width: 100%;
  367. overflow-x: auto;
  368. background-color: rgba(0, 0, 0, 0.5);
  369. .huadong {
  370. height: 100%;
  371. display: flex;
  372. justify-content: space-around;
  373. padding: 0 10px;
  374. .row {
  375. font-size: 14px;
  376. color: #fff;
  377. display: flex;
  378. align-items: center;
  379. justify-content: center;
  380. .xian {
  381. margin: 0 8px 0 15px;
  382. width: 1px;
  383. height: 20px;
  384. background-image: linear-gradient(
  385. rgba(255, 255, 255, 0.1),
  386. rgba(255, 255, 255, 0.6),
  387. rgba(255, 255, 255, 0.1)
  388. );
  389. }
  390. span {
  391. display: block;
  392. position: relative;
  393. }
  394. .active {
  395. color: #c48871;
  396. }
  397. }
  398. }
  399. }
  400. .box3 {
  401. padding: 0 10px 0 15px;
  402. margin-top: 5px;
  403. height: 50px;
  404. width: 100%;
  405. background-color: rgba(0, 0, 0, 0.5);
  406. display: flex;
  407. justify-content: space-around;
  408. .row {
  409. font-size: 16px;
  410. color: #fff;
  411. display: flex;
  412. align-items: center;
  413. .xian {
  414. margin: 0 10px 0 15px;
  415. width: 2px;
  416. height: 35px;
  417. background-image: linear-gradient(
  418. rgba(255, 255, 255, 0.1),
  419. rgba(255, 255, 255, 0.6),
  420. rgba(255, 255, 255, 0.1)
  421. );
  422. }
  423. span {
  424. display: block;
  425. position: relative;
  426. }
  427. .active {
  428. color: #c48871;
  429. &::after {
  430. content: "";
  431. position: absolute;
  432. left: 0;
  433. bottom: -5px;
  434. width: 100%;
  435. height: 2px;
  436. background-color: #c48871;
  437. }
  438. }
  439. }
  440. @media screen and (max-width: 350px) {
  441. .row {
  442. font-size: 14px;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. </style>