<template>
    <view class="">
        <text class="name" v-if="!guest && name">{{ name }}</text>
        <view class="msg--image" :class="guest ? 'right': 'left'">
            <image class="img" :src="msg.thumbnail" @click="previewImage" mode="widthFix"></image>
        </view>
    </view>
</template>

<script>
    export default {
        name: 'showImage',
        props: {
            msg: {
                type: Object,
                default: () => {
                    return {
                        local: '',
                        remote: '',
                        objectName: '',
                        thumbnail: '',
                        isFull: false
                    }
                }
            },
            guest: {
                type: Boolean,
                default: true
            },
            name: {
                type: String,
                default: ''
            }
        },
        methods: {
            previewImage() {
                uni.previewImage({
                    urls: [
                        this.msg.remote
                    ],
                    current: 1
                })
            }
        }
    }
</script>

<style scoped lang="scss">
    .name {
        font-size: 24rpx;
        color: $text-gray-m;
    }

    .msg--image {
        .img {
            width: 180rpx;
        }

        &.left {
            .img {
                border-radius: 0 10rpx 10rpx 10rpx;
            }
        }

        &.right {
            .img {
                border-radius: 10rpx 0 10rpx 10rpx;
            }
        }

    }
</style>
