<template>
	<view class="topupDetail">
		<view class="firstLine">
			<view class="left" @click="show = true">
				<view>{{currentDate}}</view>
				<view class="arrowImg" :style="'background-image: url('+ImgUrl + 'user/arrowDown.png'+')'"></view>
			</view>
			<view class="right">
				<view class="font28">¥</view>
				<view class="font40"> 40.00</view>
			</view>
		</view>
		<scroll-view scroll-y="true" class="scrollY">
			<view class="pannels">
				<view class="item">
					<view class="p1">
						<view>线下充值</view>
						<view class="num">10.00</view>
					</view>
					<view class="p2">08-09 08:02:01</view>
				</view>
				<view class="item">
					<view class="p1">
						<view>线下充值</view>
						<view class="num">10.00</view>
					</view>
					<view class="p2">08-09 08:02:01</view>
				</view>
				<view class="item">
					<view class="p1">
						<view>线下充值</view>
						<view class="num">10.00</view>
					</view>
					<view class="p2">08-09 08:02:01</view>
				</view>
			</view>
			<view class="bottomTip">— 已展示全部数据 —</view>
			<view class="popup" v-if="show">
				<van-datetime-picker :value="currentDate" type="year-month" title="选择年月" :min-date="minDate"
					position="bottom" :max-date="maxDate" :formatter="formatter" @confirm="onConfirm" @cancel="onCancel"
					 />
			</view>
		</scroll-view>

	</view>
</template>

<script>
	import moment from "moment";
	import {
		DatetimePicker
	} from 'vant';
	export default {
		data() {
			return {
				ImgUrl: this.$ImgUrl,
				minDate: new Date(2022, 10, 0),
				maxDate: new Date(2999, 10, 1),
				currentDate: '',
				show: false,
			}
		},
		created() {
			this.currentDate = moment(new Date()).format('YYYY年M月');
		},
		methods: {
			formatter(type, val) {
				if (type === 'year') {
					return `${val}年`;
				} else if (type === 'month') {
					return `${val}月`;
				}
				return val;
			},
			onConfirm(val) {
				this.currentDate = moment(val).format('YYYY年M月')
				this.show = false
			},
			onCancel() {
				this.show = false
			}
		}
	}
</script>

<style lang="scss">
	.topupDetail {
		width: 100%;
		height: 100%;
		min-height: calc(100vh - calc(44px + env(safe-area-inset-top)));
		background: #F1F1F3;
		font-family: PingFangSC-Regular, PingFang SC;

		.firstLine {
			display: inline-flex;
			justify-content: space-between;
			height: 88rpx;
			line-height: 88rpx;
			width: calc(100% - 130rpx);
			padding: 0 38rpx 0 92rpx;
			background: #FFFFFF;
			border-top: 1rpx solid #E5E5E5;
			border-bottom: 1rpx solid #E5E5E5;
			font-size: 30rpx;
			color: #333333;

			.left,
			.right {
				display: inline-flex;
				height: 100%;

				view {
					align-self: center;
				}

				.arrowImg {
					margin-left: 12rpx;
					width: 17rpx;
					height: 11rpx;
					background-size: cover;
					background-position: center center;
				}

				.font28 {
					font-size: 28rpx;
				}

				.font40 {
					font-size: 40rpx;
					margin-left: 15rpx;
				}
			}
		}

		.scrollY {
			position: fixed;
			height: calc(100vh - 91rpx - calc(44px + env(safe-area-inset-top)));
			bottom: 0;
			left: 0;
			right: 0;
		}
		.popup {
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
		}
		.pannels {
			width: 100%;

			background-color: white;
			display: flex;
			flex-direction: column;

			.item {
				margin-left: 32rpx;
				width: calc(100% - 32rpx);
				border-bottom: 1px solid #E5E5E5;
				display: flex;
				flex-direction: column;

				.p1 {
					margin-top: 26rpx;
					margin-bottom: 6rpx;
					width: calc(100% - 40rpx);
					height: 45rpx;
					line-height: 45rpx;
					display: flex;
					justify-content: space-between;
					color: #333333;
					font-size: 32rpx;
					padding-right: 40rpx;

					.num {
						color: #E02020;
					}
				}

				.p2 {
					width: calc(100% - 40rpx);
					height: 37rpx;
					font-size: 26rpx;
					color: rgba(0, 0, 0, 0.35);
					line-height: 37rpx;
					padding-right: 40rpx;
					margin-bottom: 24rpx;
				}
			}
		}

		.bottomTip {
			margin-top: 32rpx;
			padding-bottom: 32rpx;
			width: 100%;
			height: 33rpx;
			font-size: 24rpx;
			color: rgba(0, 0, 0, 0.25);
			line-height: 33rpx;
			text-align: center;
		}
	}
</style>