Files
dvcp_v2_wxcp_app/library/apps/AppBuilding/AiImage.vue

81 lines
1.6 KiB
Vue
Raw Normal View History

2021-11-15 10:29:05 +08:00
<template>
<section class="AiImage">
<div v-if="$slots.default" @tap="prev">
<slot/>
</div>
2021-12-01 18:09:58 +08:00
<u-image v-else :src="image" @tap="prev">
2021-11-15 10:29:05 +08:00
<image v-if="link" class="errorImage" slot="error" :src="$cdn+'link.png'"/>
<image v-else-if="miniapp" class="errorImage" slot="error" :src="$cdn+'miniwxmp.jpg'"/>
2022-03-10 12:17:44 +08:00
<div v-else-if="$slots.errorImage" slot="error">
<slot name="errorImage"/>
</div>
2021-11-15 10:29:05 +08:00
<image v-else class="errorImage" slot="error" :src="$cdn+'file.png'"/>
</u-image>
</section>
</template>
<script>
import {mapActions} from "vuex";
export default {
name: "AiImage",
data() {
return {
dialog: false
}
},
computed: {
image() {
return this.src?.replace(/\\/g, '/')
2021-12-01 18:09:58 +08:00
}
},
2021-11-15 10:29:05 +08:00
props: {
src: String,
preview: Boolean,
link: Boolean,
miniapp: Boolean,
file: {
default: () => {
}
}
},
methods: {
...mapActions(['previewFile', 'injectJWeixin']),
prev() {
if (this.preview) {
2021-12-01 18:09:58 +08:00
if (!!this.image) {
2021-11-15 10:29:05 +08:00
uni.previewImage({
2021-12-01 18:09:58 +08:00
current: this.image,
2021-12-10 18:03:07 +08:00
urls: [this.image],
success() {
2021-12-15 14:37:20 +08:00
sessionStorage.setItem("previewImage", " 1")
2021-12-10 18:03:07 +08:00
}
2021-11-15 10:29:05 +08:00
})
} else {
this.previewFile({size: 1, ...this.file})
}
}
},
}
}
</script>
<style lang="scss" scoped>
.AiImage {
::v-deep image {
width: 160px;
height: 160px;
object-fit: cover;
}
::v-deep .u-image__error {
position: relative;
}
.errorImage {
width: 80px;
height: 80px;
}
}
</style>