Main.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <Panel v-show="player.showWidgets" :isOpen="isOpen">
  3. <div @click="toggleOpen" class="menu color">
  4. <div class="logo">
  5. <img :src="require('@/assets/images/icon/logo.png')" alt="" />
  6. <p>cdf澳門上葡京店</p>
  7. </div>
  8. <div class="vline"></div>
  9. <ul>
  10. <li v-if="tours.length > 0">
  11. <ui-icon type="preview" @click.stop="playTour"></ui-icon>
  12. <div>導覽</div>
  13. </li>
  14. <li @click.stop="onClickMenu(item)" v-for="(item, i) in menulist" :key="i">
  15. <ui-icon :type="item.icon"></ui-icon>
  16. <div>{{ item.name }}</div>
  17. </li>
  18. <li v-if="showdaogou">
  19. <ui-icon
  20. type="guided_shopping"
  21. @click.stop="
  22. onClickMenu({
  23. icon: 'guided_shopping',
  24. id: 'guided_shopping',
  25. name: '導購',
  26. })
  27. "
  28. ></ui-icon>
  29. <div>導購</div>
  30. </li>
  31. <li>
  32. <ui-icon
  33. type="shopping"
  34. @click.stop="
  35. onClickMenu({
  36. icon: 'shopping',
  37. id: 'shopping',
  38. name: '購物',
  39. })
  40. "
  41. ></ui-icon>
  42. <div>購物</div>
  43. </li>
  44. </ul>
  45. </div>
  46. <div class="toolbar color">
  47. <div class="navigation">
  48. <div class="h3">
  49. <span>專櫃導航</span>
  50. <div @click="showShopList = true">
  51. <img :src="require(`@/assets/images/icon/search.svg`)" alt="" />
  52. 搜索專櫃
  53. </div>
  54. </div>
  55. <div class="swiper-container" id="sw-navigation">
  56. <ul class="swiper-wrapper">
  57. <li
  58. class="swiper-slide"
  59. :class="{ liactive: item.sceneUrl === currentM && item.inPosition.indexOf(currentPose) > -1 }"
  60. @click.stop="onClickShop(item)"
  61. v-for="(item, i) in brandlist"
  62. :key="i"
  63. >
  64. <div v-if="item.shopLogo" class="img" :style="{ 'background-image': `url(${item.shopLogo})` }"></div>
  65. <div class="name" v-if="item.shopName">
  66. <span :class="{ active: item.shopName.length > 6 }">
  67. {{ item.shopName }}
  68. </span>
  69. </div>
  70. </li>
  71. </ul>
  72. </div>
  73. </div>
  74. <div class="category">
  75. <div class="swiper-container" id="sw-category">
  76. <ul class="swiper-wrapper">
  77. <li
  78. class="swiper-slide"
  79. :class="{ categoryactive: '' == currentCategory.id }"
  80. @click.stop="
  81. onClickCategory({
  82. id: '',
  83. categoryName: '全部',
  84. })
  85. "
  86. >
  87. <div>全部</div>
  88. </li>
  89. <li
  90. @click.stop="onClickCategory(item)"
  91. :class="{ categoryactive: item.id == currentCategory.id }"
  92. class="swiper-slide"
  93. v-for="(item, i) in categorylist"
  94. :key="i"
  95. >
  96. <div>{{ item.categoryName }}</div>
  97. </li>
  98. </ul>
  99. </div>
  100. </div>
  101. </div>
  102. <div v-show="showShopList" class="shoplist">
  103. <div class="l-title">
  104. 專櫃列表 ({{searchList.length}})
  105. <ui-icon type="close" @click="showShopList = false" />
  106. </div>
  107. <div class="search">
  108. <img :src="require(`@/assets/images/icon/search.svg`)" alt="" />
  109. <input v-model="searchKey" type="text" placeholder="專櫃搜索" />
  110. <ui-icon class="close" v-if="searchKey.length > 0" @click.stop="searchKey = ''" type="state_f"></ui-icon>
  111. </div>
  112. <ul v-if="searchList.length > 0">
  113. <li
  114. @click.stop="onClickShop(item)"
  115. v-for="(item, idx) in searchList" :key="idx">
  116. <div class="img" :style="{ 'background-image': `url(${item.shopLogo})` }"></div>
  117. <div class="name" v-if="item.shopName">
  118. <span :class="{ active: item.shopName.length > 6 }">
  119. {{ item.shopName }}
  120. </span>
  121. </div>
  122. <ui-icon class="right" type="right"></ui-icon>
  123. </li>
  124. </ul>
  125. <div class="noresult" v-else>暫無結果</div>
  126. </div>
  127. </Panel>
  128. </template>
  129. <script setup>
  130. import { useStore } from "vuex";
  131. import { onMounted, watch, computed, ref, nextTick } from "vue";
  132. import Panel from "@/views/Panel.vue";
  133. import { useApp, getApp } from "@/app";
  134. import * as apis from "@/apis/index.js";
  135. import browser from "@/utils/browser";
  136. const store = useStore();
  137. const isOpen = ref(false);
  138. const searchKey = ref("");
  139. const showShopList = ref(false);
  140. const toggleOpen = () => {
  141. isOpen.value = !isOpen.value;
  142. };
  143. const currentCategory = ref({
  144. id: "",
  145. categoryName: "全部",
  146. });
  147. const currentM = computed(() => browser.getURLParam("m"));
  148. const currentPose = computed(() => browser.getURLParam("pose"));
  149. const showdaogou = computed(() => store.getters["rtc/showdaogou"]);
  150. const isPlay = computed(() => {
  151. let status = store.getters["tour/isPlay"];
  152. let map = document.querySelector(".kankan-app div[xui_min_map]");
  153. if (map) {
  154. if (status) {
  155. map.classList.add("disabled");
  156. } else {
  157. map.classList.remove("disabled");
  158. }
  159. }
  160. return status;
  161. });
  162. const partId = computed(() => store.getters["tour/partId"]);
  163. const playTour = async () => {
  164. let player = await getApp().TourManager.player;
  165. if (isPlay.value) {
  166. store.commit("tour/setData", { isPlay: true });
  167. player.pause();
  168. } else {
  169. store.commit("tour/setData", { isPlay: true });
  170. player.play(partId.value);
  171. }
  172. };
  173. const metadata = computed(() => store.getters["scene/metadata"]);
  174. const player = computed(() => store.getters["player"]);
  175. const tours = computed(() => store.getters["tour/tours"]);
  176. const menulist = computed(() => {
  177. let fff = [
  178. {
  179. icon: "help",
  180. id: "help",
  181. name: "幫助",
  182. },
  183. {
  184. icon: "customer_service",
  185. id: "kefu",
  186. name: "客服",
  187. },
  188. ];
  189. if (!browser.isMobile()) {
  190. fff.shift();
  191. }
  192. return fff;
  193. });
  194. const categorylist = ref([]);
  195. const brandlist = ref([]);
  196. const searchList = ref([]);
  197. const brandScroll = () => {
  198. nextTick(() => {
  199. let t = setTimeout(() => {
  200. clearTimeout(t);
  201. new Swiper("#sw-navigation", {
  202. freeMode: true,
  203. slidesPerView: "auto",
  204. centeredSlides: false,
  205. spaceBetween: 10,
  206. grid: {
  207. rows: 2,
  208. },
  209. on: {
  210. touchMove(swiper, e) {
  211. e.stopPropagation();
  212. e.preventDefault();
  213. },
  214. },
  215. });
  216. new Swiper("#sw-category", {
  217. freeMode: true,
  218. slidesPerView: "auto",
  219. spaceBetween: 10,
  220. on: {
  221. touchMove(swiper, e) {
  222. e.stopPropagation();
  223. e.preventDefault();
  224. },
  225. },
  226. });
  227. }, 100);
  228. });
  229. };
  230. const onClickMenu = (item) => {
  231. if (item.id == "kefu") {
  232. let mglink =
  233. "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";
  234. window.open(mglink, "_blank");
  235. } else if (item.id == "shopping") {
  236. browser.openLink(
  237. "/subPackage/pages/shoppingcart/shoppingcart",
  238. "https://m.cdfmembers.com/shop/600667208/shoppingcart",
  239. "/subPackage/pages/shoppingcart/shoppingcart"
  240. );
  241. } else if (item.id == "help") {
  242. store.commit("showUserGuide", true);
  243. } else if (item.id == "guided_shopping") {
  244. store.commit("showShoppingguide", true);
  245. }
  246. };
  247. const getCategorylist = async () => {
  248. let res = await apis.get_category_list({});
  249. categorylist.value = res.data;
  250. brandScroll();
  251. };
  252. const onClickCategory = (item) => {
  253. currentCategory.value.id = item.id;
  254. currentCategory.value.categoryName = item.categoryName;
  255. };
  256. const onClickShop = (item) => {
  257. let url = window.location.href;
  258. if (!browser.hasURLParam("pose")) {
  259. url += `&${item.inPosition}`;
  260. } else {
  261. url = browser.replaceQueryString(url, "pose", item.inPosition.replace("pose=", ""));
  262. }
  263. url = browser.replaceQueryString(url, "m", item.sceneUrl);
  264. window.location.href = url;
  265. };
  266. watch(
  267. () => currentCategory,
  268. (val, old) => {
  269. getShoplist();
  270. },
  271. {
  272. deep: true,
  273. }
  274. );
  275. watch(
  276. () => searchKey.value,
  277. (val, old) => {
  278. console.log(searchKey.value);
  279. getSearchList();
  280. }
  281. );
  282. const getShoplist = async () => {
  283. let res = await apis.get_shop_list({
  284. categoryId: currentCategory.value.id,
  285. });
  286. brandlist.value = res.data;
  287. brandScroll();
  288. };
  289. const getSearchList = async () => {
  290. let res = await apis.get_shop_list({
  291. shopName: searchKey.value,
  292. });
  293. searchList.value = res.data;
  294. console.log(searchList.value);
  295. };
  296. onMounted(() => {
  297. useApp().then((app) => {
  298. getCategorylist();
  299. getShoplist();
  300. });
  301. });
  302. </script>
  303. <style lang="scss" scoped>
  304. .menu {
  305. width: 100%;
  306. border-radius: 6px;
  307. border: 1px solid rgba(255, 255, 255, 0.2);
  308. background: rgba(0, 0, 0, 0.2);
  309. display: flex;
  310. justify-content: space-between;
  311. box-sizing: border-box;
  312. position: relative;
  313. align-items: center;
  314. height: 48px;
  315. padding: 0 12px;
  316. text-align: center;
  317. .logo {
  318. width: 90px;
  319. transform: translateY(-24%);
  320. > img {
  321. width: 100%;
  322. border-radius: 4px;
  323. }
  324. > p {
  325. margin: 2px 0;
  326. font-size: 10px;
  327. }
  328. }
  329. .vline {
  330. width: 1px;
  331. height: 14px;
  332. background: #fff;
  333. }
  334. > ul {
  335. display: flex;
  336. align-items: center;
  337. font-size: 0;
  338. justify-content: flex-end;
  339. > li {
  340. margin-left: 0.5rem;
  341. &:first-of-type {
  342. margin-left: 0;
  343. }
  344. > div {
  345. margin-top: 4px;
  346. font-size: 10px;
  347. }
  348. }
  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>