<template>
	<view class="rechargeDetail">
		<view class="contentWrapper">
			<view class="wrapper">
				<view class="topBg" :style="'background-image: url('+this.$ImgUrl + 'user/greyBgTop.png'+')'">
					<view class="line"></view>
				</view>
				<view class="title">{{Record['optionName']||''}}</view>
				<view class="amount">{{itemAmount(Record['amount']||0)}}</view>
				<view class="rowItem" style="margin-top: 92rpx;">
					<view class="label">学生姓名</view>
					<view class="value">{{Record['userName']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">年级班级</view>
					<view class="value">{{Record['gradeName']||''}}/{{Record['className']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">服务费</view>
					<view class="value"> {{Record['serviceFee']||'0.00'}}</view>
				</view>
				<view class="rowItem">
					<view class="label">消费时间</view>
					<view class="value">{{Record['payTime']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">交易订单号</view>
					<view class="value">{{Record['outTradeNo']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">支付订单号</view>
					<view class="value">{{Record['tradeNo']||''}}</view>
				</view>
				<view class="btn" @click="goToPage(1)">
					<view class="button">对此订单有疑问？</view>
				</view>
			</view>
			<view class="bottomBg" :style="'background-image: url('+this.$ImgUrl + 'user/greyBgBottom.png'+')'"></view>
		</view>
	</view>
</template>

<script>
	import {
		Dialog,
		Toast
	} from 'vant';
	import config from '../common/config.js'
	import {
		requestGet,
		requestPost
	} from '../common/request.js'
	export default {
		data() {
			return {
				ImgUrl: this.$ImgUrl,
				mealType: {
					1: '早餐',
					2: '中餐',
					3: '晚餐',
					4: '夜宵',
					5: '夜夜宵'
				},
				status: {
					0: '待扣款',
					1: '已付款',
					2: '已撤销',
					3: '已退款',
					4: '异常订单'
				},
				Record: {
					amount: '', //	integer金额 单位分
					className: '', //	string班级
					gradeName: '', //	string年级
					id: 0, //	integer
					optionName: '', //	string操作名称 示例：线上充值
					outTradeNo: '', //	string交易订单号
					payTime: '', //	string消费时间
					serviceFee: '', //	string服务费 格式￥0.02
					tradeNo: '', //	string支付订单号
				}
			}
		},
		onLoad(options) {
			this.QueryRechargeRecord(options['month'] || '', options['id'] || '');
		},
		computed: {
			itemAmount() {
				return function(Amount) {
					if (Amount) {
						return (Amount / 100).toFixed(2)
					} else {
						return "0.00"
					}
				}
			},
		},
		methods: {
			// 充值明细列表
			async QueryRechargeRecord(month, id) {
				uni.showLoading({
					title: "请稍后",
					// #ifndef MP-ALIPAY
					mask: true,
					// #endif
				})
				await new Promise((res, rej) => {
					setTimeout(() => {
						res()
					}, 200);
				})
				const data = await requestPost('/cgi-xpay/app/h5/QueryRechargeRecord', {
					accountId: sessionStorage.getItem('accountId') * 1,
					month: month,
					id
				})
				uni.hideLoading()
				if (data['code'] != 200) {
					await Dialog({
						title: '温馨提示',
						message: data['message'],
						confirmButtonText: "知道了"
					})
					return
				}
				this.expenditure = data.data['expenditure'] || 0
				this.Record = Array(10).fill(1).map((v, index) => {
					return {
						amount: 100, //	integer金额 单位分
						className: '班级', //	string班级
						gradeName: '年级', //	string年级
						id: index + 1, //	integer
						optionName: '线上充值', //	string操作名称 示例：线上充值
						outTradeNo: '易订单号', //	string交易订单号
						payTime: '2023-09-10 08:22:56', //	string消费时间
						serviceFee: '0.02', //	string服务费 格式￥0.02
						tradeNo: '支付订单号', //	string支付订单号
					}
				})
			},
			// 跳转页面
			async goToPage(value) {
				switch (value) {
					case 1:
						uni.makePhoneCall({
							phoneNumber: '400-9656-210'
						})
						break;
					case 2:
						break;
					case 3:
						break;
					default:
						break;
				}
			},
		}
	}
</script>

<style lang="scss">
	.rechargeDetail {
		width: 100%;
		height: 100%;
		min-height: 100vh;
		background: #F1F1F3;

		.status {
			height: 45rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FA6400;
			line-height: 45rpx;
			text-align: center;
		}

		.contentWrapper {
			padding: 25rpx 22rpx 0 25rpx;
			display: flex;
			flex-direction: column;



			.wrapper {
				margin: 0 8rpx;
				padding-top: 59rpx;
				width: 686rpx;
				display: flex;
				flex-direction: column;
				background: white;
				font-family: PingFangSC-Regular, PingFang SC;
				position: relative;

				.topBg {
					position: absolute;
					top: 0;
					left: -8rpx;
					width: 703rpx;
					height: 59rpx;
					background-size: cover;
					background-position: center center;
					z-index: 1;

					.line {
						width: 686rpx;
						height: 22rpx;
						margin-top: 9rpx;
						margin-left: 8rpx;
						background: linear-gradient(180deg, #D9D9D9 0%, #FFFFFF 100%);
						opacity: 0.75;
					}
				}

				.title {
					margin-top: 78rpx;
					width: 100%;
					height: 42rpx;
					font-size: 30rpx;
					font-weight: 400;
					color: #333333;
					line-height: 42rpx;
					text-align: center;
				}

				.amount {
					margin-top: 4rpx;
					width: 100%;
					height: 90rpx;
					font-size: 64rpx;
					color: #333333;
					font-weight: 600;
					line-height: 90rpx;
					text-align: center;
				}

				.rowItem {
					padding: 0 32rpx;
					margin-bottom: 37rpx;
					display: inline-flex;
					justify-content: space-between;
					height: 42rpx;
					line-height: 42rpx;
					font-size: 30rpx;
					color: #333333;

					.label {
						height: 42rpx;
						font-size: 30rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 42rpx;
					}

					.value {
						color: rgba(0, 0, 0, 0.5);
					}
				}

				.btn {
					padding: 165rpx 0 35rpx;

					.button {
						margin: 0 auto;
						width: 622rpx;
						height: 71rpx;
						line-height: 71rpx;
						background: #F1F1F3;
						border-radius: 12rpx;
						text-align: center;
						font-size: 28rpx;
						color: rgba(0, 0, 0, 0.5);
					}
				}
			}

			.bottomBg {
				width: 686rpx;
				height: 29rpx;
				background-size: cover;
				background-position: center center;
				margin: 0 8rpx;
			}
		}
	}
</style>