control.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <ul class="control" v-show="fdkkCurrentVersion == 'V4'">
  3. <!-- 自定义链接 -->
  4. <li
  5. @click="onLink"
  6. v-tooltip="customLink.name"
  7. v-if="customLink && customLink.isShow"
  8. >
  9. <img :src="require(`@/assets/images/icon/link@2x.png`)" alt="" />
  10. </li>
  11. <!-- 联系电话 -->
  12. <li
  13. @click="onTelephone"
  14. v-tooltip="customTelephone.name"
  15. v-if="customTelephone && customTelephone.isShow"
  16. >
  17. <img :src="require(`@/assets/images/icon/telephone@2x.png`)" alt="" />
  18. </li>
  19. <!-- 简介 -->
  20. <li
  21. @click="onIntroduce"
  22. v-tooltip="$t('menu.introduce')"
  23. v-if="metadata.description"
  24. >
  25. <img :src="require(`@/assets/images/icon/text@2x.png`)" alt="" />
  26. </li>
  27. <!-- 背景音乐 -->
  28. <li
  29. @click="onIsBGM"
  30. v-tooltip="$t('menu.music')"
  31. v-if="isHasNormalBGM || isHasV4BGM"
  32. >
  33. <img
  34. :src="
  35. require(`@/assets/images/icon/${
  36. (isPlayNormalBGM || isPlayV4BGM) && isCurrentPlaying
  37. ? 'music@2x.png'
  38. : 'music_disabled@2x.png'
  39. }`)
  40. "
  41. alt=""
  42. />
  43. </li>
  44. <!-- 解说音频 -->
  45. <li
  46. @click="onIsCommentary"
  47. v-tooltip="$t('menu.commentary')"
  48. v-if="isHasExplanationBGM"
  49. >
  50. <img
  51. :src="
  52. require(`@/assets/images/icon/${
  53. isPlayExplanationBGM && isCurrentPlaying
  54. ? 'commentary@2x.png'
  55. : 'commentary_disabled@2x.png'
  56. }`)
  57. "
  58. alt=""
  59. />
  60. </li>
  61. <li
  62. @click="onIsAutoRotate"
  63. v-tooltip="$t('menu.autoRotate')"
  64. v-if="currentScene.type != '4dkk'"
  65. >
  66. <img
  67. :src="
  68. require(`@/assets/images/icon/${
  69. isAutoRotate ? 'rotation@2x.png' : 'rotation_disabled@2x.png'
  70. }`)
  71. "
  72. alt=""
  73. />
  74. </li>
  75. <li @click="onVR" v-tooltip="'VR'" v-if="currentScene.type != '4dkk'">
  76. <img :src="require(`@/assets/images/icon/vr@2x.png`)" alt="" />
  77. </li>
  78. <li @click="onShare" v-tooltip="$t('menu.share')">
  79. <img :src="require(`@/assets/images/icon/share@2x.png`)" alt="" />
  80. </li>
  81. <li @click="onFullScreen" v-tooltip="$t('menu.fullScreen')">
  82. <img
  83. :src="require(`@/assets/images/icon/${'fullscreen@2x.png'}`)"
  84. alt=""
  85. />
  86. </li>
  87. </ul>
  88. <teleport to="body">
  89. <introduce v-if="showIntroduce" />
  90. <telephone v-if="showTelephone" />
  91. <clink v-if="showLink" />
  92. </teleport>
  93. </template>
  94. <script setup>
  95. import {
  96. ref,
  97. watch,
  98. computed,
  99. onMounted,
  100. watchEffect,
  101. nextTick,
  102. unref,
  103. } from "vue";
  104. import { useStore } from "vuex";
  105. import { useApp } from "@/app";
  106. import introduce from "./control/text";
  107. import telephone from "./control/telephone";
  108. import clink from "./control/link";
  109. const store = useStore();
  110. //BMG音乐
  111. const isHasNormalBGM = computed(() => store.getters["audio/isHasNormalBGM"]);
  112. const isCurrentPlaying = computed(
  113. () => store.getters["audio/isCurrentPlaying"]
  114. );
  115. const isHasV4BGM = computed(() => store.getters["audio/isHasV4BGM"]);
  116. const isHasExplanationBGM = computed(
  117. () => store.getters["audio/isHasExplanationBGM"]
  118. );
  119. //BMG playing音乐
  120. const isPlayNormalBGM = computed(() => store.getters["audio/isPlayNormalBGM"]);
  121. const isPlayV4BGM = computed(() => store.getters["audio/isPlayV4BGM"]);
  122. const isPlayExplanationBGM = computed(
  123. () => store.getters["audio/isPlayExplanationBGM"]
  124. );
  125. const metadata = computed(() => store.getters["scene/metadata"]);
  126. const isDoneforCover = computed(() => store.getters["scene/isDoneforCover"]);
  127. const isShowCover = computed(
  128. () => metadata.value.coverInfo?.isShowCover || false
  129. );
  130. const fdkkCurrentVersion = computed(
  131. () => store.getters["scene/fdkkCurrentVersion"]
  132. );
  133. const isAutoRotate = computed(() => store.getters["functions/isAutoRotate"]);
  134. // const showMusicPlaying = ref(false);
  135. // const showCommentaryPlaying = ref(false);
  136. // const isCommentary = computed(() => store.getters["functions/isCommentary"]);
  137. const currentScene = computed(() => store.getters["scene/currentScene"]);
  138. const customTelephone = computed(() => store.getters["scene/customTelephone"]);
  139. const customLink = computed(() => store.getters["scene/customLink"]);
  140. // const fdkkmetadata = computed(() => store.getters["fdkk/metadata"]);
  141. const fdkkBGM = computed(() => store.getters["fdkk/fdkkBGM"]);
  142. const showIntroduce = computed(() => store.getters["functions/showIntroduce"]);
  143. const showTelephone = computed(() => store.getters["functions/showTelephone"]);
  144. const showLink = computed(() => store.getters["functions/showLink"]);
  145. const isFullscreen = ref(false);
  146. const onIntroduce = () => {
  147. store.commit("functions/setShowIntroduce", true);
  148. };
  149. const onTelephone = () => {
  150. store.commit("functions/setShowTelephone", true);
  151. };
  152. const onLink = () => {
  153. const { openMethod, value } = unref(customLink);
  154. if (openMethod == "_target") {
  155. window.open(value, "_blank");
  156. } else {
  157. store.commit("functions/setShowLink", true);
  158. }
  159. };
  160. const onIsBGM = () => {
  161. if (unref(isHasV4BGM)) {
  162. if (!unref(isCurrentPlaying)) {
  163. store.dispatch("audio/playBGM", 2);
  164. } else {
  165. store.dispatch("audio/pauseBGM", 0);
  166. }
  167. } else {
  168. if (!unref(isPlayNormalBGM)) {
  169. console.log("从其他切过来");
  170. store.dispatch("audio/playBGM", 0);
  171. } else {
  172. if (!unref(isCurrentPlaying)) {
  173. store.dispatch("audio/playBGM", 0);
  174. } else {
  175. store.dispatch("audio/pauseBGM", 0);
  176. }
  177. }
  178. }
  179. };
  180. const onIsAutoRotate = (data) => {
  181. store.commit("functions/setAutoRotate", !isAutoRotate.value);
  182. };
  183. const onIsCommentary = () => {
  184. if (!unref(isPlayExplanationBGM)) {
  185. console.log("从其他切过来");
  186. store.dispatch("audio/playBGM", 3);
  187. } else {
  188. if (unref(isCurrentPlaying)) {
  189. store.dispatch("audio/pauseBGM");
  190. } else {
  191. store.dispatch("audio/playBGM", 3);
  192. }
  193. }
  194. };
  195. const onFullScreen = () => {
  196. let element = document.documentElement;
  197. if (isFullscreen.value) {
  198. if (document.exitFullscreen) {
  199. document.exitFullscreen();
  200. } else if (document.webkitCancelFullScreen) {
  201. document.webkitCancelFullScreen();
  202. } else if (document.mozCancelFullScreen) {
  203. document.mozCancelFullScreen();
  204. } else if (document.msExitFullscreen) {
  205. document.msExitFullscreen();
  206. }
  207. } else {
  208. if (element.requestFullscreen) {
  209. element.requestFullscreen();
  210. } else if (element.webkitRequestFullScreen) {
  211. element.webkitRequestFullScreen();
  212. } else if (element.mozRequestFullScreen) {
  213. element.mozRequestFullScreen();
  214. } else if (element.msRequestFullscreen) {
  215. element.msRequestFullscreen();
  216. }
  217. }
  218. // 改变当前全屏状态
  219. //this.isFullscreen = !this.isFullscreen;
  220. };
  221. const onVR = (data) => {
  222. useApp().then((app) => {
  223. app.krpanoDom.call("webvr.enterVR()");
  224. });
  225. };
  226. const onShare = () => {
  227. store.commit("functions/setShareUrl", true);
  228. };
  229. // const staticList = ref([
  230. // {
  231. // id: "cruise",
  232. // name: "巡游开关",
  233. // icon: "rotation@2x.png",
  234. // icondisabled: "rotation_disabled@2x.png",
  235. // },
  236. // {
  237. // id: "vr",
  238. // name: "VR",
  239. // icon: "vr@2x.png",
  240. // },
  241. // {
  242. // id: "share",
  243. // name: "分享",
  244. // icon: "share@2x.png",
  245. // },
  246. // {
  247. // id: "full",
  248. // name: "全屏",
  249. // icon: "fullscreen@2x.png",
  250. // icondisabled: "rotation_disabled@2x.png",
  251. // },
  252. // ]);
  253. onMounted(() => {
  254. let events = [
  255. "fullscreenchange",
  256. "webkitfullscreenchange",
  257. "mozfullscreenchange",
  258. "MSFullscreenChange",
  259. ];
  260. events.forEach((item, index) => {
  261. window.addEventListener(item, () => {
  262. isFullscreen.value = !isFullscreen.value;
  263. });
  264. });
  265. });
  266. // watch(
  267. // () => [showCommentaryPlaying.value, showMusicPlaying.value],
  268. // () => {
  269. // if (!showCommentaryPlaying.value && !showMusicPlaying.value) {
  270. // store.commit("functions/setCurrentPlaying", "");
  271. // } else {
  272. // if (showCommentaryPlaying.value) {
  273. // store.commit("functions/setCurrentPlaying", "commentary");
  274. // } else if (showMusicPlaying.value) {
  275. // store.commit("functions/setCurrentPlaying", "bgm");
  276. // }
  277. // }
  278. // }
  279. // );
  280. // musicPlayer.on("play", () => {
  281. // soundPlayer.pause();
  282. // showMusicPlaying.value = true;
  283. // });
  284. // musicPlayer.on("pause", () => {
  285. // showMusicPlaying.value = false;
  286. // });
  287. // soundPlayer.on("play", () => {
  288. // musicPlayer.pause();
  289. // showCommentaryPlaying.value = true;
  290. // //设置当前播放中音乐来源
  291. // if (!musicPlayer.pauseFromOther) {
  292. // musicPlayer.pauseFromOther = true;
  293. // }
  294. // });
  295. // soundPlayer.on("pause", () => {
  296. // console.log(11111);
  297. // showCommentaryPlaying.value = false;
  298. // });
  299. </script>
  300. <style lang="scss" scoped>
  301. .control {
  302. position: absolute;
  303. right: 20px;
  304. bottom: 8px;
  305. display: flex;
  306. z-index: 9;
  307. > li {
  308. width: 26px;
  309. height: 26px;
  310. margin: 0 10px;
  311. cursor: pointer;
  312. > img {
  313. width: 100%;
  314. height: 100%;
  315. }
  316. }
  317. }
  318. </style>