<template>
	<view class="content">
		<view class="list" v-if="list.length > 0">
			<view class="list-item hflex acenter jbetween" v-for="(item,index) in list" :key="index">
				<view class="item-left vflex">
					<text>{{item.remark}}</text>
					<text>{{item.created_at}}</text>
				</view>
				<view class="item-right" :class="item.amount > 0 ? '' : 'item-right2'">
					{{item.amount > 0 ? '+' + item.amount : item.amount}}
				</view>
			</view>
		</view>
		<view class="hflex acenter jcenter " style="height: 100vh;" v-else>
			<u-empty mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	import $api from '@/static/js/api.js'
	export default {
		data() {
			return {
				list: [],
				page: 1,
				last_page: 1
			}
		},
		onLoad() {
			this.getlist()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.getlist()
			} else {
				uni.$u.toast('已经到底了')
				return
			}
		},
		methods: {
			getlist() {
				var _this = this
				$api.req({
					url: 'finance',
					data: {
						is_page: 1,
						page: _this.page,
						limit: 10,
					}
				}, function(res) {
					if (res.code == 10000) {
						_this.list = _this.list.concat(res.data.list)
						_this.last_page = res.data.last_page
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		min-height: 100vh;
		background: #FFFFFF;

		.list {
			padding: 10rpx 28rpx;

			.list-item {
				padding: 22rpx 0;
				border-bottom: 1px solid #F3F3F3;

				.item-left {
					text:first-child {
						font-size: 32rpx;
						font-family: SFPro, SFPro;
						font-weight: 400;
						color: #222222;
					}

					text:last-child {
						font-size: 24rpx;
						font-family: SFPro, SFPro;
						font-weight: 400;
						color: #222222;
						padding: 10rpx 0 0;
					}
				}

				.item-right {
					font-size: 36rpx;
					font-family: JDZhengHT, JDZhengHT;
					font-weight: 400;
					color: #E02020;
				}

				.item-right2 {
					font-size: 36rpx;
					font-family: JDZhengHT, JDZhengHT;
					font-weight: 400;
					color: #B4B4B4 !important;
				}
			}

		}
	}
</style>