| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <div >
- <van-row gutter="10" >
- <van-col span="6" v-for="(urls, index) in imgs" :key="index">
- <div class="imgview">
- <img v-if="urls.type=='2'" :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>
- <img v-else :src="urls.fileUrl" width="100px" height="100px" @click="previewsImg(index)"/>
- </div>
- </van-col>
- </van-row>
- </div>
- </template>
- <script>
- import {ImagePreview} from "vant";
- import {removePhoto} from "@/api/index";
- export default {
- name: 'deleteUploadImg',
- props: {
- imgs: {
- type: Array,
- default() {
- return []
- }
- },
- },
- data() {
- return {
- url: process.env.VUE_APP_Target1 + process.env.VUE_APP_BASE_API
- }
- },
- methods: {
- deleteImg(index, collectionItemId) {
- removePhoto({fileId: collectionItemId}).then(res => {
- if (res.code == 200) {
- this.$toast("删除成功!")
- this.imgs.splice(index, 1);
- } else {
- this.$toast("删除失败!")
- }
- })
- },
- previewsImg(index) {
- var arrimg = []
- for (var imgi = 0; imgi < this.imgs.length; imgi++) {
- arrimg.push(this.imgs[imgi].fileUrl)
- }
- ImagePreview({
- images: arrimg,
- startPosition: index,
- onClose() {
- // do something
- }
- });
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .imgview {
- width: 100%;
- height: 72px;
- position: relative;
- display: inline-block;
- i {
- position: absolute;
- right: -2px;
- top: -3px;
- color: white;
- background: red;
- overflow: hidden;
- border-radius: 50%;
- }
- img {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|