<template>
	<view>
		<view class="content" v-if="list.length" >
			<view class="list_box" v-for="(item,index) in list" :key="index">
				<view class="list_left">
					<view class="name">{{item.title}}</view>
					<view class="data">{{item.createTime}}</view>
				</view>
				<view class="list_right" style="color: red;" v-if="item.type==2">- {{item.money}}</view>
				<view class="list_right" style="color: #33D442;" v-if="item.type==1">+ {{item.money}}</view>
			</view>
		</view>
		<empty v-else></empty>
	</view>
</template>

<script>
	import empty from '@/components/empty'
	export default {
		components: {
			empty
		},
		data() {
			return {
				list: [],
				page: 1,
				totalCount: 0
			}
		},
		onLoad() {
			this.taskData()
		},
		methods: {
			// 获取任务数据
			taskData() {
				this.$Request.getT('/app/userinfo/findMoneyDetails?classify=3&page='+this.page+'&limit=15').then(res => {
					if(res.code==0){
						// this.list = res.data.list
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = this.list.concat(res.data.list)
						}
						
						this.totalCount = res.data.totalPage
					}
					console.log('res',res)
					uni.stopPullDownRefresh();
				});
			},
		},
		// 上拉加载
		onReachBottom: function() {
			if (this.page < this.totalCount) {
				this.page += 1;
				this.taskData();
			} else {
				uni.showToast({
					title: '已经最后一页啦',
					icon: 'none'
				})
			}
			
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.taskData();
		},
	}
</script>

<style>
	body {
		background: #F5F5F5;
	}

	.content {
		width: 100%;
		background: #FFFFFF;
		/* margin-top: 20rpx; */
		padding-bottom: 50rpx;
		padding-top: 20rpx;
	}

	.list_box {
		width: 90%;
		margin: 0 auto;
		display: flex;
		line-height: 45rpx;
		padding-top: 20rpx;
	}

	.list_left {
		flex: 2;
	}

	.name {
		font-size: 26rpx;
		color: #333333;
		font-weight: bold;
		letter-spacing: 2rpx;
	}

	.data {
		color: #999999;
		font-size: 24rpx;
	}

	.list_right {
		flex: 1;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		font-size: 31rpx;
	}
</style>
