list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <div class="list" :class="{ listHide: incoShow }">
  3. <div class="incoShow" @click="incoShow = !incoShow">
  4. <img src="../../assets/img/menu2.png" alt="" v-if="incoShow" />
  5. <img src="../../assets/img/menu.png" alt="" v-else />
  6. </div>
  7. <!-- 收起之后展开 -->
  8. <div class="topTitBox">
  9. <div
  10. class="oneLi"
  11. @click="handleTabone({ children: [1], id: 100, name: '航拍' }, 0)"
  12. :class="{ activeOne: 100 == taboneActive.id }"
  13. >
  14. 航拍全景
  15. </div>
  16. <div
  17. class="clip-scroller topTit"
  18. ref="sw2"
  19. v-swiper:mySwiperb="swiperOptions"
  20. v-if="showInfo.catalogRoot.length > 0 && showInfo.catalogs.length > 1"
  21. >
  22. <ul class="tap swiper-wrapper" v-if="showInfo.catalogRoot.length > 1">
  23. <li
  24. class="swiper-slide row"
  25. @click="handleTabone(item, i)"
  26. :class="{ active: item.id == taboneActive.id }"
  27. v-show="i !== 0"
  28. v-for="(item, i) in showInfo.catalogRoot"
  29. :key="i"
  30. >
  31. {{ item.name }}
  32. </li>
  33. </ul>
  34. </div>
  35. </div>
  36. <div class="listBac">
  37. <!-- 左右箭头 -->
  38. <div
  39. class="swiper-button-prev"
  40. slot="button-prev"
  41. v-show="scenes.length > 11"
  42. ></div>
  43. <div
  44. class="swiper-button-next"
  45. slot="button-next"
  46. v-show="scenes.length > 11"
  47. ></div>
  48. <div
  49. class="l-con"
  50. :class="showList ? 'active' : ''"
  51. v-if="
  52. !(
  53. showInfo.catalogRoot.length == 1 &&
  54. scenes.length == 1 &&
  55. showInfo.catalogs.length == 1
  56. )
  57. "
  58. >
  59. <div class="pic-con">
  60. <div
  61. class="clip-scroller"
  62. ref="sw"
  63. v-swiper:mySwiper="swiperOptions2"
  64. v-if="scenes.length > 0"
  65. >
  66. <ul class="pic-list swiper-wrapper">
  67. <li
  68. class="swiper-slide"
  69. :title="item.sceneTitle"
  70. @click="handleVR(item, i)"
  71. v-for="(item, i) in scenes"
  72. :key="i"
  73. >
  74. <div
  75. :data-value="i"
  76. :class="{
  77. active: selected.sceneCode == item.sceneCode && !MapShow,
  78. }"
  79. >
  80. <img :src="handleImg(item) + `?${Math.random()}`" alt="" />
  81. <RollName
  82. :offset="20"
  83. :active="selected.sceneCode == item.sceneCode && !MapShow"
  84. class="dWenZi"
  85. :myref="'subw' + item.id"
  86. :name="item.sceneTitle"
  87. />
  88. </div>
  89. </li>
  90. </ul>
  91. <div class="swiper-scrollbar"></div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <!-- 右下角的几个按钮 -->
  97. <div class="txtShowBtn2" @click="fullShow">
  98. <img
  99. :src="require(`@/assets/img/Goods/full${isFullscreen ? 'Ac' : ''}.png`)"
  100. alt=""
  101. />
  102. <p :class="{ acFull: isFullscreen }">全屏</p>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import { mapGetters } from "vuex";
  108. import config from "@/config";
  109. import RollName from "@/components/rollName";
  110. import { directive } from "vue-awesome-swiper";
  111. // import style (<= Swiper 5.x)
  112. import "swiper/css/swiper.css";
  113. let isW = window.innerWidth > 1400;
  114. export default {
  115. props: ["select", "hanpaiID", "MapShow"],
  116. components: { RollName },
  117. directives: {
  118. swiper: directive,
  119. },
  120. data() {
  121. return {
  122. isFullscreen: false,
  123. incoShow: false,
  124. taboneActive: { children: [] },
  125. tabtowActive: "",
  126. childTab: [],
  127. scenes: [],
  128. showList: true,
  129. isW,
  130. loadFirst: true,
  131. menuWidth: 0,
  132. sceneNum: config.sceneNum,
  133. SlyArr: [],
  134. };
  135. },
  136. computed: {
  137. ...mapGetters({
  138. showInfo: "showInfo",
  139. }),
  140. selected() {
  141. return { ...this.select };
  142. },
  143. swiperOptions() {
  144. return {
  145. slidesPerView: "auto",
  146. centeredSlides: true,
  147. centerInsufficientSlides: true,
  148. centeredSlidesBounds: true,
  149. freeMode: true,
  150. };
  151. },
  152. swiperOptions2() {
  153. return {
  154. slidesPerView: "auto",
  155. centeredSlides: true,
  156. centerInsufficientSlides: true,
  157. centeredSlidesBounds: true,
  158. freeMode: true,
  159. navigation: {
  160. prevEl: ".swiper-button-prev",
  161. nextEl: ".swiper-button-next",
  162. },
  163. scrollbar: {
  164. el: ".swiper-scrollbar",
  165. },
  166. };
  167. },
  168. },
  169. methods: {
  170. // 从倾斜摄影进来
  171. incoShowClose() {
  172. this.incoShow = true;
  173. },
  174. // 点击全屏
  175. fullShow() {
  176. let element = document.documentElement;
  177. if (this.isFullscreen) {
  178. if (document.exitFullscreen) {
  179. document.exitFullscreen();
  180. } else if (document.webkitCancelFullScreen) {
  181. document.webkitCancelFullScreen();
  182. } else if (document.mozCancelFullScreen) {
  183. document.mozCancelFullScreen();
  184. } else if (document.msExitFullscreen) {
  185. document.msExitFullscreen();
  186. }
  187. } else {
  188. if (element.requestFullscreen) {
  189. element.requestFullscreen();
  190. } else if (element.webkitRequestFullScreen) {
  191. element.webkitRequestFullScreen();
  192. } else if (element.mozRequestFullScreen) {
  193. element.mozRequestFullScreen();
  194. } else if (element.msRequestFullscreen) {
  195. element.msRequestFullscreen();
  196. }
  197. }
  198. // 改变当前全屏状态
  199. this.isFullscreen = !this.isFullscreen;
  200. },
  201. handleImg(item) {
  202. let url = "";
  203. if (item.type == "4dkk") {
  204. url = `local/4dkk/${item.sceneCode}/wwwroot/images/images${item.sceneCode}/thumbSmallImg.jpg`;
  205. } else {
  206. if (item.icon.indexOf("preview.jpg") > -1) {
  207. url = item.icon.replace(
  208. "https://4dkk.4dage.com/720yun_fd_manage/image/",
  209. `${this.$cdn}local/pano/${item.sceneCode}/`
  210. );
  211. } else {
  212. url = item.icon.replace(
  213. "https://4dkk.4dage.com/720yun_fd_manage/image/",
  214. `${this.$cdn}local/pano/images/`
  215. );
  216. }
  217. }
  218. return url || item.icon;
  219. },
  220. // 给父组件调用控制轮播图的位置
  221. changeSwInd(index) {
  222. this.$refs.sw.swiper.slideTo(index);
  223. },
  224. handleTabone(item, i = null) {
  225. this.taboneActive = item;
  226. // 把底部轮播图回到起点
  227. this.$refs.sw.swiper.slideTo(0);
  228. // 让自己保持居中
  229. this.$refs.sw2.swiper.slideTo(i);
  230. },
  231. handleVR(item, i = null) {
  232. if (i !== null) {
  233. this.$refs.sw.swiper.slideTo(i);
  234. this.$emit("mapClose");
  235. }
  236. history.replaceState(
  237. null,
  238. null,
  239. ""
  240. .concat(window.location.pathname, "?")
  241. .concat(`id=${this.showInfo.id}&vr=${item.sceneCode}`)
  242. );
  243. this.sceneNum = item.sceneCode;
  244. },
  245. },
  246. mounted() {
  247. // 监听esc事件
  248. document.addEventListener("webkitfullscreenchange", (e) => {
  249. if (!e.currentTarget.webkitIsFullScreen) this.isFullscreen = false;
  250. });
  251. document.addEventListener("fullscreenchange", (e) => {
  252. if (!document.fullscreenElement) this.isFullscreen = false;
  253. });
  254. document.addEventListener("MSFullscreenChange", (e) => {
  255. if (!document.msFullscreenElement) this.isFullscreen = false;
  256. });
  257. document.addEventListener("mozfullscreenchange", (e) => {
  258. if (!document.mozFullScreenElement) this.isFullscreen = false;
  259. });
  260. },
  261. watch: {
  262. taboneActive: {
  263. handler: function (newVal) {
  264. let temp = [];
  265. newVal.children &&
  266. newVal.children.forEach((item) => {
  267. this.showInfo.catalogs.forEach((sub) => {
  268. if (item == sub.id) {
  269. temp.push(sub);
  270. }
  271. });
  272. });
  273. this.childTab = temp;
  274. if (!this.loadFirst) {
  275. this.tabtowActive = "";
  276. }
  277. },
  278. },
  279. tabtowActive: {
  280. deep: true,
  281. handler: function (newVal) {
  282. if (!newVal) {
  283. this.tabtowActive = this.childTab[0];
  284. } else {
  285. let arr = this.showInfo.scenes.filter((item) => {
  286. return newVal.id == item.category;
  287. });
  288. this.scenes = arr.sort((a, b) => a.weight - b.weight);
  289. }
  290. },
  291. },
  292. sceneNum: {
  293. deep: true,
  294. immediate: true,
  295. handler: function (newVal) {
  296. if (!newVal) {
  297. let tmp = this.showInfo.firstScene || this.showInfo.scenes[0];
  298. this.handleVR(tmp);
  299. return;
  300. }
  301. let val = this.showInfo.scenes.find((item) => item.sceneCode == newVal);
  302. let tmp = this.showInfo.catalogs.find(
  303. (item) => item.id == val.category
  304. );
  305. let rootTmp = this.showInfo.catalogRoot.find((item) => {
  306. return item.children.indexOf(tmp.id) > -1;
  307. });
  308. this.taboneActive = rootTmp;
  309. this.tabtowActive = tmp;
  310. setTimeout(() => {
  311. this.$emit("select", val);
  312. this.loadFirst = false;
  313. });
  314. },
  315. },
  316. selected: {
  317. handler: function (newVal) {
  318. this.handleVR(newVal);
  319. if (newVal.type == "4dkk") {
  320. this.showList = false;
  321. }
  322. },
  323. },
  324. },
  325. created() {},
  326. };
  327. </script>
  328. <style lang="less" scoped>
  329. .txtShowBtn2 {
  330. position: fixed;
  331. z-index: 15;
  332. top: 35px;
  333. right: 30px;
  334. color: #333333;
  335. width: 50px;
  336. cursor: pointer;
  337. background-size: 100% 100%;
  338. & > img {
  339. width: 100%;
  340. }
  341. .acFull {
  342. color: #930909;
  343. }
  344. }
  345. .list {
  346. transition: bottom 0.5s;
  347. position: absolute;
  348. bottom: 0px;
  349. left: 0;
  350. z-index: 99;
  351. text-align: center;
  352. width: 100%;
  353. height: 200px;
  354. background-color: rgba(234, 229, 211, 0.9);
  355. &::before {
  356. content: "";
  357. position: absolute;
  358. top: -40px;
  359. left: 50%;
  360. transform: translateX(-50%);
  361. width: 80px;
  362. height: 40px;
  363. border-radius: 40px 40px 0 0;
  364. line-height: 40px;
  365. background-color: rgba(234, 229, 211, 0.9);
  366. }
  367. .incoShow {
  368. cursor: pointer;
  369. z-index: 20;
  370. position: absolute;
  371. left: 50%;
  372. transform: translateX(-50%);
  373. width: 40px;
  374. height: 40px;
  375. top: -36px;
  376. display: flex;
  377. justify-content: center;
  378. align-items: center;
  379. & > img {
  380. width: 20px;
  381. height: 18px;
  382. }
  383. }
  384. .topTitBox {
  385. color: #333333;
  386. max-width: 1000px;
  387. z-index: 10;
  388. position: absolute;
  389. top: 7px;
  390. left: 50%;
  391. transform: translateX(-50%);
  392. height: 54px;
  393. padding: 0 0px 0 85px;
  394. .oneLi {
  395. padding: 0 8px;
  396. position: absolute;
  397. z-index: 20;
  398. height: 30px;
  399. top: 3px;
  400. left: 5px;
  401. cursor: pointer;
  402. line-height: 30px;
  403. }
  404. .activeOne {
  405. color: #d00724;
  406. pointer-events: none;
  407. opacity: 1;
  408. margin-right: 15px;
  409. }
  410. }
  411. .topTit {
  412. .row {
  413. cursor: pointer;
  414. margin: 3px 10px 0;
  415. padding: 0 10px;
  416. height: 30px;
  417. line-height: 30px;
  418. width: auto;
  419. }
  420. .active {
  421. color: #d00724;
  422. pointer-events: none;
  423. opacity: 1;
  424. }
  425. }
  426. .listBac {
  427. width: 100%;
  428. height: 140px;
  429. position: absolute;
  430. bottom: 10px;
  431. left: 0;
  432. .swiper-scrollbar {
  433. background-color: #d8b275;
  434. }
  435. /deep/.swiper-scrollbar-drag {
  436. background-color: #930909;
  437. }
  438. .swiper-button-prev {
  439. position: absolute;
  440. left: 30px;
  441. top: 50%;
  442. transform: translateY(-50%);
  443. width: 20px;
  444. height: 30px;
  445. background: url("../../assets/img/left.png") no-repeat;
  446. background-size: 100% 100%;
  447. &::after {
  448. color: transparent;
  449. }
  450. }
  451. .swiper-button-next {
  452. position: absolute;
  453. right: 30px;
  454. top: 50%;
  455. transform: translateY(-50%);
  456. width: 20px;
  457. height: 30px;
  458. background: url("../../assets/img/right.png") no-repeat;
  459. background-size: 100% 100%;
  460. &::after {
  461. color: transparent;
  462. }
  463. }
  464. }
  465. .l-con {
  466. width: 100%;
  467. transition: all ease 0.3s;
  468. overflow: hidden;
  469. pointer-events: auto;
  470. .pic-con {
  471. border-radius: 4px;
  472. padding: 0 70px;
  473. }
  474. .clip-scroller {
  475. position: relative;
  476. border-radius: 4px;
  477. }
  478. ul {
  479. // display: inline-block;
  480. white-space: nowrap;
  481. position: relative;
  482. li {
  483. margin: 0 5px;
  484. display: inline-block;
  485. }
  486. }
  487. .pp-tap {
  488. padding: 8px 0 18px;
  489. > li {
  490. width: 84px;
  491. margin: 0 10px;
  492. }
  493. }
  494. .tap {
  495. padding: 10px 0 0;
  496. > li {
  497. position: relative;
  498. width: 104px;
  499. .btn {
  500. width: 100%;
  501. padding: 0;
  502. }
  503. }
  504. }
  505. .pic-list {
  506. > li {
  507. cursor: pointer;
  508. width: 180px;
  509. height: 140px;
  510. > div {
  511. box-sizing: border-box;
  512. width: 100%;
  513. height: 140px;
  514. opacity: 1;
  515. border-radius: 4px;
  516. position: relative;
  517. cursor: pointer;
  518. .dWenZi {
  519. color: #333333;
  520. width: 100%;
  521. text-align: center;
  522. position: absolute;
  523. left: 0;
  524. bottom: 15px;
  525. z-index: 10;
  526. font-size: 14px;
  527. padding: 0 5px;
  528. overflow: hidden;
  529. text-overflow: ellipsis;
  530. white-space: nowrap;
  531. }
  532. > img {
  533. width: 100%;
  534. height: 100px;
  535. object-fit: cover;
  536. }
  537. .iconfont {
  538. position: absolute;
  539. left: 4px;
  540. top: 4px;
  541. z-index: 99;
  542. }
  543. > span {
  544. display: inline-block;
  545. background: rgba(0, 0, 0, 0.5);
  546. position: absolute;
  547. text-overflow: ellipsis;
  548. overflow: hidden;
  549. white-space: nowrap;
  550. left: 0;
  551. bottom: 0;
  552. width: 100%;
  553. }
  554. &.active {
  555. & > img {
  556. border: 3px solid #930909;
  557. }
  558. .dWenZi {
  559. color: #930909;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. .onecls {
  566. background: rgba(0, 0, 0, 0.3);
  567. display: inline-block;
  568. width: 100%;
  569. }
  570. .towcls {
  571. background: rgba(0, 0, 0, 0.3);
  572. }
  573. &.active {
  574. position: relative;
  575. top: 0px;
  576. }
  577. }
  578. }
  579. .listHide {
  580. bottom: -200px;
  581. }
  582. </style>