bottom.vue 11 KB

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