message-video.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="message-video">
  3. <div class="message-video-box" :class="[!video.progress && 'message-video-cover']" @tap="toggleShow">
  4. <image :src="video.snapshotUrl" class="message-video-box" :class="['content-' + message.flow]"></image>
  5. <image src="../../../../assets/icon/play_normal@2x.png" class="video-play"></image>
  6. </div>
  7. </div>
  8. </template>
  9. <script lang="ts">
  10. import { defineComponent, watchEffect, reactive, toRefs } from 'vue';
  11. export default defineComponent({
  12. props: {
  13. data: {
  14. type: Object,
  15. default: () => {
  16. return {};
  17. }
  18. },
  19. messageData: {
  20. type: Object,
  21. default: () => {
  22. return {};
  23. }
  24. }
  25. },
  26. setup(props:any, ctx:any) {
  27. const data = reactive({
  28. video: {},
  29. message: {},
  30. show: false,
  31. videoContext: null
  32. });
  33. watchEffect(()=>{
  34. data.video = props.data;
  35. data.message = props.messageData
  36. });
  37. const toggleShow = () => {
  38. uni.navigateTo({
  39. url:`./components/message-elements/video-play?videoMessage=${data.video.url}`
  40. })
  41. };
  42. return {
  43. ...toRefs(data),
  44. toggleShow,
  45. };
  46. }
  47. });
  48. </script>
  49. <style lang="scss" scoped>
  50. .message-video {
  51. position: relative;
  52. &-box {
  53. width: 120px;
  54. max-width: 120px;
  55. background-color: rgba(#000000, 0.3);
  56. border-radius: 6px;
  57. height: 200px; // todo 优化高度动态获取
  58. video {
  59. // max-width: 300px;
  60. }
  61. }
  62. &-cover {
  63. display: inline-block;
  64. position: relative;
  65. .video-play {
  66. position: absolute;
  67. top: 0;
  68. right: 0;
  69. left: 0;
  70. bottom: 0;
  71. z-index: 3;
  72. width: 35px;
  73. height: 35px;
  74. margin: auto;
  75. }
  76. // video {
  77. // max-width: 300px;
  78. // }
  79. }
  80. .progress {
  81. position: absolute;
  82. box-sizing: border-box;
  83. width: 100%;
  84. height: 100%;
  85. padding: 0 20px;
  86. left: 0;
  87. top: 0;
  88. background: rgba(#000000, 0.5);
  89. display: flex;
  90. align-items: center;
  91. progress {
  92. width: 100%;
  93. }
  94. }
  95. }
  96. .dialog-video {
  97. position: fixed;
  98. z-index: 999;
  99. width: 100vw;
  100. height: 100vh;
  101. background: rgba(#000000, 0.6);
  102. top: 0;
  103. left: 0;
  104. right: 0;
  105. bottom: 0;
  106. display: flex;
  107. flex-direction: column;
  108. justify-content: center;
  109. align-items: center;
  110. .video-box {
  111. position: absolute;
  112. width: 100vw;
  113. height: 90vh;
  114. top: 100px;
  115. left: 0;
  116. right: 0;
  117. bottom: 20px;
  118. }
  119. .video-close {
  120. color: antiquewhite;
  121. position: absolute;
  122. bottom: 0;
  123. }
  124. }
  125. .content {
  126. &-in {
  127. border-radius: 6px;
  128. }
  129. &-out {
  130. border-radius: 6px;
  131. }
  132. }
  133. </style>