bottom.vue 11 KB

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