多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.5 KiB

2 years ago
  1. <template>
  2. <div class="videoBox warp" :class="'terminal' + terminal">
  3. <div class="videoLeftBox">
  4. <h3>{{componentContent.title}}</h3>
  5. <div v-html="componentContent.mainBody"></div>
  6. </div>
  7. <div class="videoRightBox" v-if="componentContent.coverImg && isPlay">
  8. <video class="myVideo" id="myVideo" :src="componentContent.videoUrl" enable-danmu danmu-btn controls></video>
  9. </div>
  10. <div class="videoCoverBox" v-if="componentContent.coverImg && !isPlay" @click="handlePlayVideo">
  11. <image :src="componentContent.coverImg" ></image>
  12. </div>
  13. <div class="videoRightBox" v-if="!componentContent.coverImg">
  14. <video class="myVideo" id="myVideo" :src="componentContent.videoUrl" enable-danmu danmu-btn controls></video>
  15. </div>
  16. <div class="clear"></div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'videoBox',
  22. props: {
  23. terminal: {
  24. type: Number,
  25. default: 4
  26. },
  27. componentContent: {
  28. type: Object
  29. }
  30. },
  31. created(){
  32. console.log('componentContent',this.componentContent)
  33. },
  34. mounted() {
  35. this.videoContext = uni.createVideoContext('myVideo',this)
  36. },
  37. data () {
  38. return {
  39. isPlay:false,
  40. videoContext:null
  41. }
  42. },
  43. methods:{
  44. handlePlayVideo(){
  45. this.isPlay = true
  46. setTimeout(()=>{
  47. this.videoContext.play()
  48. },500)
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .videoBox {
  55. padding: 20upx 0;
  56. display: flex;
  57. justify-content: flex-start;
  58. align-items: center;
  59. .videoLeftBox {
  60. width: 50%;
  61. padding-right: 10%;
  62. h3 {
  63. font-size: 28upx;
  64. color: #333333;
  65. margin-bottom: 30upx;
  66. }
  67. p {
  68. color: #333333;
  69. font-size: 14upx;
  70. line-height: 30upx;
  71. }
  72. }
  73. .videoRightBox {
  74. width: 50%;
  75. video {
  76. width: 100%;
  77. }
  78. }
  79. .clear {
  80. clear: both;
  81. }
  82. }
  83. .terminal1,.terminal2,.terminal3{
  84. &.videoBox{
  85. display: block;
  86. .videoLeftBox{
  87. width: 100%;
  88. text-align: center;
  89. margin-bottom: 20upx;
  90. }
  91. .videoRightBox {
  92. width: 100%;
  93. }
  94. }
  95. }
  96. .videoCoverBox{
  97. aspect-ratio: 16/9;
  98. position: relative;
  99. &:before{
  100. content: '';
  101. width: 0rpx;
  102. height: 0rpx;
  103. border-left:80rpx solid #fff;
  104. border-right:50rpx solid transparent;
  105. border-top:50rpx solid transparent;
  106. border-bottom:50rpx solid transparent;
  107. position: absolute;
  108. top: 50%;
  109. left: 50%;
  110. transform: translate(-30%,-50%);
  111. z-index: 99;
  112. }
  113. image{
  114. width: 100%;
  115. height: 100%;
  116. }
  117. }
  118. </style>