login.vue 1.4 KB

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