xvideo.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="video_content">
  3. <view v-if="show" class="popup_content">
  4. <view class="flex">
  5. <video id="myVideo" :src="videoUrl" style="width:100%;height: 372rpx; margin: 10rpx 10rpx;"></video>
  6. </view>
  7. <view class="flex" style="margin-top: 10rpx;" v-if="showBtn">
  8. <view>
  9. <xbutton size='medium' round='25rpx' padding='0rpx 20rpx' bgColor='#2C6FF3' @tap="playVideo(0)">主视频
  10. </xbutton>
  11. </view>
  12. <view style="margin-left: 24rpx;">
  13. <xbutton size='medium' round='25rpx' padding='0rpx 20rpx' bgColor='#2C6FF3' @tap="playVideo(1)">副视频
  14. </xbutton>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="popup_overlay" v-if="show" @click="closeVideoView()"></view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. show: false,
  26. videoUrl: null,
  27. }
  28. },
  29. props: {
  30. showBtn: {
  31. type: Boolean,
  32. require: true,
  33. default: false
  34. },
  35. list: {
  36. type: [Array,String],
  37. require: true,
  38. default () {
  39. return ''
  40. }
  41. },
  42. },
  43. watch:{
  44. list:{
  45. handler(newVal,oldVal){
  46. if(newVal!=null){
  47. if(typeof(newVal)=='object'){
  48. this.videoUrl=newVal[0]
  49. }else{
  50. this.videoUrl=newVal
  51. }
  52. }
  53. },
  54. deep:true,
  55. immediate:true
  56. }
  57. },
  58. methods: {
  59. closeVideoView() {
  60. this.show = false
  61. },
  62. playVideo(type){
  63. this.videoUrl=this.list[type]
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .popup_content {
  70. position: fixed;
  71. top: 50%;
  72. left: 50%;
  73. width: 700rpx;
  74. height: 500rpx;
  75. margin-left: -350rpx;
  76. margin-top: -250rpx;
  77. border: 10px solid white;
  78. background-color: white;
  79. z-index: 1002;
  80. overflow: auto;
  81. }
  82. .popup_overlay {
  83. position: fixed;
  84. top: 0%;
  85. left: 0%;
  86. width: 100%;
  87. height: 100%;
  88. background-color: black;
  89. z-index: 1001;
  90. -moz-opacity: 0.8;
  91. opacity: .80;
  92. filter: alpha(opacity=88);
  93. }
  94. </style>