login.vue 1.3 KB

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