Main.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <div>
  3. <Panel v-show="player.showWidgets" :class="{ disabled: !showdaogou }" :isOpen="isOpen">
  4. <div @click="toggleOpen" class="menu color">
  5. <div class="logo">
  6. <img :src="require('@/assets/images/icon/logo.png')" alt="" />
  7. <p v-if="player.lang != 'en'">{{$t('common.title') }}</p>
  8. </div>
  9. <div class="vline"></div>
  10. <ul :class="player.lang" @touchmove.stop>
  11. <li v-if="tours.length > 0">
  12. <ui-icon type="preview" @click.stop="playTour"></ui-icon>
  13. <div>{{$t('common.tour')}}</div>
  14. </li>
  15. <li @click.stop="onClickMenu(item)" v-for="(item, i) in menulist" :key="i">
  16. <ui-icon :type="item.icon"></ui-icon>
  17. <div>{{ item.name }}</div>
  18. </li>
  19. <li v-if="showdaogou">
  20. <ui-icon
  21. type="guided_shopping"
  22. @click.stop="
  23. onClickMenu({
  24. icon: 'guided_shopping',
  25. id: 'guided_shopping',
  26. name: $t('common.mode'),
  27. })
  28. "
  29. ></ui-icon>
  30. <div>{{ $t('common.mode') }}</div>
  31. </li>
  32. <li>
  33. <ui-icon
  34. type="shopping"
  35. @click.stop="
  36. onClickMenu({
  37. icon: 'shopping',
  38. id: 'shopping',
  39. name: $t('common.shopping'),
  40. })
  41. "
  42. ></ui-icon>
  43. <div>{{ $t('common.shopping') }}</div>
  44. </li>
  45. </ul>
  46. </div>
  47. <div class="toolbar color">
  48. <div class="navigation">
  49. <div class="h3">
  50. <span>{{ $t('common.guide') }}</span>
  51. <div @click="showShopList = true">
  52. <img :src="require(`@/assets/images/icon/search.svg`)" alt="" />
  53. {{ $t('common.searchguide') }}
  54. </div>
  55. </div>
  56. <div class="swiper-container" id="sw-navigation">
  57. <ul class="swiper-wrapper">
  58. <li
  59. class="swiper-slide"
  60. :class="{ liactive: item.sceneUrl === currentM && item.inPosition.indexOf(currentPose) > -1 }"
  61. @click.stop="onClickShop(item)"
  62. v-for="(item, i) in brandlist"
  63. :key="i"
  64. >
  65. <div v-if="item.shopLogo" class="img" :style="{ 'background-image': `url(${item.shopLogo})` }"></div>
  66. <div class="name" v-if="item.shopName">
  67. <span :class="{ active: item.shopName.length > 6 }">
  68. {{ item.shopName }}
  69. </span>
  70. </div>
  71. </li>
  72. </ul>
  73. </div>
  74. </div>
  75. <div class="category">
  76. <div class="swiper-container" id="sw-category">
  77. <ul class="swiper-wrapper">
  78. <li
  79. class="swiper-slide"
  80. :class="{ categoryactive: '' == currentCategory.id }"
  81. @click.stop="
  82. onClickCategory({
  83. id: '',
  84. categoryName: $t('common.all'),
  85. })
  86. "
  87. >
  88. <div>{{ $t('common.all') }}</div>
  89. </li>
  90. <li @click.stop="onClickCategory(item)" :class="{ categoryactive: item.id == currentCategory.id }" class="swiper-slide" v-for="(item, i) in categorylist" :key="i">
  91. <div>{{ item.categoryName }}</div>
  92. </li>
  93. </ul>
  94. </div>
  95. </div>
  96. </div>
  97. </Panel>
  98. <teleport :to="`#app`">
  99. <div v-show="showShopList" class="shoplist">
  100. <div class="l-title">
  101. {{ $t('common.guidelist') }} ({{ searchList.length }})
  102. <ui-icon type="close" @click="showShopList = false" />
  103. </div>
  104. <div class="search">
  105. <img :src="require(`@/assets/images/icon/search.svg`)" alt="" />
  106. <input v-model="searchKey" type="text" :placeholder="$t('common.guideSearch')" />
  107. <ui-icon class="close" v-if="searchKey.length > 0" @click.stop="searchKey = ''" type="state_f"></ui-icon>
  108. </div>
  109. <ul v-if="searchList.length > 0">
  110. <li @click.stop="onClickShop(item)" v-for="(item, idx) in searchList" :key="idx">
  111. <div class="img" :style="{ 'background-image': `url(${item.shopLogo})` }"></div>
  112. <div class="name" v-if="item.shopName">
  113. <span>
  114. {{ item.shopName }}
  115. </span>
  116. </div>
  117. <ui-icon class="right" type="right"></ui-icon>
  118. </li>
  119. </ul>
  120. <div class="noresult" v-else>{{ $t('common.noResult') }}</div>
  121. </div>
  122. </teleport>
  123. </div>
  124. </template>
  125. <script setup>
  126. import { useStore } from 'vuex';
  127. import { onMounted, watch, computed, ref, nextTick } from 'vue';
  128. import Panel from '@/views/Panel.vue';
  129. import { useApp, getApp } from '@/app';
  130. import * as apis from '@/apis/index.js';
  131. import browser from '@/utils/browser';
  132. import { useI18n, getLocale } from '@/i18n';
  133. const { t } = useI18n({ useScope: 'global' });
  134. const store = useStore();
  135. const isOpen = ref(false);
  136. const searchKey = ref('');
  137. const showShopList = ref(false);
  138. const toggleOpen = () => {
  139. isOpen.value = !isOpen.value;
  140. };
  141. const currentCategory = ref({
  142. id: '',
  143. categoryName: '全部',
  144. });
  145. const currentM = computed(() => browser.getURLParam('m'));
  146. const currentPose = computed(() => browser.getURLParam('pose'));
  147. const showdaogou = computed(() => store.getters['rtc/showdaogou']);
  148. const isPlay = computed(() => {
  149. let status = store.getters['tour/isPlay'];
  150. let map = document.querySelector('.kankan-app div[xui_min_map]');
  151. if (map) {
  152. if (status) {
  153. map.classList.add('disabled');
  154. } else {
  155. map.classList.remove('disabled');
  156. }
  157. }
  158. return status;
  159. });
  160. const partId = computed(() => store.getters['tour/partId']);
  161. const playTour = async () => {
  162. let player = await getApp().TourManager.player;
  163. if (isPlay.value) {
  164. store.commit('tour/setData', { isHome: true });
  165. player.pause();
  166. } else {
  167. store.commit('tour/setData', { isHome: false });
  168. player.play(partId.value);
  169. }
  170. };
  171. const metadata = computed(() => store.getters['scene/metadata']);
  172. const player = computed(() => store.getters['player']);
  173. const tours = computed(() => store.getters['tour/tours']);
  174. const menulist = computed(() => {
  175. let fff = [
  176. {
  177. icon: 'help',
  178. id: 'help',
  179. name: t('common.help'),
  180. },
  181. {
  182. icon: 'customer_service',
  183. id: 'kefu',
  184. name: t('common.kefu'),
  185. },
  186. ];
  187. if (!browser.isMobile()) {
  188. fff.shift();
  189. }
  190. return fff;
  191. });
  192. const categorylist = ref([]);
  193. const brandlist = ref([]);
  194. const searchList = ref([]);
  195. const brandScroll = () => {
  196. nextTick(() => {
  197. let t = setTimeout(() => {
  198. clearTimeout(t);
  199. new Swiper('#sw-navigation', {
  200. freeMode: true,
  201. slidesPerView: 'auto',
  202. centeredSlides: false,
  203. spaceBetween: 10,
  204. grid: {
  205. rows: 2,
  206. },
  207. on: {
  208. touchMove(swiper, e) {
  209. e.stopPropagation();
  210. e.preventDefault();
  211. },
  212. },
  213. });
  214. new Swiper('#sw-category', {
  215. freeMode: true,
  216. slidesPerView: 'auto',
  217. spaceBetween: 10,
  218. on: {
  219. touchMove(swiper, e) {
  220. e.stopPropagation();
  221. e.preventDefault();
  222. },
  223. },
  224. });
  225. }, 100);
  226. });
  227. };
  228. const onClickMenu = (item) => {
  229. if (item.id == 'kefu') {
  230. let mglink =
  231. 'https://webpage.qidian.qq.com/2/chat/h5/index.html?linkType=1&env=ol&kfuin=3009110132&fid=3655&key=9b4334768c39150ead3f23e11e5dc2e4&cate=7&source=0&isLBS=0&isCustomEntry=0&type=10&ftype=1&_type=wpa&qidian=true&_pid=kvrmvu.74cg11.l43qvbcu&translateSwitch=0&isSsc=0&roleValue=4&roleData=922223821';
  232. window.open(mglink, '_blank');
  233. } else if (item.id == 'shopping') {
  234. browser.openLink('/subPackage/pages/shoppingcart/shoppingcart', 'https://m.cdfmembers.com/shop/600667208/shoppingcart', '/subPackage/pages/shoppingcart/shoppingcart');
  235. } else if (item.id == 'help') {
  236. store.commit('showUserGuide', true);
  237. } else if (item.id == 'guided_shopping') {
  238. store.commit('showShoppingguide', true);
  239. }
  240. };
  241. const getCategorylist = async () => {
  242. let res = await apis.get_category_list({});
  243. categorylist.value = res.data;
  244. brandScroll();
  245. };
  246. const onClickCategory = (item) => {
  247. currentCategory.value.id = item.id;
  248. currentCategory.value.categoryName = item.categoryName;
  249. };
  250. const onClickShop = (item) => {
  251. let url = window.location.href;
  252. if (!browser.hasURLParam('pose')) {
  253. url += `&${item.inPosition}`;
  254. } else {
  255. url = browser.replaceQueryString(url, 'pose', item.inPosition.replace('pose=', ''));
  256. }
  257. url = browser.replaceQueryString(url, 'm', item.sceneUrl);
  258. window.location.href = url;
  259. };
  260. watch(
  261. () => currentCategory,
  262. (val, old) => {
  263. getShoplist();
  264. },
  265. {
  266. deep: true,
  267. }
  268. );
  269. watch(
  270. () => searchKey.value,
  271. (val, old) => {
  272. console.log(searchKey.value);
  273. getSearchList();
  274. }
  275. );
  276. const getShoplist = async () => {
  277. let res = await apis.get_shop_list({
  278. categoryId: currentCategory.value.id,
  279. });
  280. brandlist.value = res.data;
  281. brandScroll();
  282. };
  283. const getSearchList = async () => {
  284. let res = await apis.get_shop_list({
  285. shopName: searchKey.value,
  286. });
  287. searchList.value = res.data;
  288. };
  289. onMounted(() => {
  290. useApp().then((app) => {
  291. getCategorylist();
  292. getShoplist();
  293. });
  294. });
  295. </script>
  296. <style lang="scss" scoped>
  297. .menu {
  298. width: 100%;
  299. border-radius: 6px;
  300. border: 1px solid rgba(255, 255, 255, 0.2);
  301. background: rgba(0, 0, 0, 0.2);
  302. display: flex;
  303. justify-content: space-between;
  304. box-sizing: border-box;
  305. position: relative;
  306. align-items: center;
  307. height: 48px;
  308. padding: 0 12px;
  309. text-align: center;
  310. .logo {
  311. width: 90px;
  312. transform: translateY(-24%);
  313. min-width: 90px;
  314. flex-shrink: 0;
  315. > img {
  316. width: 100%;
  317. border-radius: 4px;
  318. }
  319. > p {
  320. margin: 2px 0;
  321. font-size: 10px;
  322. }
  323. }
  324. .vline {
  325. width: 1px;
  326. height: 14px;
  327. background: #fff;
  328. }
  329. > ul {
  330. display: flex;
  331. align-items: center;
  332. font-size: 0;
  333. justify-content: flex-end;
  334. overflow-x: auto;
  335. > li {
  336. margin-left: 0.4rem;
  337. &:first-of-type {
  338. margin-left: 0;
  339. }
  340. > div {
  341. margin-top: 4px;
  342. font-size: 10px;
  343. }
  344. }
  345. }
  346. .en{
  347. justify-content: flex-start;
  348. width: calc(100% - 100px);
  349. }
  350. }
  351. .toolbar {
  352. width: 100%;
  353. border-radius: 6px;
  354. border: 1px solid rgba(255, 255, 255, 0.2);
  355. margin-top: 8px;
  356. margin-bottom: 30px;
  357. background: rgba(0, 0, 0, 0.2);
  358. .navigation {
  359. padding: 8px 0;
  360. .h3 {
  361. font-size: 14px;
  362. padding: 0 14px;
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. > div {
  367. width: 96px;
  368. height: 24px;
  369. background: rgba(0, 0, 0, 0.5);
  370. border-radius: 24px;
  371. display: flex;
  372. font-size: 12px;
  373. justify-content: center;
  374. align-items: center;
  375. }
  376. img {
  377. width: 12px;
  378. margin-right: 6px;
  379. }
  380. }
  381. .swiper-container {
  382. width: 100%;
  383. height: 130px;
  384. overflow: hidden;
  385. margin-top: 8px;
  386. padding-right: 2px;
  387. padding-left: 14px;
  388. position: relative;
  389. &::after {
  390. position: absolute;
  391. right: 0;
  392. bottom: 0;
  393. content: '';
  394. display: inline-block;
  395. height: 100%;
  396. z-index: 99;
  397. width: 17px;
  398. background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000000 100%);
  399. opacity: 0.4;
  400. pointer-events: none;
  401. }
  402. > ul {
  403. margin: 0 !important;
  404. > li {
  405. width: 60px;
  406. height: 60px;
  407. border-radius: 4px;
  408. position: relative;
  409. font-size: 0;
  410. overflow: hidden;
  411. border: 1px transparent solid;
  412. box-sizing: border-box;
  413. &.liactive {
  414. color: var(--editor-main-color);
  415. border: 1px var(--editor-main-color) solid;
  416. }
  417. .img {
  418. width: 100%;
  419. height: 100%;
  420. background-size: contain;
  421. }
  422. .name {
  423. width: 100%;
  424. position: absolute;
  425. bottom: -1px;
  426. font-size: 12px;
  427. left: 0;
  428. background: rgba(0, 0, 0, 0.5);
  429. // text-overflow: ellipsis;
  430. // white-space: nowrap;
  431. // overflow: hidden;
  432. text-align: center;
  433. padding: 2px 4px;
  434. box-sizing: border-box;
  435. word-break: break-all;
  436. > span {
  437. display: inline-block;
  438. white-space: nowrap;
  439. }
  440. .active {
  441. animation: 5s wordsLoop linear infinite normal;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. }
  448. .category {
  449. padding: 8px 14px;
  450. border-top: 1px solid rgba(255, 255, 255, 0.2);
  451. .swiper-container {
  452. width: 100%;
  453. overflow: hidden;
  454. > ul {
  455. > li {
  456. width: auto;
  457. color: rgba(255, 255, 255, 0.5);
  458. > div {
  459. width: 100%;
  460. font-size: 14px;
  461. padding: 2px 4px;
  462. }
  463. }
  464. .categoryactive {
  465. color: #fff;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. .shoplist {
  472. position: fixed;
  473. z-index: 999;
  474. width: 100%;
  475. height: 30px;
  476. left: 0;
  477. right: 0;
  478. bottom: 0;
  479. height: 80vh;
  480. background: rgba(0, 0, 0, 0.8);
  481. border-radius: 10px 10px 0px 0px;
  482. padding: 12px 15px;
  483. .l-title {
  484. font-size: 16px;
  485. font-weight: bold;
  486. color: #ffffff;
  487. text-align: center;
  488. position: relative;
  489. width: 100%;
  490. i {
  491. position: absolute;
  492. right: 0;
  493. top: 2px;
  494. }
  495. }
  496. .search {
  497. width: 100%;
  498. height: 34px;
  499. background: rgba(46, 46, 46, 0.9);
  500. border-radius: 20px;
  501. display: flex;
  502. justify-content: space-between;
  503. align-items: center;
  504. padding: 0 8px;
  505. margin-top: 20px;
  506. > img {
  507. width: 16px;
  508. opacity: 0.8;
  509. }
  510. > input {
  511. text-align: left;
  512. font-size: 16px;
  513. width: 100%;
  514. color: #fff;
  515. margin-left: 10px;
  516. }
  517. .close {
  518. color: #7d7e80;
  519. }
  520. }
  521. > ul {
  522. width: 100%;
  523. height: calc(100% - 80px);
  524. overflow-y: auto;
  525. > li {
  526. width: 100%;
  527. height: 60px;
  528. position: relative;
  529. font-size: 0;
  530. overflow: hidden;
  531. box-sizing: border-box;
  532. display: flex;
  533. justify-content: center;
  534. align-items: center;
  535. margin: 18px 0;
  536. .img {
  537. width: 60px;
  538. height: 60px;
  539. background-size: contain;
  540. flex-shrink: 0;
  541. border-radius: 4px;
  542. margin-right: 10px;
  543. }
  544. .name {
  545. width: 100%;
  546. font-size: 12px;
  547. left: 0;
  548. text-overflow: ellipsis;
  549. white-space: nowrap;
  550. overflow: hidden;
  551. text-align: left;
  552. padding: 2px 4px;
  553. box-sizing: border-box;
  554. word-break: break-all;
  555. > span {
  556. display: inline-block;
  557. white-space: nowrap;
  558. }
  559. }
  560. .right {
  561. font-size: 14px;
  562. }
  563. }
  564. }
  565. }
  566. .noresult {
  567. text-align: center;
  568. margin-top: 20vh;
  569. }
  570. @keyframes wordsLoop {
  571. 0% {
  572. transform: translateX(100%);
  573. -webkit-transform: translateX(100%);
  574. }
  575. 100% {
  576. transform: translateX(-100%);
  577. -webkit-transform: translateX(-100%);
  578. }
  579. }
  580. </style>