<template>
    <div class="ui-label-article-list px-24rem pt-12rem">
        <UiMainArticle v-for="article in articles" :item="article"></UiMainArticle>
        <van-empty v-if="!articles.length" description="暂无数据" />
    </div>
</template>

<script>
    export default {
        name: "ui-label-article-list",
        data(){
            return {
                articles:[]
            }
        },
        props:{
            label:{
                type:Object,
                default(){
                    return ''
                }
            }
        },
        watch:{
            label:{
                immediate:true,
                handler(){
                    this.labelArticles(1);
                }
            }
        },
        methods:{
            async labelArticles(pageIndex) {
                let resp = await this.$http.post(this.$api.cms.articles, this.$qs.stringify({pageIndex: pageIndex,keywords:this.label.name}));
                if (resp.data.status === 200) {
                    if(pageIndex === 1){
                        this.articles = resp.data.data.cmsArticles;
                    }else{
                        this.articles.push(...resp.data.data.cmsArticles);
                    }
                }
            }
        }

    }
</script>

<style scoped>

</style>