<template>
	<view class="withdrawalManagement">
		<view class="card" :style="{backgroundImage: `url(${baseImgUrl}/withdrawalManagement_bg.png)`}">
			<view class="top-info">
				<view class="left">
					<view class="label">已提现</view>
					<view class="number">￥{{total['已提现']}}</view>
				</view>
				<view class="right">
					<view class="label">待提现</view>
					<view class="number">￥{{ total["待提现"] }}</view>
				</view>
			</view>
			<view class="bottom-info">
				<view class="number-item">总收益：￥{{total['总收益']}}</view>
				<view class="number-item">冻结中：￥{{ total["冻结中"] }}</view>
			</view>
		</view>
		<view class="title-wrap">
			<view class="title">提现记录</view>
			<navigator url="/subPages/applyWithdrawal/applyWithdrawal">
				<view class="btn">申请提现</view>
			</navigator>
		</view>
		<view class="list">
			<view class="item" v-for="item in list" :key="item.id">
				<view class="left">
					<view class="avatar-wrap">
						提现
					</view>
					<view class="info">
						<view class="name">提现到-{{ item.bank_name }}{{getBankLastCode(item.bank_code)}}</view>
						<view class="time">
							{{ item.date }}
						</view>
					</view>
				</view>
				<view class="right">
					<view class="amount">
						{{ item.amount }}
					</view>
					<view class="status" :style="{ color: STATUSMAPLIST[item.status].text }">
						{{ STATUSMAPLIST[item.status].text }}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getWithdrawalList } from "@/common/api/withdrawal.js";
	const STATUSMAPLIST = [
		{ text: '失败', color: '#8E8E8E' },
		{ text: '待审核', color: '#0085FF' },
		{ text: '已审核', color: '#00BE7A' },
		{ text: '打款中', color: '#1b7976' },
		{ text: '已打款', color: '#F39800' },
		{ text: '已收款', color: '#00BE7A' },
	]
	export default {
		data() {
			return {
				STATUSMAPLIST,
				total: {},
				list: [],
				baseImgUrl: this.$C.imageUrl
			};
		},
		onShow() {
			this._getWithdrawalList();
			console.log(7456746574356,this.$C)
		},
		methods: {
			_getWithdrawalList() {
				getWithdrawalList({
					page: 1,
					pageSize: 100,
				}).then(({ data = {} }) => {
					const { list = [], total = {} } = data;
					this.list = list;
					this.total = total;
				});
			},
			getBankLastCode(code) {
				if (!code) return "";
				return code.slice(-4);
			},
		},
	};
</script>

<style lang="scss" scoped>
	.withdrawalManagement {
		padding: 20rpx 20rpx 40rpx;
		background: #f5f6f8;

		.card {
			height: 377rpx;
			padding: 105rpx 0 0 43rpx;
			color: #fff;
			background-size: 100% 100%;
			border-radius: 16rpx;
			box-sizing: border-box;

			.top-info,
			.bottom-info {
				display: flex;
				align-items: center;
			}

			.top-info {
				padding-bottom: 34rpx;
				border-bottom: 2rpx solid rgba(255, 255, 255, 0.28);

				.left,
				.right {
					flex: 1;
				}

				.right {
					border-left: 1rpx solid #ffffff;
					padding-left: 62rpx;
				}

				.lable {
					font-size: 28rpx;
					font-weight: 500;
					color: #fffbe7;
					line-height: 39rpx;
				}

				.number {
					font-size: 42rpx;
					font-weight: bold;
					color: #ffffff;
					line-height: 59rpx;
					margin-top: 25rpx;
				}
			}

			.bottom-info {
				padding-top: 32rpx;

				.number-item {
					flex: 1;
					font-size: 26rpx;
					font-weight: 500;
					color: #ffffff;
					line-height: 36rpx;

					&:last-child {
						margin-left: 62rpx;
					}
				}
			}
		}

		.title-wrap {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 42rpx;
			padding-bottom: 6rpx;

			.title {
				font-size: 36rpx;
				font-weight: bold;
				color: #1d161f;
				line-height: 50rpx;

				&::before {
					content: "";
					display: inline-block;
					width: 4rpx;
					height: 32rpx;
					background: #f39800;
					margin-right: 8rpx;
				}
			}

			.btn {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 66rpx;
				font-size: 28rpx;
				font-weight: 500;
				padding: 0 20rpx;
				color: #fffcf7;
				line-height: 1;
				background: linear-gradient(90deg, #535257 0%, #191820 100%);
				border-radius: 7rpx 7rpx 7rpx 7rpx;
			}
		}

		.item {
			height: 154rpx;
			background: #ffffff;
			border-radius: 10rpx;
			margin-top: 20rpx;
			padding: 0 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.left {
				display: flex;
				align-items: center;

				.avatar-wrap {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 85rpx;
					height: 85rpx;
					background: #F39800;
					border-radius: 50%;
					font-size: 26rpx;
					font-weight: bold;
					color: #FFFFFF;
					line-height: 1;
				}

				.info {
					margin-left: 20rpx;
				}

				.name {
					font-size: 28rpx;
					font-weight: bold;
					color: #1d161f;
					line-height: 39rpx;
				}

				.time {
					font-size: 24rpx;
					font-weight: 500;
					color: #807f85;
					line-height: 34rpx;
					margin-top: 20rpx;
				}
			}

			.amount {
				text-align: right;
				font-size: 28rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #c9161e;
				line-height: 39rpx;
			}

			.status {
				font-size: 26rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #b2b2b2;
				line-height: 36rpx;
				margin-top: 20rpx;

				&.submited {
					color: #0085ff;
				}

				&.paid {
					color: #f39800;
				}

				&.audited {
					color: #00be7a;
				}

				&.rejected {
					color: #8e8e8e;
				}
			}
		}
	}
</style>
