<template>
	<view class="attention">
		<mescroll-body top="30" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
			<view class="fans-list">
				<view class="fans-item" v-for="(item,index) in list" :key="item.id"
					@click="$navigateTo('/pages/person/person?userId='+item.userId)">
					<image class="fans-avatar" :src="item.fansUserPortrait" mode="">
					</image>
					<view class="fans-content">
						<view class="fans-name">{{item.fansUserName}}</view>
						<view class="fans-organization">{{item.date}}</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {
		getFansAttentionListByPage
	} from '@/request/api/my.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				list: []
			}
		},
		onLoad() {

		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				getFansAttentionListByPage(page.num, 10).then(res => {
					if (res.code === 200) {
						this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
						if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
						let data = res.data.dataList;
						this.list = this.list.concat(data); //追加新数据
					} else {
						this.mescroll.endErr();
					}
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})

			}
		}
	}
</script>

<style lang="scss"></style>