deleteUploadImg1.vue 2.5 KB

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