<template>
    <div class="container">
        <div class="title">系统消息</div>
        <div v-if="newsList != 0">
            <div class="news" v-for="(item, index) in newsList" :key="index">
                <div class="news-l">
                    <el-avatar
                        :size="46"
                        src="https://zhirongip.oss-cn-hangzhou.aliyuncs.com/image/2021-07-21-15-53-49AdKihDPS.png"
                    ></el-avatar>
                    <div class="news-con">
                        <div class="txt">
                            <div class="txt1">系统消息</div>
                            <div class="txt2">{{ item.createdAt }}</div>
                        </div>
                        <div class="txt3">{{ item.content }}</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="empty" v-else>
            <i class="el-icon-takeaway-box" style="margin-left: 29px"></i>
            <div style="font-size: 30px">暂无信息</div>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    data() {
        return {
            newsList: []
        };
    },
    computed: {
        ...mapState(['userInfo'])
    },
    created() {
        const receiveUserId = this.userInfo.id;
        this.$http.post('/information/all', { size: 1000, query: { receiveUserId } }, { body: 'json' }).then(res => {
            this.newsList = res.content;
        });
    },
    methods: {}
};
</script>

<style lang="less" scoped>
.container {
    margin: 17px 20px 20px;
    .title {
        font-size: 16px;
        font-weight: bold;
        color: #000000;
        padding-bottom: 17px;
        line-height: 26px;
        border-bottom: 1px solid @bg;
    }
    .empty {
        position: absolute;
        top: 65%;
        left: 53%;
        font-size: 60px;
        color: #ccc;
    }
    .news {
        margin-top: 20px;
        display: flex;
        .news-l {
            display: flex;
            .news-con {
                padding-left: 10px;
                .txt {
                    .flex();
                    margin-bottom: 5px;
                    .txt1 {
                        font-size: 14px;
                        line-height: 24px;
                        font-weight: bold;
                        color: #000000;
                    }
                    .txt2 {
                        font-size: 14px;
                        font-weight: 400;
                        color: #c8c9cc;
                        line-height: 24px;
                        margin-left: 30px;
                    }
                }
                .txt3 {
                    background: #f5f7fa;
                    border-radius: 0px 8px 8px 8px;
                    font-size: 14px;
                    font-weight: 400;
                    color: #000;
                    padding: 5px 10px;
                    line-height: 24px;
                }
            }
        }
    }
}
</style>
