<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">{{orderInfo['storeName']||''}}-{{mealType[orderInfo['mealType']]}}</view>
				<view class="amount">-{{itemAmount(orderInfo['amount']||0)}}</view>
				<!-- 订单状态 -->
				<view class="status" v-if="orderInfo['status']==0||orderInfo['status']==1">
					{{['待支付','已支付'][orderInfo['status']]}}
				</view>
				<view class="rowItem" style="margin-top: 92rpx;">
					<view class="label">学生姓名</view>
					<view class="value">{{orderInfo['userName']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">年级班级</view>
					<view class="value">{{orderInfo['gradeName']||''}}/{{orderInfo['className']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">手续费</view>
					<view class="value"> {{orderInfo['serviceFee']||'0.00'}}</view>
				</view>
				<view class="rowItem">
					<view class="label">消费设备</view>
					<view class="value"> {{orderInfo['deviceName']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">消费场景</view>
					<view class="value"> {{orderInfo['consumeScene']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">消费时间</view>
					<view class="value">{{orderInfo['dealTime']||''}}</view>
				</view>
				<view class="rowItem">
					<view class="label">交易订单号</view>
					<view class="value">{{orderInfo['platflowNo']||''}}</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: '异常订单'
				},
				orderInfo: {
					accountId: '', //	integer刷脸用户账户id，该id为绑定用户id
					amount: '', //	integer消费金额 单位分
					dealTime: '', //	string消费时间(刷脸时间)
					debt: '', //	integer是否垫资 1支付宝垫资 0未垫资
					devflowNo: '', //	string终端消费流水号
					mealType: 1, //	integer餐别：1早餐,2中餐,3晚餐,4夜宵,5夜夜宵
					payTime: '', //	string支付时间
					payType: '', //	integer消费类型 1.刷卡 2.刷脸
					platflowNo: '', //	string平台交易流水(订单编号)
					respMsg: '', //	string响应描述 (欠款原因)
					schoolName: '', //	string学校名称
					status: '', //	integer订单状态 0待扣款 1已付款 2已撤销 3已退款 4异常订单
					storeName: '', //	string食堂档口名称
					tradeNo: '', //	string支付宝订单号(支付宝流水号)
					userName: '', //	string用户姓名
					gradeName: '', //年级
					className: '', //班级
					serviceFee: '', //服务费(手续费)  格式0.02
					deviceName: '', //消费设备
					consumeScene: '' //消费场景
				}
			}
		},
		onLoad(options) {
			this.OrderDetail(options['devflowNo'] || '');
		},
		computed: {
			itemAmount() {
				return function(Amount) {
					if (Amount) {
						return (Amount / 100).toFixed(2)
					} else {
						return "0.00"
					}
				}
			},
		},
		methods: {
			// 订单详情
			async OrderDetail(devflowNo) {
				const data = await requestPost('/cgi-xpay/app/h5/OrderDetail', {
					devflowNo
				})
				if (data['code'] != 200) {
					await Dialog({
						title: '温馨提示',
						message: data['message'],
						confirmButtonText: "知道了"
					})
					return
				}
				this.orderInfo = data.data['data'] || {}
			},
			// 跳转页面
			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>