video-play.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="dialog-video" >
  3. <video class="video-box" v-if="show" :src="videoData" id="videoEle" controls autoplay >
  4. <!-- <cover-view class="video-close">
  5. <cover-image class="video-icon" @tap="toggleClose" src="/pages/TUIKit/assets/icon/close.svg"></cover-image>
  6. <cover-image class="video-icon" src="/pages/TUIKit/assets/icon/save.svg"></cover-image>
  7. </cover-view> -->
  8. </video>
  9. </view>
  10. </template>
  11. <script lang="ts">
  12. import { defineComponent, watchEffect, reactive, toRefs } from 'vue';
  13. import {
  14. onLoad,
  15. onShow,
  16. onReady,
  17. onNavigationBarButtonTap
  18. } from '@dcloudio/uni-app'
  19. export default defineComponent({
  20. name: "videoPlay",
  21. setup(props:any) {
  22. const data = reactive({
  23. videoData: '',
  24. show: false,
  25. videoContext: null,
  26. direction: 0
  27. });
  28. onLoad((option) => {
  29. data.videoData = option && option.videoMessage
  30. data.show = true
  31. })
  32. onReady(() => {
  33. data.videoContext = uni.createVideoContext('videoEle');
  34. })
  35. const toggleClose = () => {
  36. data.show = false
  37. uni.navigateBack({
  38. delta: 1
  39. });
  40. }
  41. return {
  42. ...toRefs(data),
  43. toggleClose
  44. };
  45. }
  46. });
  47. </script>
  48. <style lang="scss" scoped>
  49. .dialog-video {
  50. position: fixed;
  51. z-index: 999;
  52. width: 100vw;
  53. height: 100vh;
  54. background: rgba(#000000, 0.6);
  55. top: 0;
  56. left: 0;
  57. right: 0;
  58. bottom: 0;
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. .video-box {
  63. position: absolute;
  64. width: 100vw;
  65. height: 100vh;
  66. top: 0;
  67. left: 0;
  68. right: 0;
  69. bottom: 0;
  70. }
  71. .video-close {
  72. z-index: 999;
  73. width: 90%;
  74. color: antiquewhite;
  75. position: absolute;
  76. display: flex;
  77. justify-content:space-between;
  78. bottom: 50px;
  79. left: 10px;
  80. right: 0;
  81. margin: 0 auto;
  82. .video-icon {
  83. display: block;
  84. width: 30px;
  85. height: 30px;
  86. }
  87. }
  88. }
  89. .content {
  90. &-in {
  91. border-radius: 6px;
  92. }
  93. &-out {
  94. border-radius: 6px;
  95. }
  96. }
  97. </style>