<template>
	<view class="recharge">
		<view class="recharge-bd">
			<view class="item" v-for="item in list" :key="i" v-if="list.length>0">
				<view class="l">
					<view class="a">提现</view>
					<view class="b">{{item.created_at}}</view>
				</view>
				<view class="r">
					<view class="a">-{{item.money}}</view>
					<view class="b">{{item.status==0?'待审核':item.status==1?'提现成功':'提现失败'}}</view>
				</view>
			</view>
		</view>
		<u-empty text="暂无数据显示哦～" v-if="list.length==0" mode="list"></u-empty>
	</view>
</template>

<script>
	import * as wallet from '@/api/wallet'
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getRechargeList()
		},
		methods: {
			getRechargeList() {
				let that = this;
				wallet.list()
					.then(res => {
						if (res.data.list.data.length == 0) {
							res.data.list.data.forEach((elem) => {
								elem.created_at = that.timestampToYds(elem.created_at)
							});
						}
						that.list = res.data.list.data
					})
					.finally()
			},
			timestampToYds(timestamp) {
				//时间戳为10位需*1000，为13位不需乘1000
				let times = timestamp.length == 10 ? times * 1000 : timestamp;
				var date = new Date(times);
				let Y = date.getFullYear(),
					M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1),
					D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()),
					h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()),
					m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()),
					s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
				return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s
			},
		}
	}
</script>

<style lang="scss" scoped>
	.recharge {
		padding: 25rpx;
		overflow: hidden;

		&-bd {
			padding: 0 28rpx;
			background-color: #fff;
			border-radius: 12rpx;
			overflow: hidden;

			.item {
				padding: 20rpx 0;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-top: 1px solid #F3F3F3;

				&:first-child {
					border-top-color: #fff;
				}

				.l {
					flex: 1;

					.a {
						padding: 20rpx 0;
						margin:0 6rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #595959;
					}

					.b {
						font-size: 28rpx;
						font-weight: 400;
						color: #A3A3A3;
						margin:0 6rpx
					}
				}

				.r {
					flex: 1;
					text-align: right;

					.a {
						font-size: 40rpx;
						font-weight: 500;
						color: #414141;
					}

					.b {
						font-size: 28rpx;
						font-weight: 400;
						color: #A3A3A3;
					}
				}
			}
		}
	}

	.empty {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100%;

		image {
			width: 114rpx;
			height: auto;
			margin-top: 200rpx;
		}
	}
</style>
