deleteUploadImg1.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div>
  3. <van-row gutter="10">
  4. <van-col span="6" v-for="(urls, index) in imgs" :key="index">
  5. <div class="imgview">
  6. <van-icon
  7. name="close"
  8. size="16"
  9. v-on:click="deleteImg(index, urls.id)"
  10. v-if="photoIdentifyType != 1" />
  11. <img
  12. v-if="urls.type == '2'"
  13. :src="urls.fileUrl"
  14. width="100px"
  15. height="100px"
  16. @click="previewsImg(index)" />
  17. <img
  18. v-else
  19. :src="urls.fileUrl"
  20. width="100px"
  21. height="100px"
  22. @click="previewsImg(index)" />
  23. </div>
  24. </van-col>
  25. </van-row>
  26. <!-- <div style="padding: 10px 16px 0;">-->
  27. <!-- <div class="img-box" v-for="(urls, index) in imgs" :key="index">-->
  28. <!-- <van-icon name="clear" v-on:click="deleteImg(index,urls.id)"/>-->
  29. <!-- <img v-if="urls.type=='2'" :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>-->
  30. <!-- <img v-else :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>-->
  31. <!-- </div>-->
  32. <!-- </div>-->
  33. </div>
  34. </template>
  35. <script>
  36. import { ImagePreview } from 'vant';
  37. import { removePhoto } from '@/api/index';
  38. export default {
  39. name: 'deleteUploadImg',
  40. props: {
  41. imgs: {
  42. type: Array,
  43. default() {
  44. return [];
  45. },
  46. },
  47. photoIdentifyType: {
  48. // 图匠识别目的(1:店招内容识别,2:门店代码识别,3:调色机识别,4:更换店招)
  49. type: String,
  50. default: '',
  51. },
  52. },
  53. data() {
  54. return {
  55. url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
  56. };
  57. },
  58. methods: {
  59. deleteImg(index, collectionItemId) {
  60. removePhoto({ fileId: collectionItemId }).then((res) => {
  61. if (res.code == 200) {
  62. this.$toast('删除成功!');
  63. this.imgs.splice(index, 1);
  64. } else {
  65. this.$toast('删除失败!');
  66. }
  67. });
  68. },
  69. previewsImg(index) {
  70. var arrimg = [];
  71. for (var imgi = 0; imgi < this.imgs.length; imgi++) {
  72. arrimg.push(this.imgs[imgi].fileUrl);
  73. }
  74. ImagePreview({
  75. images: arrimg,
  76. startPosition: index,
  77. onClose() {
  78. // do something
  79. },
  80. });
  81. },
  82. },
  83. };
  84. </script>
  85. <style lang="scss" scoped>
  86. .imgview {
  87. width: 100%;
  88. height: 72px;
  89. position: relative;
  90. display: inline-block;
  91. i {
  92. position: absolute;
  93. right: -2px;
  94. top: -3px;
  95. color: white;
  96. background: red;
  97. overflow: hidden;
  98. border-radius: 50%;
  99. }
  100. img {
  101. width: 100%;
  102. height: 100%;
  103. }
  104. }
  105. </style>