<template>
	<view class="main">
		<view class="list_item u-margin-top-30 margin-lr-sm flex" v-for="(item,index) in listItem" :key="index">
			<view class="">
				<u-avatar :src="item.avatar" size="70"></u-avatar>
			</view>
			<view class="u-margin-left-30" style="width: 100%;">
				<view class="order-num u-font-28 u-padding-bottom-10 u-border-bottom">
					{{item.name}}
				</view>
				<view class="margin-top-sm u-font-24" style="color:#909399;">
					{{item.message}}
				</view>
			</view>
		</view>
		<uni-load-more :loadingType="loadingType" :contentText="contentText" />
		<!-- <view class="cu-tabbar-height"></view> -->
		<!-- <view class="cu-tabbar-height"></view> -->
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				indexPage: 1,
				listItem: []
			}
		},
		onLoad() {
			this.getUserMessage()
		},
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			this.getUserMessage();
		},
		methods: {
			async getUserMessage() {
				let res = await this.$u.post("manager/message", {
					page: this.indexPage
				})
				if (res.code == 200) {
					this.listItem = this.listItem.concat(res.data.data)
					this.indexPage++
					if (res.data.current_page == res.data.last_page) {
						this.loadingType = 2;
					} else {
						this.loadingType = 0;
					}
				}else{
					uni.showToast({
						icon: 'none',
						title: data.message
					});
					this.loadingType = 0;
				}
			}
		}
	}
</script>

<style>
	.list_item {
		padding: 20rpx;
		border-radius: 16rpx;
		box-shadow: 6rpx 6rpx 10rpx rgba(122, 122, 122, 0.2);
		background: #fff;
	}

	.order-num::after {
		border-color: #bbb;
	}
</style>
