deleteUploadImgD.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. <img v-if="urls.type=='2'" :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>
  7. <img v-else :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>
  8. </div>
  9. </van-col>
  10. </van-row>
  11. </div>
  12. </template>
  13. <script>
  14. import {ImagePreview} from "vant";
  15. import {removePhoto} from "@/api/index";
  16. export default {
  17. name: 'deleteUploadImg',
  18. props: {
  19. imgs: {
  20. type: Array,
  21. default() {
  22. return []
  23. }
  24. },
  25. },
  26. data() {
  27. return {
  28. url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API
  29. }
  30. },
  31. methods: {
  32. deleteImg(index, collectionItemId) {
  33. removePhoto({fileId: collectionItemId}).then(res => {
  34. if (res.code == 200) {
  35. this.$toast("删除成功!")
  36. this.imgs.splice(index, 1);
  37. } else {
  38. this.$toast("删除失败!")
  39. }
  40. })
  41. },
  42. previewsImg(index) {
  43. var arrimg = []
  44. for (var imgi = 0; imgi < this.imgs.length; imgi++) {
  45. arrimg.push(this.imgs[imgi].fileUrl)
  46. }
  47. ImagePreview({
  48. images: arrimg,
  49. startPosition: index,
  50. onClose() {
  51. // do something
  52. }
  53. });
  54. },
  55. },
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .imgview {
  60. width: 100%;
  61. height: 72px;
  62. position: relative;
  63. display: inline-block;
  64. i {
  65. position: absolute;
  66. right: -2px;
  67. top: -3px;
  68. color: white;
  69. background: red;
  70. overflow: hidden;
  71. border-radius: 50%;
  72. }
  73. img {
  74. width: 100%;
  75. height: 100%;
  76. }
  77. }
  78. </style>