<template>
	<view class="content">
		<view class="warp">
			<block v-if="type==3">
				<view v-for="item in newsInfo" :key="item.id" class="pgConBox bb">
					<view class="pgConTop dfsb">
						 充值 ： <text class="elli red"> {{ item.money }}</text>
					</view> 
					<view class="pgConBot dfsb">
						<text>{{type==3?'充值时间：':''}}{{ item.pay_time }}</text> 
					</view>
				</view>
			</block> 
			<block v-if="type==1">
				<view v-for="item in newsInfo" :key="item.id" class="pgConBox bb">
					<view class="pgConTop dfsb">
						<text class="elli">提现：<text class="red"> {{ item.money }}</text>手续费{{item.sxf}},实际到账{{item.actual}}</text>
						<text :class="['mon', item.status==0?'yellow':item.status==1?'green':item.status==2?'red':'' ]">-{{ item.money }}</text>
					</view> 
					<view class="pgConBot dfsb">
						<text class="textgrey">{{ item.create_time }}</text> 
						<text :class="['mon', item.status==0?'yellow':item.status==1?'green':item.status==2?'red':'' ]">{{ item.status==0?'待审核':item.status==1?'已结算':item.status==2?'已驳回':'' }}</text>
					</view>
				</view>
			</block>
		</view>
		<u-empty v-if="newsInfo.length < 1" icon-size="200" text="还没有记录哦" mode="list"></u-empty>
	</view>
</template>

<script>
export default {
	data() {
		return {
			type: '', //1.2 提现   3 充值  
			newsInfo: [
				// {
				// 	content: '编译成功。前端运行日志，请另行在小程序开发工具的控制台查',
				// 	money: 566,
				// 	create_time: '09:57:41'
				// }
			],
			status: 'loadmore',
			limit:20,
			page: 1
		};
	},

	onReachBottom() {
		if (this.status == 'nomore') return;
		this.status = 'loading';
		this.page = ++this.page;
		this.loading();
	},
	onLoad(opt) {
		this.type = opt.type;
		if (this.type == 1 ) {
			uni.setNavigationBarTitle({
				title: '提现记录'
			});
		} else if (this.type == 3) {
			uni.setNavigationBarTitle({
				title: '充值记录'
			});
		} 
		this.loading();
	},

	methods: {
		loading() {
			console.log(1212);
			let url = '';
			if (this.type == 1) {
				uni.setNavigationBarTitle({
					title: '提现记录'
				});
				url = 'withdrawal/cashList';
			} else if (this.type == 3) {
				uni.setNavigationBarTitle({
					title: '充值记录'
				});
				url = 'user/beanRechargeList';
			} 
			this.$api
				.request(url, {  
					page: this.page,
					limit: this.limit
				})
				.then(data => {
					if (data.code == 200) {
						this.newsInfo = this.newsInfo.concat(data.data.list);
						console.log(this.newsInfo);
						if (data.data.list.length < this.limit) {
							this.status = 'nomore';
						}
					} else {
						this.$api.toast(data.msg);
					}
				}) 
		}
	}
};
</script>
<style lang="scss">
.content {
	padding-top: 20rpx;
	.warp {
		min-height: 100vh; 
	}
	.pgConBox {
		margin-bottom: 20rpx;
		background-color: #fff;
		padding: 30rpx;
		.pgConTop {
			align-items: flex-start;
			.elli {
				flex: 1;
			}
			text {
				font-size: 30rpx;
			}
			.mon {
				font-size: 36rpx;
				font-family: DIN-Medium, DIN;
				font-weight: 500;
				margin-left: 20rpx;
			}
		}
		.pgConBot {
			margin-top: 20rpx;
			text { 
				font-size: 26rpx;
				line-height: 36rpx;
			}
		}
	}
}
</style>
