fourth.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="fourth">
  3. <div class="main animate__animated">
  4. <img src="../../../assets/img/top4.png" />
  5. <label for="file" :class="{ camere: true, shakeSlow: dou === 2 }">
  6. <img src="../../../assets/img/camere.png" style="width: 100%" />
  7. </label>
  8. <img
  9. :class="{ doudong: dou === 1 }"
  10. src="../../../assets/img/bottom4.png"
  11. />
  12. </div>
  13. <input
  14. type="file"
  15. accept="image/*"
  16. style="display: none"
  17. id="file"
  18. capture="environment"
  19. @change="inputFile"
  20. />
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, defineEmits } from "vue";
  25. // import { onMounted, reactive } from "vue";
  26. import { isAndroid, isIphone } from "../../../utils/isTerminal";
  27. /**
  28. * window.$originData.orginParames.title 页面标题
  29. * window.$originData.orginParames.parameters 固定参数值
  30. * window.$originData.urlParames url参数
  31. */
  32. const emits = defineEmits(["changePage"]);
  33. const dou = ref(0);
  34. window.addEventListener(
  35. "devicemotion",
  36. event => {
  37. if (dou.value < 1) return;
  38. var acceleration = event.accelerationIncludingGravity;
  39. let px = Math.pow(acceleration.x, 2) >= 100;
  40. let py = Math.pow(acceleration.y, 2) >= 100;
  41. let pz = Math.pow(acceleration.z, 2) >= 100;
  42. console.log("----------------start------------");
  43. if (px || py || pz) {
  44. // 手机摇晃
  45. toNext();
  46. }
  47. },
  48. false
  49. );
  50. function toNext() {
  51. dou.value = 2;
  52. let t = setTimeout(() => {
  53. clearTimeout(t);
  54. emits("changePage", "five");
  55. }, 2000);
  56. }
  57. function inputFile() {
  58. dou.value = 1;
  59. if (isAndroid || isIphone) return;
  60. let t = setTimeout(() => {
  61. clearTimeout(t);
  62. toNext();
  63. }, 2000);
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .fourth {
  68. position: relative;
  69. .main {
  70. position: absolute;
  71. top: 50%;
  72. transform: translateY(-50%);
  73. img {
  74. width: 40%;
  75. margin: 0 auto;
  76. display: block;
  77. }
  78. .camere {
  79. display: block;
  80. width: 5em;
  81. margin: 4em auto;
  82. }
  83. }
  84. @keyframes shake-slow {
  85. 2% {
  86. transform: translate(6px, -2px) rotate(3.5deg);
  87. }
  88. 4% {
  89. transform: translate(5px, 8px) rotate(-0.5deg);
  90. }
  91. 6% {
  92. transform: translate(6px, -3px) rotate(-2.5deg);
  93. }
  94. 8% {
  95. transform: translate(4px, -2px) rotate(1.5deg);
  96. }
  97. 10% {
  98. transform: translate(-6px, 8px) rotate(-1.5deg);
  99. }
  100. 12% {
  101. transform: translate(-5px, 5px) rotate(1.5deg);
  102. }
  103. 14% {
  104. transform: translate(4px, 10px) rotate(3.5deg);
  105. }
  106. 16% {
  107. transform: translate(0px, 4px) rotate(1.5deg);
  108. }
  109. 18% {
  110. transform: translate(-1px, -6px) rotate(-0.5deg);
  111. }
  112. 20% {
  113. transform: translate(6px, -9px) rotate(2.5deg);
  114. }
  115. 22% {
  116. transform: translate(1px, -5px) rotate(-1.5deg);
  117. }
  118. 24% {
  119. transform: translate(-9px, 6px) rotate(-0.5deg);
  120. }
  121. 26% {
  122. transform: translate(8px, -2px) rotate(-1.5deg);
  123. }
  124. 28% {
  125. transform: translate(2px, -3px) rotate(-2.5deg);
  126. }
  127. 30% {
  128. transform: translate(9px, -7px) rotate(-0.5deg);
  129. }
  130. 32% {
  131. transform: translate(8px, -6px) rotate(-2.5deg);
  132. }
  133. 34% {
  134. transform: translate(-5px, 1px) rotate(3.5deg);
  135. }
  136. 36% {
  137. transform: translate(0px, -5px) rotate(2.5deg);
  138. }
  139. 38% {
  140. transform: translate(2px, 7px) rotate(-1.5deg);
  141. }
  142. 40% {
  143. transform: translate(6px, 3px) rotate(-1.5deg);
  144. }
  145. 42% {
  146. transform: translate(1px, -5px) rotate(-1.5deg);
  147. }
  148. 44% {
  149. transform: translate(10px, -4px) rotate(-0.5deg);
  150. }
  151. 46% {
  152. transform: translate(-2px, 2px) rotate(3.5deg);
  153. }
  154. 48% {
  155. transform: translate(3px, 4px) rotate(-0.5deg);
  156. }
  157. 50% {
  158. transform: translate(8px, 1px) rotate(-1.5deg);
  159. }
  160. 52% {
  161. transform: translate(7px, 4px) rotate(-1.5deg);
  162. }
  163. 54% {
  164. transform: translate(10px, 8px) rotate(-1.5deg);
  165. }
  166. 56% {
  167. transform: translate(-3px, 0px) rotate(-0.5deg);
  168. }
  169. 58% {
  170. transform: translate(0px, -1px) rotate(1.5deg);
  171. }
  172. 60% {
  173. transform: translate(6px, 9px) rotate(-1.5deg);
  174. }
  175. 62% {
  176. transform: translate(-9px, 8px) rotate(0.5deg);
  177. }
  178. 64% {
  179. transform: translate(-6px, 10px) rotate(0.5deg);
  180. }
  181. 66% {
  182. transform: translate(7px, 0px) rotate(0.5deg);
  183. }
  184. 68% {
  185. transform: translate(3px, 8px) rotate(-0.5deg);
  186. }
  187. 70% {
  188. transform: translate(-2px, -9px) rotate(1.5deg);
  189. }
  190. 72% {
  191. transform: translate(-6px, 2px) rotate(1.5deg);
  192. }
  193. 74% {
  194. transform: translate(-2px, 10px) rotate(-1.5deg);
  195. }
  196. 76% {
  197. transform: translate(2px, 8px) rotate(2.5deg);
  198. }
  199. 78% {
  200. transform: translate(6px, -2px) rotate(-0.5deg);
  201. }
  202. 80% {
  203. transform: translate(6px, 8px) rotate(0.5deg);
  204. }
  205. 82% {
  206. transform: translate(10px, 9px) rotate(3.5deg);
  207. }
  208. 84% {
  209. transform: translate(-3px, -1px) rotate(3.5deg);
  210. }
  211. 86% {
  212. transform: translate(1px, 8px) rotate(-2.5deg);
  213. }
  214. 88% {
  215. transform: translate(-5px, -9px) rotate(2.5deg);
  216. }
  217. 90% {
  218. transform: translate(2px, 8px) rotate(0.5deg);
  219. }
  220. 92% {
  221. transform: translate(0px, -1px) rotate(1.5deg);
  222. }
  223. 94% {
  224. transform: translate(-8px, -1px) rotate(0.5deg);
  225. }
  226. 96% {
  227. transform: translate(-3px, 8px) rotate(-1.5deg);
  228. }
  229. 98% {
  230. transform: translate(4px, 8px) rotate(0.5deg);
  231. }
  232. 0%,
  233. 100% {
  234. transform: translate(0, 0) rotate(0);
  235. }
  236. }
  237. @keyframes buzz-out {
  238. 0% {
  239. transform: translateX(3px) rotate(2deg);
  240. }
  241. 10% {
  242. transform: translateX(-3px) rotate(-2deg);
  243. }
  244. 20% {
  245. transform: translateX(3px) rotate(2deg);
  246. }
  247. 30% {
  248. transform: translateX(-3px) rotate(-2deg);
  249. }
  250. 40% {
  251. transform: translateX(3px) rotate(2deg);
  252. }
  253. 50% {
  254. transform: translateX(-3px) rotate(-2deg);
  255. }
  256. 60% {
  257. transform: translateX(3px) rotate(2deg);
  258. }
  259. 70% {
  260. transform: translateX(-3px) rotate(-2deg);
  261. }
  262. 80% {
  263. transform: translateX(3px) rotate(2deg);
  264. }
  265. 90% {
  266. transform: translateX(-3px) rotate(-2deg);
  267. }
  268. 100% {
  269. transform: translateX(3px) rotate(2deg);
  270. }
  271. }
  272. .doudong {
  273. animation: buzz-out 2s 1 ease-in-out;
  274. }
  275. .shakeSlow {
  276. animation: shake-slow 2s 1 ease-in-out;
  277. }
  278. }
  279. </style>