control.fdkk.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <ul
  3. class="control-fdkk"
  4. v-if="
  5. (fdkkmetadata &&
  6. fdkkCurrentVersion != 'V3' &&
  7. fdkkmetadata &&
  8. !fdkkmetadata.controls.showMap &&
  9. (fdkkmetadata.controls.showPanorama ||
  10. fdkkmetadata.controls.showFloorplan ||
  11. fdkkmetadata.controls.showDollhouse)) ||
  12. toursList.length > 0 ||
  13. (customLink && customLink.isShow) ||
  14. (customTelephone && customTelephone.isShow) ||
  15. metadata.description ||
  16. isHasNormalBGM ||
  17. fdkkBGM
  18. "
  19. >
  20. <li
  21. class="daolan"
  22. :class="{ v3daolan: fdkkCurrentVersion == 'V3' }"
  23. @click.stop="playTour"
  24. v-if="toursList.length > 0"
  25. >
  26. <img
  27. :src="
  28. require(`@/assets/images/icon/${
  29. (fdkkCurrentVersion == 'V3' ? v3toursStatus : isPlayTours)
  30. ? 'pause01@2x'
  31. : 'playing01@2x'
  32. }.png`)
  33. "
  34. alt=""
  35. />
  36. <span>{{ $t("menu.tour") }}</span>
  37. <img
  38. @click.stop="openTours"
  39. :class="{ active: showTours }"
  40. class="jiantou"
  41. :src="require(`@/assets/images/icon/expand_arrows@2x.png`)"
  42. alt=""
  43. />
  44. <div class="vlink"></div>
  45. </li>
  46. <template
  47. v-if="
  48. fdkkCurrentVersion != 'V3' &&
  49. fdkkmetadata &&
  50. !fdkkmetadata.controls.showMap
  51. "
  52. >
  53. <li
  54. v-if="fdkkmetadata && fdkkmetadata.controls.showPanorama"
  55. :class="{ disabled: isPlayTours || flying }"
  56. @click="onModeChange('panorama')"
  57. >
  58. <img
  59. :src="
  60. require(`@/assets/images/icon/${
  61. mode == 'panorama' ? 'roaming_selected@2x' : 'roaming_normal@2x'
  62. }.png`)
  63. "
  64. alt=""
  65. />
  66. </li>
  67. <li
  68. v-if="fdkkmetadata && fdkkmetadata.controls.showFloorplan"
  69. :class="{ disabled: isPlayTours || flying }"
  70. @click="onModeChange('floorplan')"
  71. >
  72. <img
  73. :src="
  74. require(`@/assets/images/icon/${
  75. mode == 'floorplan' ? 'plane_selected@2x' : 'plane_normal@2x'
  76. }.png`)
  77. "
  78. alt=""
  79. />
  80. </li>
  81. <li
  82. v-if="fdkkmetadata && fdkkmetadata.controls.showDollhouse"
  83. :class="{ disabled: isPlayTours || flying }"
  84. @click="onModeChange('dollhouse')"
  85. >
  86. <img
  87. :src="
  88. require(`@/assets/images/icon/${
  89. mode == 'dollhouse' ? '3d_selected@2x' : '3d_normal@2x'
  90. }.png`)
  91. "
  92. alt=""
  93. />
  94. </li>
  95. <li
  96. class="vlink"
  97. v-if="
  98. (customLink && customLink.isShow) ||
  99. (customTelephone && customTelephone.isShow) ||
  100. metadata.description ||
  101. (((metadata.backgroundMusic && metadata.backgroundMusic.id) ||
  102. fdkkBGM) &&
  103. fdkkmetadata &&
  104. (fdkkmetadata.controls.showPanorama ||
  105. fdkkmetadata.controls.showFloorplan ||
  106. fdkkmetadata.controls.showDollhouse))
  107. "
  108. ></li>
  109. </template>
  110. <!-- 自定义链接 -->
  111. <li @click="onLink" v-if="customLink && customLink.isShow">
  112. <img :src="require(`@/assets/images/icon/link@2x.png`)" alt="" />
  113. </li>
  114. <!-- 联系电话 -->
  115. <li v-if="customTelephone && customTelephone.isShow">
  116. <a :href="`tel:${customTelephone.value}`">
  117. <img :src="require(`@/assets/images/icon/telephone@2x.png`)" alt="" />
  118. </a>
  119. </li>
  120. <!-- 简介 -->
  121. <li @click="onIntroduce" v-if="metadata.description">
  122. <img :src="require(`@/assets/images/icon/text@2x.png`)" alt="" />
  123. </li>
  124. <li @click="onIsBGM" v-if="isHasNormalBGM || isHasV4BGM || isHasV3BGM">
  125. <img
  126. v-if="isHasV3BGM"
  127. :src="
  128. require(`@/assets/images/icon/${
  129. isPlayV3BGM ? 'music@2x.png' : 'music_disabled@2x.png'
  130. }`)
  131. "
  132. alt=""
  133. />
  134. <img
  135. v-else
  136. :src="
  137. require(`@/assets/images/icon/${
  138. (isPlayNormalBGM || isPlayV4BGM) && isCurrentPlaying
  139. ? 'music@2x.png'
  140. : 'music_disabled@2x.png'
  141. }`)
  142. "
  143. alt=""
  144. />
  145. </li>
  146. </ul>
  147. <teleport to="body">
  148. <introduce v-if="showIntroduce" />
  149. <telephone v-if="showTelephone" />
  150. <clink v-if="showLink" />
  151. </teleport>
  152. </template>
  153. <script setup>
  154. import { computed, unref, ref } from "vue";
  155. import introduce from "./control/text";
  156. import telephone from "./control/telephone";
  157. import clink from "./control/link";
  158. import { useStore } from "vuex";
  159. const store = useStore();
  160. const toursList = computed(() => store.getters["fdkk/toursList"]);
  161. const isShowScenesList = computed(
  162. () => store.getters["functions/isShowScenesList"]
  163. );
  164. const toursStatus = computed(() => store.getters["fdkk/toursStatus"]);
  165. const v3toursStatus = computed(() => store.getters["fdkk/v3toursStatus"]);
  166. const isPlayTours = computed(() => store.getters["fdkk/isPlayTours"]);
  167. const flying = computed(() => store.getters["fdkk/isFlying"]);
  168. const mode = computed(() => store.getters["fdkk/mode"]);
  169. const showTours = computed(() => store.getters["fdkk/isShowToursList"]);
  170. // const currentScene = computed(() => store.getters["scene/currentScene"]);
  171. const metadata = computed(() => store.getters["scene/metadata"]);
  172. const fdkkmetadata = computed(() => store.getters["fdkk/metadata"]);
  173. const fdkkCurrentVersion = computed(
  174. () => store.getters["scene/fdkkCurrentVersion"]
  175. );
  176. const fdkkBGM = computed(() => store.getters["fdkk/fdkkBGM"]);
  177. // const v3IsBgm = computed(() => store.getters["fdkk/v3IsBgm"]);
  178. // const v3BGMStatus = computed(() => store.getters["fdkk/v3BGMStatus"]);
  179. const customTelephone = computed(() => store.getters["scene/customTelephone"]);
  180. const customLink = computed(() => store.getters["scene/customLink"]);
  181. const showIntroduce = computed(() => store.getters["functions/showIntroduce"]);
  182. const showTelephone = computed(() => store.getters["functions/showTelephone"]);
  183. const showLink = computed(() => store.getters["functions/showLink"]);
  184. //BMG音乐
  185. const isHasNormalBGM = computed(() => store.getters["audio/isHasNormalBGM"]);
  186. const isCurrentPlaying = computed(
  187. () => store.getters["audio/isCurrentPlaying"]
  188. );
  189. const isHasV3BGM = computed(() => store.getters["audio/isHasV3BGM"]);
  190. const isHasV4BGM = computed(() => store.getters["audio/isHasV4BGM"]);
  191. const isHasExplanationBGM = computed(
  192. () => store.getters["audio/isHasExplanationBGM"]
  193. );
  194. //BMG playing音乐
  195. const isPlayNormalBGM = computed(() => store.getters["audio/isPlayNormalBGM"]);
  196. const isPlayV3BGM = computed(() => store.getters["audio/isPlayV3BGM"]);
  197. const isPlayV4BGM = computed(() => store.getters["audio/isPlayV4BGM"]);
  198. const onIntroduce = () => {
  199. store.commit("functions/setShowIntroduce", true);
  200. };
  201. const onLink = () => {
  202. const { openMethod, value } = unref(customLink);
  203. if (openMethod == "_target") {
  204. window.open(value, "_blank");
  205. } else {
  206. store.commit("functions/setShowLink", true);
  207. }
  208. };
  209. const onIsBGM = () => {
  210. console.log("fdkk----onIsBGM", fdkkCurrentVersion.value);
  211. if (unref(isHasV3BGM)) {
  212. const v3playToggle = !unref(isPlayV3BGM);
  213. console.log("v3playToggle", v3playToggle);
  214. toggleV3BGM(v3playToggle);
  215. return;
  216. }
  217. if (unref(isHasV4BGM)) {
  218. if (!unref(isCurrentPlaying)) {
  219. store.dispatch("audio/playBGM", 2);
  220. } else {
  221. store.dispatch("audio/pauseBGM");
  222. }
  223. } else {
  224. if (!unref(isCurrentPlaying)) {
  225. store.dispatch("audio/playBGM", 0);
  226. } else {
  227. store.dispatch("audio/pauseBGM");
  228. }
  229. }
  230. };
  231. /**
  232. * 只有v3利用Iframe postMessage
  233. */
  234. const toggleV3BGM = (status) => {
  235. const target = document.querySelector("#showifr");
  236. if (target) {
  237. target.contentWindow.postMessage(
  238. {
  239. source: "mingyuan",
  240. event: "settings",
  241. params: {
  242. playMusic: status,
  243. },
  244. },
  245. "*"
  246. );
  247. }
  248. };
  249. window.toggleV3BGM = toggleV3BGM;
  250. const openTours = () => {
  251. if (isShowScenesList.value) {
  252. store.commit("functions/setShowScenesList", false);
  253. }
  254. store.commit("fdkk/setShowToursList", !showTours.value);
  255. };
  256. const playTour = () => {
  257. if (fdkkCurrentVersion.value == "V3") {
  258. store.commit("fdkk/setV3ToursStatus", !v3toursStatus.value);
  259. let ele = document.getElementById("showifr");
  260. ele &&
  261. ele.contentWindow.postMessage(
  262. {
  263. source: "mingyuan",
  264. event: v3toursStatus.value ? "guide-start" : "guide-pause",
  265. },
  266. "*"
  267. );
  268. return;
  269. }
  270. store.commit("fdkk/setToursStatus", !toursStatus.value);
  271. };
  272. const onIsShowList = (data) => {
  273. if (showTours.value) {
  274. store.commit("fdkk/setShowToursList", false);
  275. }
  276. store.commit("functions/setShowScenesList", !isShowScenesList.value);
  277. };
  278. const onModeChange = (name) => {
  279. document.querySelector("#fdkkifr") &&
  280. document.querySelector("#fdkkifr").contentWindow.postMessage(
  281. {
  282. source: "qjkankan",
  283. event: "setMode",
  284. params: {
  285. name: name,
  286. },
  287. },
  288. "*"
  289. );
  290. };
  291. </script>
  292. <style lang="scss" scoped>
  293. .control-fdkk {
  294. display: flex;
  295. align-items: center;
  296. height: 100%;
  297. &::-webkit-scrollbar {
  298. display: none;
  299. }
  300. > li {
  301. width: 26px;
  302. height: 26px;
  303. margin: 0 2px;
  304. cursor: pointer;
  305. white-space: nowrap;
  306. display: inline-block;
  307. flex-shrink: 0;
  308. img {
  309. width: 100%;
  310. height: 100%;
  311. }
  312. &:last-of-type {
  313. margin-right: 10px;
  314. &::after {
  315. width: 10px;
  316. height: 1px;
  317. background: none;
  318. content: "";
  319. display: inline-block;
  320. }
  321. }
  322. &:first-of-type {
  323. margin-left: 10px;
  324. }
  325. }
  326. .daolan {
  327. display: flex;
  328. width: auto;
  329. align-items: center;
  330. > img {
  331. width: 26px;
  332. height: 26px;
  333. }
  334. .jiantou {
  335. margin-left: -2px;
  336. transform: rotate(180deg);
  337. transition: 0.3s ease transform;
  338. &.active {
  339. transform: none;
  340. }
  341. }
  342. > span {
  343. font-size: 12px;
  344. margin-top: 2px;
  345. }
  346. }
  347. .v3daolan {
  348. > img {
  349. &:last-of-type {
  350. display: none;
  351. }
  352. }
  353. > span {
  354. margin-left: 0;
  355. }
  356. .vlink {
  357. margin-left: 10px;
  358. }
  359. }
  360. .vlink {
  361. width: 1px;
  362. height: 20px;
  363. background: linear-gradient(
  364. 180deg,
  365. rgba(255, 255, 255, 0) 0%,
  366. #ffffff 49%,
  367. rgba(255, 255, 255, 0) 100%
  368. );
  369. opacity: 0.5;
  370. }
  371. }
  372. </style>