caimei-video.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="video" :class="show ? 'video-show' : ''">
  3. <video v-if="videoObj.cmBrandFiles[0].ossUrl" :src="videoObj.cmBrandFiles[0].ossUrl" autoplay class="videoRef" controls id="videoRef"></video>
  4. <view style="display: flex;width: 100%;flex-direction: row-reverse; margin-top: 300rpx;" @click="cancel">
  5. <image
  6. src="https://static.caimei365.com/app/img/supplier-login/close.png"
  7. mode=""
  8. class="iconfont icon-guanbi close"
  9. :class="show ? 'video-show' : ''"
  10. ></image>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. show: {
  18. type: Boolean,
  19. default: () => false
  20. },
  21. videoObj: {
  22. type: Object,
  23. default: () => {}
  24. }
  25. },
  26. data() {
  27. return {
  28. videoContext: null // 播放器上下文
  29. }
  30. },
  31. watch: {},
  32. mounted() {
  33. this.videoContext = uni.createVideoContext('videoRef', this)
  34. },
  35. methods: {
  36. cancel() {
  37. this.videoContext.pause()
  38. this.$emit('closeClick')
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .video {
  45. width: 100vw;
  46. height: 100vh;
  47. box-sizing: border-box;
  48. background-color: rgba(0, 0, 0, 0.5);
  49. justify-content: flex-end;
  50. align-items: center;
  51. flex-direction: column-reverse;
  52. z-index: 999;
  53. position: fixed;
  54. opacity: 0;
  55. display: none;
  56. left: 0;
  57. top: 0;
  58. .videoRef {
  59. width: 80%;
  60. height: 500rpx;
  61. }
  62. }
  63. .video-show {
  64. opacity: 1;
  65. display: flex !important;
  66. }
  67. .close {
  68. width: 67rpx;
  69. height: 67rpx;
  70. margin-bottom: -30rpx;
  71. margin-right: 6%;
  72. z-index: 1;
  73. }
  74. </style>