new-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div class="bar-list" v-if="info" :class="{ disable: isEditing }">
  3. <div class="top-con" v-show="currentScenesList.length">
  4. <div v-if="currentScenesList.length" class="scene-list swiper-container" ref="scene-swiper" :style="`width:${scenesListW > 1150 ? '100%' : scenesListW + 'px'}`">
  5. <!-- <div class="scene-list swiper-container" ref="scene-swiper"> -->
  6. <div class="swiper-wrapper scene-wrapper">
  7. <!-- <div
  8. class="swiper-slide scene-slide"
  9. :class="{
  10. active: currentScene.id == item.id ||currentScene.id == item.sid ,
  11. disabled: isLockV4Scene,
  12. // loopspan:
  13. // item.sceneTitle.length > spanlength &&
  14. // currentScene.id == item.id,
  15. }"
  16. v-for="(item, index) in currentScenesList"
  17. > -->
  18. <div
  19. class="swiper-slide scene-slide"
  20. :class="{
  21. active: currentScene.id == item.id || (currentScene.sid && currentScene.sid == item.sid),
  22. disabled: isLockV4Scene,
  23. // loopspan:
  24. // item.sceneTitle.length > spanlength &&
  25. // currentScene.id == item.id,
  26. }"
  27. v-for="(item, index) in currentScenesList"
  28. >
  29. <div @click="tabCurrentScene(item, index)" class="scene-content" :style="`background-image:url(${item.icon});`">
  30. <!-- <img :src="i.icon" alt="" /> -->
  31. <i class="iconfont" :class="item.type == '4dkk' ? 'icon-editor_3d' : 'icon-editor_panoramic'"></i>
  32. <div class="marquee">
  33. <marquee-text :repeat="1" :duration="Math.ceil(item.name.length / 10) * 5" :key="item.id" v-if="item.name.length > spanlength && currentScene.id == item.id">
  34. {{ item.name }}
  35. </marquee-text>
  36. <span v-else>
  37. {{ item.name }}
  38. </span>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="second-group-box">
  45. <div v-if="info.navigationTrees[rootTabIndex]?.children[0]?.type == 'group' && showSecondTab" class="second-group-list swiper-container" ref="second-group-swiper">
  46. <div class="swiper-wrapper second-group-wrapper">
  47. <div
  48. class="swiper-slide second-group-slide"
  49. @click="tabSecond(item)"
  50. v-if="item.children.length"
  51. v-for="(item, index) in info.navigationTrees[rootTabIndex].children"
  52. :class="{ active: currentSecondId == item.id, disabled: isLockV4Scene, loopspan: fixTitle(item.name).length > spanlength && currentSecondId == item.id }"
  53. >
  54. <div class="second-group-content">
  55. <marquee-text :duration="Math.ceil(fixTitle(item.name).length / 10) * 5" :key="item.id" :repeat="1" v-if="fixTitle(item.name).length > spanlength && currentSecondId == item.id">
  56. {{ fixTitle(item.name) }}
  57. </marquee-text>
  58. <span v-else>
  59. {{ fixTitle(item.name) }}
  60. </span>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="bottom-com">
  68. <div v-if="info.navigationTrees.length > 1" :style="`width:${catalogRootW}px;`" class="root-group-list swiper-container" ref="root-group">
  69. <div class="swiper-wrapper root-group-wrapper">
  70. <div
  71. class="swiper-slide root-group-slide"
  72. :class="{
  73. active: currentRootId == item.id,
  74. disabled: isLockV4Scene,
  75. loopspan: fixTitle(item.name).length > spanlength && currentRootId.id == item.id,
  76. }"
  77. v-for="(item, index) in info.navigationTrees"
  78. @click="tabRoot(item)"
  79. >
  80. <div class="root-group-content">
  81. <marquee-text :duration="Math.ceil(fixTitle(item.name).length / 10) * 5" :key="item.id" :repeat="1" v-if="fixTitle(item.name).length > spanlength && currentRootId == item.id">
  82. {{ fixTitle(item.name) }}
  83. </marquee-text>
  84. <span v-else>
  85. {{ fixTitle(item.name) }}
  86. </span>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { mapGetters, mapState } from "vuex";
  96. import MarqueeText from "vue-marquee-text-component";
  97. export default {
  98. components: { MarqueeText },
  99. data() {
  100. return {
  101. spanlength: 6,
  102. swidth: {
  103. swcatalogRoot: 104,
  104. swSecondary: 84,
  105. swScenes: 72,
  106. },
  107. SceneSwiper: null,
  108. SecondGroupSwiper: null,
  109. rootGroupSwiper: null,
  110. swiperOptions: {
  111. slidesPerView: "auto",
  112. centeredSlides: true,
  113. centerInsufficientSlides: true,
  114. centeredSlidesBounds: true,
  115. freeMode: {
  116. enabled: true,
  117. sticky: false,
  118. },
  119. },
  120. };
  121. },
  122. watch: {
  123. currentScenesList(val) {
  124. this.$nextTick(() => {
  125. this.initSceneSwiper();
  126. this.initRootGroupSwiper();
  127. if (this.info.navigationTrees[this.currentRootId]?.children[this.currentSecondId]?.type == "group") {
  128. this.initSecondGroupSwiper();
  129. }
  130. });
  131. },
  132. "info.navigationTrees": {
  133. // immediate: true,
  134. handler: function (newVal, oldVal) {
  135. if (newVal) {
  136. this.$nextTick(() => {
  137. // this.changeSceneList();
  138. });
  139. }
  140. },
  141. deep: true,
  142. },
  143. },
  144. computed: {
  145. ...mapState({
  146. isLockV4Scene: "isLockV4Scene",
  147. }),
  148. ...mapGetters({
  149. info: "base/baseInfo",
  150. currentScene: "scene/currentScene",
  151. currentScenesList: "scene/currentScenesList",
  152. currentSecondId: "navigation/currentSecondId",
  153. currentRootId: "navigation/currentRootId",
  154. isEditing: "isEditing",
  155. }),
  156. scenesListW() {
  157. return this?.currentScenesList?.length * (this.swidth["swScenes"] + 10) || 0;
  158. },
  159. secondaryW() {
  160. return this.info.navigationTrees[0].length * (this.swidth["swSecondary"] + 10);
  161. },
  162. catalogRootW() {
  163. // return this.info.navigationTrees.length * (this.swidth["swcatalogRoot"] + 10);
  164. return this.info.navigationTrees.length * (this.swidth["swcatalogRoot"] + 10);
  165. },
  166. rootTabIndex() {
  167. return this.info.navigationTrees.findIndex((item) => item.id == this.currentRootId);
  168. },
  169. secondTabIndex() {
  170. return this.info.navigationTrees[this.rootTabIndex].children.findIndex((item) => item.id == this.currentSecondId);
  171. },
  172. showSecondTab() {
  173. return this.info.navigationTrees[this.rootTabIndex].children.some((item) => item.id != this.currentSecondId);
  174. },
  175. },
  176. methods: {
  177. fixTitle(name) {
  178. if (name == "默认二级分组") {
  179. name = this.$i18n.t("navigation.default_group_two");
  180. } else if (name == "一级分组") {
  181. name = this.$i18n.t("navigation.group_one");
  182. } else {
  183. // eslint-disable-next-line no-self-assign
  184. name = name;
  185. }
  186. return name;
  187. },
  188. tabRoot(item) {
  189. this.$store.commit("navigation/setData", { currentRootId: item.id });
  190. this.changeSceneList();
  191. },
  192. tabSecond(item) {
  193. this.$store.commit("navigation/setData", { currentSecondId: item.id });
  194. let sceneList = this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex].children;
  195. this.$store.commit("scene/setCurrentScenesList", sceneList);
  196. // this.changeSceneList();
  197. },
  198. changeSceneList() {
  199. let currentList = null;
  200. if (this.info.navigationTrees[this.rootTabIndex].children.length && this.info.navigationTrees[this.rootTabIndex].children[0].type == "group") {
  201. this.$store.commit("navigation/setData", { currentSecondId: this.info.navigationTrees[this.rootTabIndex].children[0].id });
  202. currentList = this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex].children;
  203. this.$store.commit("scene/setCurrentScenesList", currentList);
  204. }
  205. if (this.secondTabIndex == -1) {
  206. console.error("没有二级目录");
  207. let rootList = this.info.navigationTrees.find((item) => item.id == this.currentRootId);
  208. this.$store.commit("scene/setCurrentScenesList", rootList.children);
  209. }
  210. this.$nextTick(() => {
  211. this.initSceneSwiper();
  212. this.initRootGroupSwiper();
  213. if (this.info.navigationTrees[this.currentRootId]?.children[this.currentSecondId]?.type == "group") {
  214. this.initSecondGroupSwiper();
  215. }
  216. });
  217. },
  218. initSceneSwiper() {
  219. if (this.SceneSwiper) {
  220. this.SceneSwiper.destroy();
  221. this.SceneSwiper = null;
  222. }
  223. if (!this.currentScenesList.length) {
  224. return;
  225. }
  226. this.SceneSwiper = new Swiper(".scene-list", this.swiperOptions);
  227. },
  228. tabCurrentScene(data, index) {
  229. this.$store.commit("scene/setCurrentScene", data);
  230. this.SceneSwiper.slideTo(index);
  231. },
  232. initSecondGroupSwiper() {
  233. if (this.SecondGroupSwiper) {
  234. this.SecondGroupSwiper.destroy();
  235. this.SecondGroupSwiper = null;
  236. }
  237. this.SecondGroupSwiper = new Swiper(".second-group-list", this.swiperOptions);
  238. },
  239. tabCurrentSecondGroup(data, index) {
  240. // this.$store.commit("scene/setCurrentScene", data);
  241. this.SecondGroupSwiper.slideTo(index);
  242. },
  243. initRootGroupSwiper() {
  244. if (this.rootGroupSwiper) {
  245. this.rootGroupSwiper.destroy();
  246. this.rootGroupSwiper = null;
  247. }
  248. this.rootGroupSwiper = new Swiper(".root-group-list", this.swiperOptions);
  249. },
  250. tabCurrentRootGroup(data, index) {
  251. // this.$store.commit("scene/setCurrentScene", data);
  252. this.SecondGroupSwiper.slideTo(index);
  253. },
  254. },
  255. mounted() {},
  256. };
  257. </script>
  258. <style lang="less" scoped>
  259. @width: 1150px;
  260. .swiper-slide {
  261. cursor: pointer;
  262. &.loopspan {
  263. > span,
  264. > div > span {
  265. animation: 5s wordsLoop linear infinite normal;
  266. }
  267. }
  268. }
  269. .bar-list {
  270. position: absolute;
  271. bottom: 28px;
  272. left: 50%;
  273. transform: translateX(-50%);
  274. text-align: center;
  275. max-width: @width;
  276. overflow: hidden;
  277. transition: 0.3s all ease;
  278. .top-con {
  279. display: inline-block;
  280. margin: 0 auto 10px;
  281. padding: 10px 6px;
  282. overflow: hidden;
  283. background: linear-gradient(268deg, transparent, rgba(0, 0, 0, 0.4) 25%, rgba(0, 0, 0, 0.4) 75%, transparent);
  284. .scene-list {
  285. max-width: @width;
  286. margin: 0 auto;
  287. // display: inline-block;
  288. .scene-wrapper {
  289. .scene-slide {
  290. margin: 0 5px;
  291. // white-space: nowrap;
  292. cursor: pointer;
  293. width: 72px;
  294. height: 72px;
  295. border-radius: 6px;
  296. border: 1px solid #fff;
  297. background-size: cover;
  298. position: relative;
  299. overflow: hidden;
  300. &.active {
  301. border: 1px solid #0076f6;
  302. .marquee {
  303. color: #fff !important;
  304. }
  305. }
  306. .scene-content {
  307. width: 100%;
  308. height: 100%;
  309. background-size: cover;
  310. position: relative;
  311. img {
  312. width: 100%;
  313. height: 100%;
  314. pointer-events: none;
  315. object-fit: cover;
  316. }
  317. > .iconfont {
  318. position: absolute;
  319. left: 4px;
  320. top: 4px;
  321. z-index: 99;
  322. text-shadow: 0px 0px 4px rgb(0, 0, 0, 0.3);
  323. }
  324. .marquee {
  325. position: absolute;
  326. bottom: 0;
  327. left: 0;
  328. height: 20px;
  329. background: rgba(0, 0, 0, 0.5);
  330. width: 100%;
  331. overflow: hidden;
  332. color: rgba(255, 255, 255, 0.6);
  333. > span {
  334. width: 100%;
  335. line-height: 20px;
  336. word-break: keep-all;
  337. display: inline-block;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. .second-group-box {
  345. .second-group-list {
  346. max-width: @width;
  347. margin: 0 auto;
  348. display: inline-block;
  349. .second-group-wrapper {
  350. .second-group-slide {
  351. width: 84px;
  352. box-sizing: border-box;
  353. overflow: hidden;
  354. padding-bottom: 6px;
  355. cursor: pointer;
  356. margin: 0 5px;
  357. white-space: nowrap;
  358. color: hsla(0, 0%, 100%, 0.6);
  359. margin: 20px auto 10px;
  360. &.active {
  361. color: #fff;
  362. &::before {
  363. content: "";
  364. display: inline-block;
  365. position: absolute;
  366. bottom: 0;
  367. width: 20px;
  368. height: 2px;
  369. z-index: 9999;
  370. left: 50%;
  371. transform: translateX(-50%);
  372. background: #0076f6;
  373. }
  374. }
  375. .second-group-content {
  376. // width: 100%;
  377. // height: 100%;
  378. // background-size: cover;
  379. // position: relative;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. .bottom-com {
  387. .root-group-list {
  388. max-width: @width;
  389. margin: 0 auto;
  390. .swiper-wrapper {
  391. }
  392. .root-group-wrapper {
  393. .root-group-slide {
  394. width: 104px;
  395. background: rgba(0, 0, 0, 0.5);
  396. border-radius: 4px;
  397. padding: 4px 10px;
  398. border: 1px solid hsla(0, 0%, 100%, 0.5);
  399. box-sizing: border-box;
  400. overflow: hidden;
  401. margin: 0 5px;
  402. white-space: nowrap;
  403. color: hsla(0, 0%, 100%, 0.6);
  404. &.active {
  405. border: 1px solid #fff;
  406. color: #fff;
  407. }
  408. .root-group-content {
  409. width: 100%;
  410. word-break: keep-all;
  411. }
  412. }
  413. }
  414. }
  415. }
  416. }
  417. </style>