<template>
	<view class="earnings p30">
		<z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
			<view class="mt30 wallet_list" v-for="(item, index) in dataList" :key="index">
				<view class="wallet_list_left">
					<view>{{ item.type == 1 ? '提现人' : '提现公司' }}：{{ item.name }}</view>
					<!-- <view>银行名称：{{ item.bankName }}</view> -->
					<view v-if="item.type != 1">支行名称：{{ item.subbranchName }}</view>
					<view>银行卡号：{{ item.bankCard }}</view>
					<view>提现时间：{{ timeFormat(new Date(item.createTime).getTime(), 'yyyy-mm-dd hh:MM:ss') }}</view>
					<view>处理时间：{{ item.completeTime ? timeFormat(new Date(item.completeTime).getTime(), 'yyyy-mm-dd hh:MM:ss') : '-' }}</view>
					<view>处理结果：{{ item.handleMessage || '-' }}</view>
				</view>
				<view class="wallet_list_right" style="display: flex; flex-direction: column; align-items: flex-end;height: 320rpx;">
					<view style="margin-bottom: 100rpx">
						<view></view>
						<up-tag v-if="item.status == 0" size="mini" text="申请中" type="warning" plain plainFill></up-tag>
						<up-tag v-if="item.status == 1" size="mini" type="success" text="提现成功" plain plainFill></up-tag>
						<up-tag v-if="item.status == -1" size="mini" type="error" text="失败" plain plainFill></up-tag>
					</view>
					<view>{{ item.amount }}元</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { onPullDownRefresh, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import { timeFormat } from '@/uni_modules/uview-plus';
import { userExtractList } from '@/api/api.js';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { useNav } from '@/hooks/useNav.js';
import moneyJson from '@/common/money.json';

const { nav, navTo } = useNav();
let getInfo = ref({});
const paging = ref(null);
let dataList = ref([]);

let isPagingRefNotFound = () => {
	return !paging.value;
};

function maskCardNumber(cardNumber) {
	if (!cardNumber || typeof cardNumber !== 'string') {
		throw new Error('Invalid card number');
	}
	const sanitizedNumber = cardNumber.replace(/\D/g, '');
	if (sanitizedNumber.length < 4) {
		throw new Error('Card number is too short');
	}
	const lastFourDigits = sanitizedNumber.slice(-4);
	const maskedNumber = '*'.repeat(sanitizedNumber.length - 4) + lastFourDigits;
	return maskedNumber;
}

onPullDownRefresh(() => {
	if (isPagingRefNotFound()) return;
	paging.value.reload().catch(() => {});
});

onPageScroll((e) => {
	if (isPagingRefNotFound()) return;
	paging.value.updatePageScrollTop(e.scrollTop);
	e.scrollTop < 10 && paging.value.doChatRecordLoadMore();
});

onReachBottom(() => {
	if (isPagingRefNotFound()) return;
	paging.value.pageReachBottom();
});

const queryList = (pageNo, pageSize) => {
	const params = {
		current: pageNo,
		pageSize: pageSize
	};

	userExtractList(params)
		.then((res) => {
			paging.value.complete(res);
		})
		.catch((res) => {
			paging.value.complete(false);
		});
};
</script>

<style scoped lang="scss">
.wallet_pall {
	width: 690rpx;
	height: 272rpx;
	border-radius: 16rpx 16rpx 16rpx 16rpx;
	padding: 40rpx;
	background: #ffffff;
	&_header {
		font-weight: bold;
		font-size: 26rpx;
		color: #002ea4;
	}
	&_ye {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 70%;
		view:nth-child(1) {
			font-weight: bold;
			font-size: 68rpx;
			color: #002ea4;
		}
		view:nth-child(2) {
			width: 128rpx;
			height: 58rpx;
			background: rgba(0, 46, 164, 0.07);
			border-radius: 32rpx 32rpx 32rpx 32rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 26rpx;
			color: #002ea4;
		}
	}
}

.wallet_list {
	width: 690rpx;
	background: #ffffff;
	border-radius: 8rpx 8rpx 8rpx 8rpx;
	padding: 15rpx 30rpx;
	@include flex($space: space-between);
	&_left {
		// view:nth-child(1) {
		// 	font-weight: bold;
		// 	font-size: 28rpx;
		// 	color: #232323;
		// 	margin-bottom: 10rpx;
		// }
		// view:nth-child(2) {
		// 	font-size: 24rpx;
		// 	color: #232323;
		// }
		view {
			font-size: 28rpx;
			color: #232323;
			margin-bottom: 10rpx;
		}
	}
	&_right {
		font-weight: bold;
		font-size: 28rpx;
		color: #ff2727;
	}
}
</style>
