menu.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="rmenu">
  3. <ul v-if="menuType == 'func' && isShowfunc">
  4. <li :class="{ rmactive: isBgm && item.id == 'music' }" v-for="(item, i) in menu" :key="i">
  5. <img @click="onClick(item)" :title="item.name" :src="require(`@/assets/images/proj2022/mobile/menu/${item.img}.png`)" alt="" />
  6. </li>
  7. </ul>
  8. <div class="control">
  9. <img @click.stop="onClickNavigate('up')" :src="require(`@/assets/images/proj2022/mobile/up@2x.png`)" alt="" />
  10. <img @click.stop="onClickNavigate('down')" :src="require(`@/assets/images/proj2022/mobile/down@2x.png`)" alt="" />
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import { Booth } from "@/data/booth.js";
  16. import { g_findCloseNum } from "@/utils/index.js";
  17. let findNextItem = (arr, currentItem) => {
  18. let idx = arr.findIndex((item) => item == currentItem);
  19. if (idx == arr.length - 1) {
  20. idx = 0;
  21. } else {
  22. idx += 1;
  23. }
  24. return arr[idx];
  25. };
  26. let findPrevItem = (arr, currentItem) => {
  27. let idx = arr.findIndex((item) => item == currentItem);
  28. if (idx == 0) {
  29. idx = arr.length - 1;
  30. } else {
  31. idx -= 1;
  32. }
  33. return arr[idx];
  34. };
  35. export default {
  36. props: ["tourStatus", "menuType", 'isShowfunc', "currentPanoid"],
  37. computed: {
  38. nextZhanXiang() {
  39. let zhanqu = Booth.find((item) => item.id === this.theme);
  40. let panoArr = zhanqu.company.map((item) => item.panoId);
  41. let currentIdx = panoArr.indexOf(this.currentPanoid);
  42. let nextPanoItem = "";
  43. if (currentIdx > -1) {
  44. if (currentIdx == panoArr.length - 1) {
  45. zhanqu = findNextItem(Booth, zhanqu);
  46. nextPanoItem = zhanqu.company[0];
  47. } else {
  48. currentIdx += 1;
  49. nextPanoItem = zhanqu.company[currentIdx];
  50. }
  51. } else {
  52. let ttt = g_findCloseNum(
  53. zhanqu.company.map((item) => item.panoId),
  54. this.currentPanoid
  55. );
  56. nextPanoItem = zhanqu.company.find((item) => item.panoId == ttt);
  57. }
  58. return nextPanoItem;
  59. },
  60. prevZhanXiang() {
  61. let zhanqu = Booth.find((item) => item.id === this.theme);
  62. let panoArr = zhanqu.company.map((item) => item.panoId);
  63. let currentIdx = panoArr.indexOf(this.currentPanoid);
  64. let prevPanoItem = "";
  65. if (currentIdx > -1) {
  66. if (currentIdx == 0) {
  67. zhanqu = findPrevItem(Booth, zhanqu);
  68. prevPanoItem = zhanqu.company[0];
  69. } else {
  70. currentIdx -= 1;
  71. prevPanoItem = zhanqu.company[currentIdx];
  72. }
  73. } else {
  74. let ttt = g_findCloseNum(
  75. zhanqu.company.map((item) => item.panoId),
  76. this.currentPanoid
  77. );
  78. prevPanoItem = zhanqu.company.find((item) => item.panoId == ttt);
  79. }
  80. return prevPanoItem;
  81. },
  82. },
  83. data() {
  84. let bgmAudio = new Audio();
  85. bgmAudio.src = require(`@/assets/audio/bgm.mp3`);
  86. bgmAudio.loop = true;
  87. return {
  88. current: "play",
  89. bgmAudio,
  90. isBgm: false,
  91. menu: [
  92. {
  93. id: "daka",
  94. name: "打卡",
  95. img: "record",
  96. cp: "daka",
  97. },
  98. {
  99. id: "content",
  100. name: "评论",
  101. img: "message",
  102. cp: "vcontent",
  103. },
  104. {
  105. id: "zan",
  106. img: "like",
  107. name: "点赞",
  108. },
  109. {
  110. id: "qrcode",
  111. name: "分享",
  112. img: "share",
  113. cp: "qrcode",
  114. },
  115. ],
  116. };
  117. },
  118. watch: {
  119. isBgm: {
  120. immediate: true,
  121. handler: function(newVal) {
  122. !newVal ? this.bgmAudio.pause() : this.bgmAudio.play();
  123. },
  124. },
  125. tourStatus(newVal) {
  126. if (newVal) {
  127. this.isBgm = false;
  128. } else {
  129. let status = localStorage.getItem("g_bgmstatus");
  130. if (status === "open") {
  131. this.isBgm = true;
  132. }
  133. }
  134. },
  135. },
  136. mounted() {
  137. this.isBgm = true;
  138. localStorage.setItem("g_bgmstatus", this.isBgm ? "open" : "close");
  139. this.$nextTick(() => {
  140. setTimeout(() => {
  141. if (this.bgmAudio.paused) {
  142. this.isBgm = false;
  143. localStorage.setItem("g_bgmstatus", this.isBgm ? "open" : "close");
  144. }
  145. this.$bus.$on("toggleBGM", (data) => {
  146. if (!data) {
  147. this.isBgm = data;
  148. } else {
  149. let status = localStorage.getItem("g_bgmstatus");
  150. if (status === "open") {
  151. this.isBgm = data;
  152. }
  153. }
  154. });
  155. });
  156. });
  157. },
  158. methods: {
  159. onClickNavigate(type) {
  160. if (type == "up") {
  161. this.$bus.$emit("ifrMessage", {
  162. events: "flyToPano",
  163. data: this.nextZhanXiang,
  164. });
  165. } else {
  166. this.$bus.$emit("ifrMessage", {
  167. events: "flyToPano",
  168. data: this.prevZhanXiang,
  169. });
  170. }
  171. },
  172. onClick(item) {
  173. item.path && this.$router.push(item.path);
  174. item.cp && this.$bus.$emit("opencp", item.cp);
  175. },
  176. },
  177. };
  178. </script>
  179. <style lang="less" scoped>
  180. .rmenu {
  181. position: fixed;
  182. right: 20px;
  183. bottom: 130px;
  184. width: 45px;
  185. > ul {
  186. width: 100%;
  187. border-radius: 31px;
  188. background-color: rgba(0, 0, 0, 0.6);
  189. padding: 2px 0;
  190. backdrop-filter: blur(12px) brightness(100%);
  191. > li {
  192. text-align: center;
  193. width: 100%;
  194. margin: 10px auto;
  195. > img {
  196. width: 80%;
  197. cursor: pointer;
  198. }
  199. }
  200. }
  201. .control {
  202. display: flex;
  203. flex-direction: column;
  204. width: 100%;
  205. margin-top: 20px;
  206. > img {
  207. width: 100%;
  208. margin: 5px 0;
  209. }
  210. }
  211. }
  212. </style>