WebRtcImage.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div>
  3. <WebRtcCapture ref="webRtcCapture" :multiple="multiple" />
  4. <div style="height:5px" />
  5. <button class="btn btn-success" type="button" style="width:100%" @click="imageUpload">
  6. {{ $t('lang.webRtcImage.uploadImage') }}
  7. </button>
  8. </div>
  9. </template>
  10. <script>
  11. import Common from '../common/Common.js';
  12. import ImageService from '../resource/file/ImageService.js';
  13. import FileService from '../resource/file/FileService.js';
  14. import WebRtcCapture from '../widget/WebRtcCapture.vue';
  15. import { Notify, Uuid } from 'pc-component-v3';
  16. export default {
  17. components: {
  18. WebRtcCapture,
  19. },
  20. props: {
  21. /**
  22. * 可以抓拍多张图片
  23. */
  24. 'multiple' : {
  25. type: Boolean,
  26. default: null,
  27. },
  28. },
  29. data: function () {
  30. return {
  31. };
  32. },
  33. methods: {
  34. /**
  35. * 上传图片
  36. */
  37. imageUpload: function () {
  38. var _self = this;
  39. var imageSrcs = _self.$refs.webRtcCapture.imageSrcs;
  40. if (imageSrcs && imageSrcs.length == 0) {
  41. Notify.error('提示', '没有图片',false);
  42. return;
  43. }
  44. if(_self.multiple == true){
  45. _self.$emit('uploadImage', imageSrcs);
  46. }else{
  47. var imageSrc = imageSrcs[0];
  48. _self.$emit('uploadImage', imageSrc);
  49. }
  50. },
  51. },
  52. };
  53. </script>
  54. <style scoped>
  55. </style>