<template>
    <div>
        <div class="box" @click="$router.push({ name: 'messageDetails' })">
            <img src="../../assets/xiaoxi_icon_xitong.png" />
            <div class="info">
                <div class="name">系统消息</div>
                <p>{{ sysList.content }}</p>
            </div>
            <div class="time">{{ sysList.createdAt }}</div>
        </div>
        <!-- <div class="box" v-for="n in tableData" :key="n.id" >
                <img :src="n.user.avatar" />
                <div class="info">
                    <div class="name">姓名</div>
                    <p>你好，我对贵方的一体化集成动力设备很感兴趣，有很多细节希望可以进一步沟通一下</p>
                </div>
                <div class="time">{{ n.createdAt }}</div>
            </div> -->
        <div class="box" v-for="n in conversationList" :key="n.id" @click="$router.push({ name: 'chat' })">
            <img :src="n.senderAvatar" />
            <div class="info">
                <div class="name">{{ n.senderName }}</div>
                <p>{{ n.content }}</p>
            </div>
            <div class="time">{{ n.createdAt }}</div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'msgPopups',
    data() {
        return {
            current: 0,
            sysList: {},
            conversationList: {}
        };
    },
    created() {
        this.$http.get('/message/all', { query: { messageType: 'SYSTEM_MESSAGE' } }).then(res => {
            // console.log(res);
            this.sysList = res.content;
        });
        this.$http.get('/message/all', { query: { messageType: 'CONVERSATION_MESSAGE' } }).then(res => {
            // console.log(res);
            this.conversationList = res.content;
        });
    },
    methods: {
        getIndex(index) {
            this.current = index;
        }
    }
};
</script>
<style lang="less" scoped>
.box {
    // overflow: hidden;
    display: flex;
    padding: 20px 0 20px;
    height: auto;
    // box-sizing: content-box;
    cursor: pointer;
    img {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        // background: cadetblue;
    }
    .info {
        // width: 780px;
        width: 90%;
        margin-left: 8px;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        .name {
            font-size: 14px;
            font-weight: 500;
            color: #000000;
        }
        p {
            margin: 0px;
            // width: 600px;
            // height: 22px;
            width: 100%;
            font-size: 14px;

            color: #c8c9cc;
            line-height: 22px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }
    .time {
        width: 20%;
        height: 22px;
        font-size: 13px;
        color: #c8c9cc;
        line-height: 22px;
    }
    + .box {
        // margin-top: 20px;
        border-top: 1px solid #f2f3f5;
    }
}
</style>
