tremble 3 년 전
부모
커밋
031c0cac99
4개의 변경된 파일60개의 추가작업 그리고 27개의 파일을 삭제
  1. 4 4
      src/clients/index.vue
  2. 34 2
      src/clients/mobile.vue
  3. 14 18
      src/pages/mobilescene/menu.vue
  4. 8 3
      src/pages/scene/menu.vue

+ 4 - 4
src/clients/index.vue

@@ -86,14 +86,14 @@ export default {
   },
   mounted() {
     if (this.isMobile) {
-      if (window.location.href.indexOf("test.html") > -1) {
+      if (window.location.href.indexOf("index.html") > -1) {
         window.location.href = window.location.href.replace(
-          "test.html",
-          "mbtest.html"
+          "index.html",
+          "mobile.html"
         );
       } else {
         window.location.href =
-          window.location.origin + window.location.pathname + "mbtest.html";
+          window.location.origin + window.location.pathname + "mobile.html";
       }
     }
 

+ 34 - 2
src/clients/mobile.vue

@@ -1,6 +1,12 @@
 <template>
   <div class="bbbb">
     <router-view />
+    <audio
+      ref="vgbgm"
+      class="noshow"
+      loop
+      :src="require(`@/assets/audio/bgm.mp3`)"
+    ></audio>
     <div class="orientation-tip">
       <div>
         <img :src="require('@/assets/images/project/landtip.png')" alt="" />
@@ -92,14 +98,32 @@ export default {
       }
     },
   },
+  watch:{
+    '$route.name':function (newVal) {
+      newVal !='scene' ? this.$refs.vgbgm.pause() : this.$refs.vgbgm.play();
+    }
+  },
   mounted() {
+  
+
     if (!this.isMobile) {
       window.location.href = window.location.href.replace(
-        "mbtest.html",
-        "test.html"
+        "mobile.html",
+        "index.html"
       );
     }
 
+    this.$nextTick(()=>{
+      document.addEventListener('WeixinJSBridgeReady', ()=>{
+        this.$refs.vgbgm.load()
+      }, false);
+
+      this.$bus.$on('toggleHomeBgm',newVal=>{
+        !newVal ? this.$refs.vgbgm.pause() : this.$refs.vgbgm.play();
+      })
+    })
+
+
     $(document)
       .off("click touchstart")
       .on("click touchstart", () => {
@@ -124,6 +148,14 @@ body,
   color: #fff;
 }
 
+.noshow {
+  position: fixed;
+  top: -100px;
+  left: -100px;
+  opacity: 0;
+  visibility: hidden;
+}
+
 /*横屏体验*/
 .orientation-tip {
   width: 100%;

+ 14 - 18
src/pages/mobilescene/menu.vue

@@ -1,12 +1,5 @@
 <template>
   <div class="smenu">
-    <audio
-      ref="vbgm"
-      class="noshow"
-      loop
-      :src="require(`@/assets/audio/bgm.mp3`)"
-    ></audio>
-  
     <template v-if="!tourStatus">
       <div class="sdaolan brightness">
         <div @click="toggle" class="daolan ">
@@ -101,12 +94,21 @@ export default {
     };
   },
   watch: {
-    isBgm(newVal) {
-      !newVal ? this.$refs.vbgm.pause() : this.$refs.vbgm.play();
+    isBgm:{
+      immediate:true,
+      handler:function(newVal){
+        this.$bus.$emit('toggleHomeBgm',newVal)
+        // !newVal ? this.$refs.vbgm.pause() : this.$refs.vbgm.play();
+      }
     },
     tourStatus(newVal){
       if (newVal) {
-        this.isBgm = false
+          this.isBgm = false;
+      } else{
+        let status = localStorage.getItem('g_bgmstatus')
+        if (status==='open') {
+          this.isBgm = true;
+        }
       }
     }
   },
@@ -143,12 +145,7 @@ export default {
       this.isBgm = true;
       localStorage.setItem('g_bgmstatus',this.isBgm?'open':'close')
       this.$nextTick(()=>{
-        setTimeout(() => {
-          if (this.$refs.vbgm.paused) {
-            this.isBgm = false
-            localStorage.setItem('g_bgmstatus',this.isBgm?'open':'close')
-          }
-          this.$bus.$on("toggleBGM", (data) => {
+        this.$bus.$on("toggleBGM", (data) => {
             if (!data) {
                 this.isBgm = data;
             } else{
@@ -157,8 +154,7 @@ export default {
                 this.isBgm = data;
               }
             }
-          });
-        });
+          })
       })
   },
 };

+ 8 - 3
src/pages/scene/menu.vue

@@ -128,11 +128,16 @@ export default {
         !newVal ? this.$refs.vbgm.pause() : this.$refs.vbgm.play();
       }
     },
-    tourStatus(newVal) {
+    tourStatus(newVal){
       if (newVal) {
-        this.isBgm = false;
+          this.isBgm = false;
+      } else{
+        let status = localStorage.getItem('g_bgmstatus')
+        if (status==='open') {
+          this.isBgm = true;
+        }
       }
-    },
+    }
   },
   methods: {
     onClick(item) {