<template>
    <div class="message">
        <el-row>
            <div class="content_title">
                <span>通知消息</span>
            </div>
        </el-row>
        <el-row>
            <div class="classify">
                <span
                    v-for="(item, index) in List"
                    :key="index"
                    :class="index == current ? 'active' : ''"
                    @click="getIndex(index)"
                >
                    {{ item }}
                </span>
            </div>
        </el-row>
        <!--         <el-row>
            <div class="box" v-for="n in 5" :key="n">
                <img src="" />
                <div class="info">
                    <div>系统消息</div>
                    <p>
                        这是消息这是消息这是消息这是消息这是消息这是消息这是消息这是消息这是消息这是消息这是消息这是消息
                    </p>
                </div>
                <div class="time">2021.01.06</div>
            </div>
        </el-row> -->

        <el-row v-if="current === 0">
            <div class="box" v-for="n in tableData" :key="n.id">
                <img :src="n.user.avatar" />
                <div class="info">
                    <div>系统消息</div>
                    <!-- <div v-if="n.state == 2">
                        <p>你的{{ n.dataType.name }}"{{ n.title }}"</p>
                        <p>被驳回了</p>
                    </div> -->
                    <!-- <div v-if="n.state == 1">
                        <p>你的{{ n.dataType.name }}"{{ n.title }}"</p>
                        <p>审核通过了</p>
                    </div> -->
                    <p v-if="n.state == 2">
                        你的{{ n.dataType ? n.dataType.name : null }}&nbsp;"{{ n.title }}"<br />被驳回了
                    </p>
                    <p v-if="n.state == 1">
                        你的{{ n.dataType ? n.dataType.name : null }}&nbsp;"{{ n.title }}"<br />审核通过了
                    </p>
                </div>
                <div class="time">{{ n.createdAt }}</div>
            </div>
        </el-row>
        <el-row v-if="current === 1">
            <div class="box" v-for="n in tableData" :key="n.id">
                <img :src="n.user.avatar" />
                <div class="info">
                    <div>供需消息</div>
                    <p v-if="n.artNeed">你发布的技术需求&nbsp;"{{ n.artNeed.name }}"</p>
                    <p v-if="n.productNeed">你发布的产品需求&nbsp;"{{ n.productNeed.name }}"</p>
                    <p v-if="n.financingNeeds">你发布的融资需求&nbsp;"{{ n.financingNeeds.name }}"</p>
                    <p v-if="n.tresource">你发布的共享资源&nbsp;"{{ n.tresource.name }}"</p>
                    <p v-if="n.product">你发布的产品&nbsp;"{{ n.product.name }}"</p>
                    <p v-if="n.artProduct">你发布的技术产品&nbsp;"{{ n.artProduct.name }}"</p>
                    <p>有人对接了</p>
                </div>
                <div class="time">{{ n.createdAt }}</div>
            </div>
        </el-row>

        <el-row>
            <div v-for="n in tableData" :key="n.id">
                <div v-if="current === 2">
                    <div class="box" v-if="n.commentList && n.commentList.length > 0">
                        <img :src="n.user.avatar" />
                        <div class="info">
                            <div>互动消息</div>

                            <p v-for="item in n.commentList" :key="item.id">
                                你发布的话题&nbsp;"&nbsp;{{ n.title }}&nbsp;"&nbsp;,&nbsp;"&nbsp;{{
                                    item.user.nickname
                                }}&nbsp;"&nbsp;给你评论了
                            </p>
                        </div>
                        <div class="time">{{ n.createdAt }}</div>
                    </div>
                </div>
            </div>
        </el-row>
    </div>
</template>

<script>
import pageableTable from '@/mixins/pageableTable';
export default {
    mixins: [pageableTable],
    name: 'message',
    data() {
        return {
            url: '/auditHistory/myAll',
            List: ['系统消息', '供需消息', '互动消息'],
            current: 0
        };
    },
    methods: {
        getIndex(index) {
            this.current = index;
            /*            if (index === 0) {
                this.url = '/auditHistory/myAll';
                this.getData();
                this.url = '/message/all';
                const arr = this.tableData;
                this.getData();
                arr.push.apply(arr, this.tableData);
                this.url = '/topic/all';
                this.getData();
                arr.push.apply(arr, this.tableData);
                this.tableData = arr;
                return;
            } */
            if (index === 0) {
                this.url = '/auditHistory/myAll';
            }
            if (index === 1) {
                this.url = '/message/getMySupply';
            }
            if (index === 2) {
                this.url = '/topic/myAll';
            }
            this.getData();
        }
    }
};
</script>
<style lang="less" scoped>
.content_title {
    height: 60px;
    line-height: 60px;
    box-sizing: border-box;
    padding-bottom: 20px;
    border-bottom: #f2f3f5 1px solid;
    > span {
        font-size: 16px;
        color: #000000;
        line-height: 30px;
        font-weight: 700;
    }
}
.classify {
    height: 60px;
    line-height: 60px;
    span {
        cursor: pointer;
        font-size: 13px;
        color: #818999;
        + span {
            margin-left: 30px;
        }
        &.active {
            color: #bf1616;
        }
    }
}
.box {
    // overflow: hidden;
    display: flex;
    padding: 20px 0 20px;
    height: auto;
    // box-sizing: content-box;
    img {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background: cadetblue;
    }
    .info {
        width: 780px;
        margin-left: 8px;
        height: auto;
        div {
            height: 24px;
            font-size: 14px;
            font-weight: 500;
            color: #000000;
        }
        p {
            margin: 0px;
            width: 520px;
            // height: 22px;
            font-size: 13px;
            color: #494a4d;
            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>
