liyongli 2 years ago
parent
commit
14a399f02a

+ 4 - 3
src/view/SilkRoadSpringFestivalGala/index.vue

@@ -99,6 +99,7 @@ const audio = new Audio();
 audio.src = audioFile;
 audio.loop = true;
 
+
 function tosecond() {
   changePage("second");
   const video = document.querySelectorAll("video");
@@ -206,9 +207,9 @@ function changePage(type) {
       height: 100vh;
       top: 0;
     }
-    .firstvideo{
-        width: 200vw;
-        height: 100vh;
+    .firstvideo {
+      width: 200vw;
+      height: 100vh;
     }
 
     .fade-enter-from,

+ 26 - 16
src/view/SilkRoadSpringFestivalGala/pages/fourth.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="fourth">
-    
     <div class="main animate__animated">
       <img src="../../../assets/img/top4.png" />
       <label for="file" :class="{ camere: true, shakeSlow: dou === 2 }">
@@ -32,28 +31,39 @@ import { ref, defineEmits } from "vue";
  * window.$originData.urlParames url参数
  */
 const emits = defineEmits(["changePage"]);
+
+const dou = ref(0);
+
 window.addEventListener(
   "devicemotion",
-  function (e) {
-    const event = e || {};
-    const acceleration = event.accelerationIncludingGravity;
-    console.log(acceleration);
+  event => {
+    var acceleration = event.accelerationIncludingGravity;
+    let px = Math.pow(acceleration.x, 2) >= 100;
+    let py = Math.pow(acceleration.y, 2) >= 100;
+    let pz = Math.pow(acceleration.z, 2) >= 100;
+    console.log("----------------start------------");
+    if (px || py || pz) {
+      // 手机摇晃
+      dou.value = 2;
+      let t = setTimeout(() => {
+        clearTimeout(t);
+        emits("changePage", "five");
+      }, 2000);
+    }
   },
-  true
+  false
 );
 
-const dou = ref(0);
-
 function inputFile() {
   dou.value = 1;
-  let t = setTimeout(() => {
-    clearTimeout(t);
-    dou.value = 2;
-    t = setTimeout(() => {
-      clearTimeout(t);
-      emits("changePage", "five");
-    }, 2000);
-  }, 2000);
+  //   let t = setTimeout(() => {
+  //     clearTimeout(t);
+  //     dou.value = 2;
+  //     t = setTimeout(() => {
+  //       clearTimeout(t);
+  //       emits("changePage", "five");
+  //     }, 2000);
+  //   }, 2000);
 }
 </script>
 <style lang="scss" scoped>