<template>
    <div class="trap">
        <scroll-view :scroll-y="true" class="content" @scrolltolower="getData()">
            <article-list :list="list"></article-list>
        </scroll-view>
    </div>
</template>

<script setup>
import articleList from "@/components/articleList/index.vue";
import { getArticleListApi, getArticleTypesApi } from "@/api/article.js";
import { reactive, ref } from "vue";
/* const active = ref("");
const typeList = ref([{ id: "", name: "全部" }]);
getArticleTypesApi(2).then(res => {
    typeList.value.push(...res.data);
});
const changeType = type => {
    active.value = type.id;
    pageNo = 1;
    list.splice(0, list.length);
    flag = false;
    getData();
}; */
/* 文章 */
// 判断是否还有数据
let pageNo = 1;
let flag = false;
const list = reactive([]);

const getData = () => {
    if (flag) {
        return;
    }
    getArticleListApi({
        type: 4,
        categoryId: "",
        pageNo: pageNo++,
        pageSize: 10
    }).then(res => {
        if (res.data.length < 10) {
            flag = true;
        }
        list.push(...res.data);
    });
};
getData();
// changeType({ id: "" });
</script>

<style lang="scss" scoped>
.trap {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.tab-name {
    display: flex;
    width: 100%;
    height: 80rpx;
    overflow-x: auto;
    white-space: nowrap;
    .item {
        padding: 22rpx 24rpx;
        font-size: 28rpx;
        &.active {
            background-image: url("https://lygsh-image.wjzpgz.com/icon/arc.png");
            background-repeat: no-repeat;
            background-position: 50% 100%;
            background-size: 35.64rpx 11.24rpx;
        }
    }
}
.content {
    flex-grow: 1;
    height: 200rpx;
}
</style>
