list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div
  3. class="bar-list"
  4. v-if="
  5. show &&
  6. !(
  7. metadata.catalogRoot &&
  8. metadata.catalogRoot.length == 1 &&
  9. scenes.length == 1 &&
  10. secondaryList.length == 1
  11. )
  12. "
  13. :class="{ barshow: isShowScenesList }"
  14. >
  15. <div class="top-con">
  16. <div
  17. class="swiper-container"
  18. id="swScenes"
  19. :style="`width:${Math.min(scenesListW, innerW)}px;
  20. padding:${scenesListW > innerW ? '0 15px' : '0'}`"
  21. v-if="currentScenesList.length > 0"
  22. >
  23. <ul class="swiper-wrapper">
  24. <li
  25. @click="tabCurrentScene(item)"
  26. class="swiper-slide"
  27. :class="{
  28. active: currentScene.sceneCode == item.sceneCode,
  29. loopspan:
  30. item.sceneTitle.length > spanlength &&
  31. currentScene.id == item.id,
  32. }"
  33. :style="{ backgroundImage: `url(${item.icon})` }"
  34. v-for="(item, i) in currentScenesList"
  35. :key="i"
  36. >
  37. <i
  38. class="iconfont"
  39. :class="
  40. item.type == '4dkk' ? 'icon-editor_3d' : 'icon-editor_panoramic'
  41. "
  42. ></i>
  43. <div>
  44. <span v-if="currentScene.id == item.id">{{
  45. item.sceneTitle
  46. }}</span>
  47. <span v-else>{{
  48. item.sceneTitle.length > spanlength
  49. ? item.sceneTitle.slice(0, spanlength)
  50. : item.sceneTitle
  51. }}</span>
  52. </div>
  53. </li>
  54. </ul>
  55. </div>
  56. <div
  57. class="swiper-container"
  58. id="swSecondary"
  59. :style="`width:${Math.min(secondaryW, innerW)}px;
  60. padding:${secondaryW > innerW ? '0 15px' : '0'}`"
  61. v-if="secondaryList.length > 1"
  62. >
  63. <ul class="swiper-wrapper">
  64. <li
  65. class="swiper-slide"
  66. @click="tabSecondary(item)"
  67. :class="{
  68. active: currentSecondary.id == item.id,
  69. loopspan:
  70. fixTitle(item.name).length > spanlength &&
  71. currentSecondary.id == item.id,
  72. }"
  73. v-for="(item, i) in secondaryList"
  74. :key="i"
  75. >
  76. <span v-if="currentSecondary.id == item.id">{{
  77. fixTitle(item.name)
  78. }}</span>
  79. <span v-else>{{
  80. fixTitle(item.name).length > spanlength
  81. ? fixTitle(item.name).slice(0, spanlength)
  82. : fixTitle(item.name)
  83. }}</span>
  84. </li>
  85. </ul>
  86. </div>
  87. </div>
  88. <div
  89. class="swiper-container"
  90. id="swcatalogRoot"
  91. :style="`width:${Math.min(catalogRootW, innerW)}px;
  92. padding:${catalogRootW > innerW ? '0 15px' : '0'}`"
  93. v-if="metadata.catalogRoot.length > 0 && metadata.catalogs.length > 1"
  94. >
  95. <ul class="swiper-wrapper" v-show="metadata.catalogRoot.length > 1">
  96. <li
  97. class="swiper-slide"
  98. :class="{
  99. active: currentCatalogRoot.id == item.id,
  100. loopspan:
  101. fixTitle(item.name).length > spanlength &&
  102. currentCatalogRoot.id == item.id,
  103. }"
  104. @click="tabRoot(item)"
  105. v-for="(item, i) in metadata.catalogRoot"
  106. :key="i"
  107. >
  108. <span v-if="currentCatalogRoot.id == item.id">{{
  109. fixTitle(item.name)
  110. }}</span>
  111. <span v-else>{{
  112. fixTitle(item.name).length > spanlength
  113. ? fixTitle(item.name).slice(0, spanlength)
  114. : fixTitle(item.name)
  115. }}</span>
  116. </li>
  117. </ul>
  118. </div>
  119. </div>
  120. </template>
  121. <script setup>
  122. import { ref, watch, computed, onMounted, nextTick } from "vue";
  123. import { useStore } from "vuex";
  124. import { useApp } from "@/app";
  125. import { useI18n, getLocale } from "@/i18n";
  126. const { t } = useI18n({ useScope: "global" });
  127. const store = useStore();
  128. const spanlength = ref(5);
  129. const metadata = computed(() => store.getters["scene/metadata"]);
  130. const scenes = computed(() => store.getters["scene/list"]);
  131. const currentScene = computed(() => store.getters["scene/currentScene"]);
  132. const currentCatalogRoot = computed(
  133. () => store.getters["scene/currentCatalogRoot"]
  134. );
  135. const currentSecondary = computed(
  136. () => store.getters["scene/currentSecondary"]
  137. );
  138. const secondaryList = computed(() => store.getters["scene/secondaryList"]);
  139. const isShowScenesList = computed(
  140. () => store.getters["functions/isShowScenesList"]
  141. );
  142. const currentScenesList = computed(
  143. () => store.getters["scene/currentScenesList"]
  144. );
  145. const swidth = ref({
  146. swcatalogRoot: 104,
  147. swSecondary: 84,
  148. swScenes: 72,
  149. });
  150. const innerW = computed(() => window.innerWidth);
  151. const scenesListW = computed(
  152. () => currentScenesList.value.length * (swidth.value["swScenes"] + 10) - 10
  153. );
  154. const secondaryW = computed(
  155. () => secondaryList.value.length * (swidth.value["swSecondary"] + 10) - 10
  156. );
  157. const catalogRootW = computed(
  158. () =>
  159. metadata.value.catalogRoot.length * (swidth.value["swcatalogRoot"] + 10) -
  160. 10
  161. );
  162. const show = ref(false);
  163. const tabCurrentScene = (data) => {
  164. store.commit("scene/setCurrentScene", data);
  165. };
  166. const tabSecondary = (data) => {
  167. store.commit("scene/setCurrentSecondary", data);
  168. };
  169. const tabRoot = (data) => {
  170. store.commit("scene/setCurrentCatalogRoot", data);
  171. };
  172. const fixTitle = (name) => {
  173. if (name == "默认二级分组") {
  174. name = t("navigation.default_group_two");
  175. } else if (name == "一级分组") {
  176. name = t("navigation.group_one");
  177. } else {
  178. name = name;
  179. }
  180. return name;
  181. };
  182. const loadList = () => {
  183. nextTick(() => {
  184. let t = setTimeout(() => {
  185. clearTimeout(t);
  186. ["#swcatalogRoot", "#swSecondary", "#swScenes"].forEach((item) => {
  187. let tmp = new Swiper(item, {
  188. slidesPerView: "auto",
  189. centeredSlides: true,
  190. spaceBetween: 10,
  191. centerInsufficientSlides: true,
  192. centeredSlidesBounds: true,
  193. freeMode: true,
  194. observer: true,
  195. observeParents: true,
  196. });
  197. if (item == "#swScenes") {
  198. setTimeout(() => {
  199. if (tmp && "slideTo" in tmp) {
  200. // tmp.slideTo(0, 80, false);
  201. }
  202. }, 0);
  203. }
  204. // console.log(tmp.slideTo);
  205. });
  206. }, 100);
  207. });
  208. };
  209. watch(currentSecondary, () => {
  210. loadList();
  211. });
  212. watch(currentScenesList, () => {
  213. loadList();
  214. });
  215. onMounted(() => {
  216. useApp().then(async (app) => {
  217. show.value = true;
  218. loadList();
  219. });
  220. });
  221. </script>
  222. <style lang="scss" scoped>
  223. .bar-list {
  224. position: absolute;
  225. bottom: 88px;
  226. left: 50%;
  227. transform: translateX(-50%);
  228. text-align: center;
  229. overflow: hidden;
  230. max-height: 0;
  231. transition: 0.3s all ease;
  232. z-index: 9;
  233. width: 100%;
  234. .swiper-container {
  235. width: 100%;
  236. position: relative;
  237. margin: 0 auto;
  238. > ul {
  239. > li {
  240. white-space: nowrap;
  241. > span,
  242. > div > span {
  243. cursor: pointer;
  244. display: inline-block;
  245. color: rgba(255, 255, 255, 0.6);
  246. }
  247. &.loopspan {
  248. > span,
  249. > div > span {
  250. animation: 5s wordsLoop linear infinite normal;
  251. }
  252. }
  253. &.active {
  254. > span,
  255. > div > span {
  256. color: rgba(255, 255, 255, 1);
  257. }
  258. }
  259. }
  260. }
  261. }
  262. .top-con {
  263. margin-bottom: 10px;
  264. padding: 10px 0;
  265. width: 100%;
  266. background: rgba(0, 0, 0, 0.5);
  267. }
  268. #swcatalogRoot {
  269. padding: 0 15px;
  270. > ul {
  271. > li {
  272. width: 104px;
  273. background: rgba(0, 0, 0, 0.5);
  274. border-radius: 4px;
  275. padding: 4px 10px;
  276. border: 1px solid rgba(255, 255, 255, 0.5);
  277. box-sizing: border-box;
  278. overflow: hidden;
  279. > span {
  280. width: 100%;
  281. word-break: keep-all;
  282. }
  283. &.active {
  284. border: 1px solid rgba(255, 255, 255, 1);
  285. }
  286. }
  287. }
  288. }
  289. #swSecondary {
  290. margin: 20px auto 10px;
  291. padding: 0 15px;
  292. > ul {
  293. > li {
  294. width: 84px;
  295. box-sizing: border-box;
  296. overflow: hidden;
  297. padding-bottom: 6px;
  298. > span {
  299. width: 100%;
  300. word-break: keep-all;
  301. }
  302. &.active {
  303. position: relative;
  304. &::before {
  305. content: "";
  306. display: inline-block;
  307. position: absolute;
  308. bottom: 0;
  309. width: 20px;
  310. height: 2px;
  311. z-index: 9999;
  312. left: 50%;
  313. transform: translateX(-50%);
  314. background: var(--colors-primary-base);
  315. }
  316. }
  317. }
  318. }
  319. }
  320. #swScenes {
  321. // padding: 0 15px;
  322. > ul {
  323. > li {
  324. cursor: pointer;
  325. width: 72px;
  326. height: 72px;
  327. border-radius: 6px;
  328. border: 1px solid #ffffff;
  329. background-size: cover;
  330. position: relative;
  331. overflow: hidden;
  332. .iconfont {
  333. position: absolute;
  334. left: 4px;
  335. top: 4px;
  336. z-index: 99;
  337. &::after {
  338. background: rgba(0, 0, 0, 0.3);
  339. content: "";
  340. width: 14px;
  341. height: 14px;
  342. display: inline-block;
  343. position: absolute;
  344. top: 50%;
  345. left: 50%;
  346. transform: translate(-50%, -50%);
  347. z-index: -1;
  348. filter: blur(4px);
  349. }
  350. }
  351. > div {
  352. position: absolute;
  353. bottom: 0;
  354. left: 0;
  355. height: 20px;
  356. background: rgba(0, 0, 0, 0.5);
  357. width: 100%;
  358. overflow: hidden;
  359. > span {
  360. width: 100%;
  361. line-height: 20px;
  362. word-break: keep-all;
  363. }
  364. }
  365. &.active {
  366. border: 1px solid var(--colors-primary-base);
  367. > div {
  368. > span {
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. .barshow {
  377. max-height: 190px;
  378. }
  379. @keyframes wordsLoop {
  380. 0% {
  381. transform: translateX(100%);
  382. -webkit-transform: translateX(100%);
  383. }
  384. 100% {
  385. transform: translateX(-100%);
  386. -webkit-transform: translateX(-100%);
  387. }
  388. }
  389. </style>