main-shop.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="panel" :class="{ show }">
  3. <span class="icon" @click="playing ? pause() : play()" v-if="existsGuide">
  4. <Icon type="play" />
  5. </span>
  6. <span class="icon" @click="showScenes = !showScenes">
  7. <Icon type="scene" />
  8. </span>
  9. <span class="ctrl" :class="{ show }" @click="show = !show">
  10. <Icon type="arrows@2x" />
  11. </span>
  12. </div>
  13. <SceneList
  14. v-if="showScenes"
  15. @close="showScenes = false"
  16. @changeScene="changeScene"
  17. />
  18. </template>
  19. <script setup lang="ts">
  20. import SceneList from "./scene-list.vue";
  21. //import { useMusicPlayer } from "@/utils/sound";
  22. import { changeScene } from "@/store/room";
  23. import Icon from "@/components/icon/index.vue";
  24. import { ref, onUnmounted } from "vue";
  25. import { getApp } from "@/app";
  26. const show = ref(false);
  27. const app = getApp();
  28. const playing = ref(false);
  29. const existsGuide = ref(false);
  30. const showScenes = ref(false);
  31. app.use("TourPlayer").then((player) => {
  32. console.log("===>", player);
  33. player.on("play", ({ partId, frameId }) => (playing.value = true));
  34. player.on("pause", ({ partId, frameId }) => (playing.value = false));
  35. player.on("end", () => {
  36. playing.value = false;
  37. });
  38. });
  39. // 需要双向绑定时,重新设置数据
  40. app.TourManager.on("loaded", (tours) => {
  41. existsGuide.value = !!tours.length;
  42. });
  43. const play = async () => {
  44. const player = await app.TourManager.player;
  45. player.play();
  46. };
  47. const pause = async () => {
  48. const player = await app.TourManager.player;
  49. player.pause();
  50. };
  51. // const timeout = setTimeout(() => {
  52. // const a = useMusicPlayer()
  53. // }, 2000)
  54. // onUnmounted(() => clearTimeout(timeout))
  55. </script>
  56. <style lang="scss" scoped>
  57. .panel {
  58. position: fixed;
  59. top: calc(100% - 90px);
  60. left: 0;
  61. z-index: 22;
  62. height: 44px;
  63. background: rgba(0, 0, 0, 0.5);
  64. border-radius: 0px 24px 24px 0px;
  65. border: 1px solid rgba(255, 255, 255, 0.1);
  66. padding-right: 30px;
  67. display: flex;
  68. align-items: center;
  69. justify-content: space-evenly;
  70. // width: 110px;
  71. transform: translateX(calc(-100% + 30px));
  72. &.show {
  73. transform: translateX(0);
  74. }
  75. > .icon {
  76. margin: 0 10px;
  77. }
  78. }
  79. .icon {
  80. font-size: 24px;
  81. height: 1em;
  82. color: #fff;
  83. &.active {
  84. color: #ed5d18;
  85. }
  86. }
  87. .ctrl {
  88. position: absolute;
  89. right: 10px;
  90. top: 50%;
  91. transform: translateY(-50%) rotateZ(180deg);
  92. font-size: 12px;
  93. &.show {
  94. transform: translateY(-50%);
  95. }
  96. }
  97. </style>