<template>
	<view class="main">
		<u-tabs :list="list" active-color="#F1C453" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view class="list_item u-margin-top-30 margin-lr-sm" v-for="(item,index) in listItem" :key="index">
			<view class="order-num flex justify-end align-center u-font-28 u-padding-bottom-10 u-border-bottom"
				style="color:#909399;">
				<text class="u-font-24">申请日期：{{item.created_at}}</text>
			</view>
			<view class="order-num u-margin-top-15 flex align-center u-padding-bottom-10">
				<u-avatar src="/static/md-monetization_on@3x.png" size="100"></u-avatar>
				<view class="u-margin-left-20 flex-sub" style="color: #505559;">
					<view class="u-font-28">
						佣金提现：{{item.bank_name}}（{{formatStr(item.bank_card)}}）
					</view>
					<view class="u-font-28">
						提现人姓名：{{item.real_name}}
					</view>
				</view>
				<view class="text-green text-bold">
					+ {{item.real_withdraw/100}}元
				</view>
			</view>
			<view v-if="item.status == 3" class="text-red text-bold text-right">
				已驳回
			</view>
			<view v-else-if="item.status == 2" class="text-green text-bold text-right">
				已打款
			</view>
			<view v-else-if="item.status == 0||item.status == 1" class="text-yellow text-bold text-right">
				{{item.status == 0?'待审核':'待打款'}}
			</view>
		</view>
		<uni-load-more :loadingType="loadingType" :contentText="contentText" />
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				list: [{
					name: '全部'
				}, {
					name: '待审核'
				}, {
					name: '待打款',
				}, {
					name: '已成功',
				},{
					name: '已驳回',
				}],
				current: 0,
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				indexPage: 1,
				listItem: []
			}
		},
		onLoad() {
			this.getUserMoneyRecord()
		},
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			this.getUserMoneyRecord();
		},
		methods: {
			formatStr(str){
				return str.substring(str.length-4)
			},
			change(index) {
				this.indexPage = 1
				this.listItem = []
				this.current = index;
				this.getUserMoneyRecord()
			},
			async getUserMoneyRecord() {
				let num = this.current
				let res = await this.$u.post("manager/withdrawList", {
					page: this.indexPage,
					status: num - 1
				})
				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;
	}

	button::after {
		display: none;
	}
</style>
