liyongli 2 anos atrás
pai
commit
b8e4c2f527

+ 7 - 2
src/view/SilkRoadSpringFestivalGala/index.vue

@@ -64,7 +64,7 @@
         <five v-if="page === 'five'" @changePage="changePage" />
       </transition>
       <transition name="fade">
-        <six v-if="page === 'six' || page === 'seven'" />
+        <six v-if="page === 'six' || page === 'seven'" @autoAudio="autoAudio" />
       </transition>
     </div>
   </div>
@@ -108,7 +108,12 @@ function tosecond() {
     const v = video[i];
     !v.playing && v.play();
   }
-  !audio.playing && audio.play();
+  autoAudio();
+}
+
+function autoAudio() {
+    if(!audio) return;
+    !audio.playing ? audio.play() : audio.pause();
 }
 
 function changePage(type) {

+ 4 - 1
src/view/SilkRoadSpringFestivalGala/pages/six.vue

@@ -187,7 +187,7 @@
   </div>
 </template>
 <script setup>
-import { ref, reactive, nextTick } from "vue";
+import { ref, reactive, nextTick, defineEmits } from "vue";
 import {
   getStore,
   getSendVerifyCode,
@@ -236,6 +236,7 @@ const text = reactive({
   ...data[type - 1],
   width,
 });
+const emits = defineEmits(["autoAudio"]);
 const isCode = ref(0); // 验证码
 const bgimg = ref(url.bg);
 const kuangimg = ref(url.kuang);
@@ -346,6 +347,7 @@ let current = 0;
 
 function showVideo(url) {
   showOverlay.value = true;
+  emits("autoAudio");
   nextTick(() => {
     let ele = document.querySelector(".sevenvideo");
     ele.src = url;
@@ -384,6 +386,7 @@ function closeSeven() {
     });
   let ele = document.querySelector(".sevenvideo");
   ele.pause();
+  emits("autoAudio");
   showOverlay.value = false;
 }