<template>
    <div class="follow">
        <van-sticky :offset-top="bar.value.show ? 46 : 0">
            <div class="top">
                <div class="name">我关注的</div>
            </div>
        </van-sticky>
        <div class="list">
            <template v-for="(item, index) in list" :key="index">
                <creator-info v-model:info="list[index]" @update:info="init"></creator-info>
            </template>
            <van-empty
                v-if="empty"
                description="你还没有关注别人哦～"
                :image="require('../../assets/kong_png_gaunzhu.png')"
            />
        </div>
    </div>
</template>

<script>
import CreatorInfo from '../../components/creator/CreatorInfo.vue';
export default {
    components: { CreatorInfo },
    inject: ['bar'],
    data() {
        return {
            list: [],
            empty: false
        };
    },
    computed: {
        showList() {
            return [...this.list].filter(item => {
                return item.follow;
            });
        }
    },
    mounted() {
        this.init();
    },
    methods: {
        init() {
            this.$toast.loading({
                message: '加载中...',
                forbidClick: true
            });
            this.empty = false;
            this.$http.get('/user/myFollows').then(res => {
                this.list = res;
                this.empty = res.length === 0;
                this.$toast.clear();
            });
        }
    }
};
</script>

<style lang="less" scoped>
.follow {
    background-color: #0f0f0f;
}
.top {
    background-color: #181818;
    padding: 0 16px;
    height: 50px;
    display: flex;
    align-items: center;
    .name {
        font-size: 20px;
        font-weight: bold;
        color: #ffffff;
        line-height: 30px;
    }
}
</style>
