cl-image.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <image class="image" :src="imgSrc" mode="aspectFill" :disabled="false" :controls='false' @error="imgerror"></image>
  3. </template>
  4. <script>
  5. export default {
  6. props: {
  7. src: {
  8. type: String,
  9. default: ''
  10. },
  11. cloudType: {
  12. type: String,
  13. default: 'oss'
  14. },
  15. },
  16. data() {
  17. return {
  18. imgSrc: ''
  19. };
  20. },
  21. mounted() {
  22. this.setCloudFunction()
  23. },
  24. methods: {
  25. imgerror(even) {
  26. this.imgSrc = `https://mp-61599c79-d7ee-4a75-a24b-e5a288da6dd3.cdn.bspapp.com/cloudstorage/887c60f0-27f8-46d1-8769-2c45be0f3d7d.png`
  27. },
  28. setCloudFunction() {
  29. switch (this.cloudType){
  30. case 'oss':
  31. this.imgSrc = this.src + '?x-oss-process=video/snapshot,t_0,f_jpg'
  32. break;
  33. case 'process':
  34. this.imgSrc = this.src + '?ci-process=snapshot&time=0.01'
  35. break;
  36. case 'vframe':
  37. this.imgSrc = this.src + '?vframe/jpg/offset/0'
  38. break;
  39. default:
  40. this.imgSrc = this.src
  41. break;
  42. }
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. image {
  49. width: 100%;
  50. height: 100%;
  51. }
  52. </style>