deleteUploadImg1.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div>
  3. <van-row gutter="10">
  4. <van-col span="6" v-for="(urls, index) in imgs" :key="urls.id">
  5. <div class="imgview">
  6. <van-icon
  7. v-if="(photoIdentifyType != 6 || photoIdentifyType != 7) && types != 'edit'"
  8. name="close"
  9. size="16"
  10. v-on:click="deleteImg(index, urls.id)" />
  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:更换店招,6:sku陈列照)
  49. type: String,
  50. default: '',
  51. },
  52. types: {
  53. // edit 编辑
  54. type: String,
  55. },
  56. },
  57. watch: {
  58. imgs: {
  59. handler(val) {},
  60. deep: true,
  61. immediate: true,
  62. },
  63. },
  64. data() {
  65. return {
  66. url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API,
  67. };
  68. },
  69. methods: {
  70. deleteImg(index, collectionItemId) {
  71. removePhoto({ fileId: collectionItemId }).then((res) => {
  72. if (res.code == 200) {
  73. this.$toast('删除成功!');
  74. this.imgs.splice(index, 1);
  75. } else {
  76. this.$toast('删除失败!');
  77. }
  78. });
  79. },
  80. previewsImg(index) {
  81. var arrimg = [];
  82. for (var imgi = 0; imgi < this.imgs.length; imgi++) {
  83. arrimg.push(this.imgs[imgi].fileUrl);
  84. }
  85. ImagePreview({
  86. images: arrimg,
  87. startPosition: index,
  88. onClose() {
  89. // do something
  90. },
  91. });
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .imgview {
  98. width: 100%;
  99. height: 72px;
  100. position: relative;
  101. display: inline-block;
  102. i {
  103. position: absolute;
  104. right: -2px;
  105. top: -3px;
  106. color: white;
  107. background: red;
  108. overflow: hidden;
  109. border-radius: 50%;
  110. }
  111. img {
  112. width: 100%;
  113. height: 100%;
  114. }
  115. }
  116. </style>