<template>
	<view class="earnings p30">
		<z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
			<view style="margin-bottom: 30rpx" class="mt30 wallet_list" v-for="(item, index) in dataList" :key="index">
				<view class="wallet_list_left">
					<view>{{ item.recordName || '-' }}</view>
					<view>{{ item.createTime }}</view>
				</view>
				<view class="wallet_list_right" style="display: flex; flex-direction: column; align-items: flex-end">
					<!-- 					<view style="margin-bottom: 10rpx; width: 75rpx">
						<view></view>
						<up-tag v-if="item.pointType == 2" size="mini" text="余额" type="warning" plain plainFill></up-tag>
						<up-tag v-if="item.pointType == 1" size="mini" text="收益" plain plainFill></up-tag>
					</view> -->
					<view>{{ item.amount }}元</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

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

let id = ref('');

const changeSele = (e) => {
	paging.value.reload();
};

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

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

onLoad((options) => {
	id.value = options.id;
});

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,
		id: id.value
	};

	userCardRecord(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;
	// height: 120rpx;
	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:nth-child(3) {
			font-size: 24rpx;
			color: #232323;
		}
		view:nth-child(4) {
			font-size: 24rpx;
			color: #232323;
		}
	}
	&_right {
		font-weight: bold;
		font-size: 28rpx;
		color: #ff2727;
	}
}
</style>
