<template>
	<view>
		<view class="list">
			<view class="message-bubble-received" v-for="(item, index) in list" :key="index">
				<view class="title">
					<text class="icon">&#xe813;</text>
					<text>{{ item.templateName }}</text>
				</view>
				<view class="desc">{{ item.op }}</view>
				<view class="desc">{{ item.createTime }}</view>
			</view>
			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [],
			param: { pageNum: 1, pageSize: 10, type: 0 },
			loadMore: true
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/follow/list',
				data: this.param,
				loading: 'false',
				success: (res) => {
					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
					this.list.push(...res.data.rows);
				}
			});
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
.list {
	padding: 10px 12px;
	.message-bubble-received {
		.title {
			font-size: 16px;
			font-weight: bold;
			.icon {
				padding-right: 3px;
			}
		}
		.desc {
			font-size: 13px;
			padding-top: 10px;
			color: $font-c;
		}
	}
}
</style>
