Main.vue 15 KB

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