index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="login-box">
  3. <view class="video-background">
  4. <video
  5. src="@/static/video/login_bg.mp4"
  6. object-fit="cover"
  7. :autoplay="true"
  8. :controls="false"
  9. :muted="true"
  10. :loop="true"
  11. id="videoRef"
  12. class="video">
  13. </video>
  14. </view>
  15. <login-content v-if="showContent"></login-content>
  16. </view>
  17. </template>
  18. <script>
  19. import LoginContent from "@/pages/login/model/loginContent.nvue";
  20. export default {
  21. components: {LoginContent},
  22. data() {
  23. return {
  24. VideoContext: {},
  25. showContent:false
  26. }
  27. },
  28. onLoad(query) {
  29. // #ifdef H5
  30. this.showContent=true
  31. //#endif
  32. },
  33. onShow() {
  34. // 当app切到后台再切回前台的时候会触发onShow这个时候视频应该继续播放,不这样做视频会暂停的
  35. this.$nextTick(() => {
  36. this.VideoContext = uni.createVideoContext('videoRef');
  37. this.VideoContext.play()
  38. })
  39. },
  40. methods: {
  41. }
  42. }
  43. </script>
  44. <style scoped lang="scss">
  45. .login-box{
  46. position: relative;
  47. height: 100vh;
  48. overflow: hidden;
  49. .video-background{
  50. z-index: 1;
  51. position: absolute;
  52. top: 0;
  53. right: 0;
  54. left: 0;
  55. bottom: 0;
  56. .video{
  57. width: 100vw;
  58. height: 100vh;
  59. }
  60. }
  61. }
  62. </style>