<template>
    <view class="msg--call">
        <view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
        <view class="im--text" :class="isRemote ? 'left': 'right'">
            <uni-icons type="videocam" size="44rpx"  />
            {{ label }}
        </view>
    </view>
</template>

<script>
    import utils from '@/utils/index.js'
    import moment from 'moment'
    import imBase from '../../mixins/imBase.js'

    export default {
        mixins: [
            imBase
        ],
        props: {
            message: {
                type: Object,
                default: () => {
                    return {}
                }
            },
            isGroup: {
                type: Boolean,
                default: false
            }
        },
        computed: {
            label() {
                return this.message.content.customFields.status == 1 ? '通话时长：' + duration : '未接通'
            },
            isRemote() {
                return this.message.messageDirection == 2
            },
            duration() {
                if (this.message.content.customFields.duration > 3600) {
                    return moment.utc(this.message.content.customFields.duration * 1000).format('HH:mm:ss')
                } else {
                    return moment.utc(this.message.content.customFields.duration * 1000).format('mm:ss')
                }
            }
        }
    }
</script>

<style scoped lang="scss">
    .msg--call {
        .name {
            font-size: 26rpx;
            color: $text-gray-m;
            display: inline-block;
        }

        .im--text {
            max-width: 508rpx;
            padding: 20rpx;
            line-height: 46rpx;
            font-size: 32rpx;
            color: $text-color;
            display: flex;
            flex-direction: row;
            align-items: center;

            &.left {
                border-radius: 0 20rpx 20rpx 20rpx;
                background: white;
            }

            &.right {
                border-radius: 20rpx 0 20rpx 20rpx;
                background: $main-color;
                color: white;

                .uni-icons {
                    color: white !important;
                }
            }
        }
    }
</style>
