<template>
    <dl data-type="12" :class='[(chatMen ? "chat-right" : "chat-left")]'>
         <!-- <h2>{{chatObj}}</h2>  -->
        <dt>
            <a>
                <img :src='chatImg' class="c-images-cycle">
            </a>
        </dt>
        <div class="c-content">
            <span class="c-f12 name">{{chatObj.sender_name}}</span>
            <div class="c-msg">
                <dd class="preview-video" data-image="http://172.19.103.54:80/group1/M00/0E/70/rBFuWllfKG2AHZoVAAFny_UvcSQ647.png" data-video="http://172.19.103.54:80/group1/M00/0E/70/rBFuWllfKG6AQhQFAAHF3lz7QoI155.mov">
                    <!-- <video id='video' :src='chatObj.content.split(",")[1]'  @click='openOrCloseFn()' loop></video> -->
                    <span class="yidu yidu1" v-show="chatMen && chatJudge && chatJudge > chatObj.timestamp">已读</span>
                    <img :class='[(chatMen ? "video-img-right" : "video-img-left")]' :src='photoSrc(chatObj.content.split(",")[0])' @click='openOrCloseFn()'>
                    <i :class='[(chatMen ? "bofang-icon-right" : "bofang-icon-left")]' @click='openOrCloseFn()'></i>
                    <i :class='[(chatMen ? "jianjiao-icon-right" : "jianjiao-icon-left")]' @click='openOrCloseFn()'></i>
                    <span :class='[(chatMen ? "shichang-time-right" : "shichang-time-left")]' @click='openOrCloseFn()'>{{checkTime(chatObj.content.split(",")[2])}}</span>
                </dd>
            </div>
        </div>
    </dl>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
    @import "../../assets/sass/message-chat";
</style>
<script>
import common from '../../assets/js/common'

export default {
    props: ['chatMen', 'chatJudge', 'chatObj', 'chatImg'],
    components: {

    },
    mounted() {

    },
    data() {
        return {
            openOrClose: false,
            arr: []
        }
    },
    methods: {
        photoSrc(str) {
            return common.setImgUrl(str)
        },
        // 前缀加0
        addstr0(num) {
            if (num < 10) {
                return '0' + num
            } else {
                return num
            }
        },
        // 视频时长出来
        checkTime(num) {
            let min = parseInt(num / 60000),
                sec = parseInt(num / 1000)
            return this.addstr0(min) + ':' + this.addstr0(sec)
        },
        // 视频播放
        openOrCloseFn() {
            this.openOrClose = true
            this.arr[0] = this.openOrClose
            this.arr[1] = this.photoSrc(this.chatObj.content.split(',')[1])
            this.$root.bus.$emit('openOrCloseVideo', this.arr)
        }
    }
}
</script>
