<template>
	<div>
		<common-merchant ref="common" @asynCallBack="asynCallBack"></common-merchant>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content vongi-car-dj">
			<div class="vongi-car-banner flew-sp flew-items">
				<div class="flew-items">
					<img class="mui-media-object" src="~$project/assets/img/antFill-car.png">
					<div class="mui-media-body ">
						车牌号码
						<p class='mui-h2' v-text="detail.carNumber"></p>
					</div>
				</div>
				<div>
					<button class="mui-btn mui-btn-outlined" @click="goToSearch">修改</button>
				</div>
			</div>
			<div class="vongi-car-over">
				<h1>- 停车中 -</h1>
				<div class="vongi-car-over-line"></div>
				<h4>协议商户：{{detail.merchantName}}</h4>
				<h4>停车位置：{{detail.parkingName}}</h4>
				<h4>入场时间：{{detail.inParkingTime}}</h4>
				<h4>已停时长：{{detail.parkingTime}}</h4>
			</div>
			<div class="vongi-car-juan flew-items">
				<div class="car-juan">
					<h2>￥<span class="mui-h1" v-text="detail.discountMoney"></span></h2>
					<h6>抵用券</h6>
				</div>
				<div class="car-juan-text">
					<h4 class="mui-ellipsis">[停车]{{detail.discountMoney}}元停车抵用券</h4>
					<p class="colorf8b155">仅限 {{today}} 当日有效</p>
					<p>本抵用券无法叠加使用</p>
				</div>
			</div>
		</div>
		<div class="fyy-footer">
			<div class="bindfyy-btn">
				<button type="button" @click="sure" class="mui-btn mui-btn-primary ">确认赠送</button>
			</div>
		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_Merchant from '@/apis/merchant'
	import CommonMerchant from '@/components/CommonMerchant.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	import {
		currentTimeStamp,
		parseUnixTime
	} from '$project/utils'
	export default {
		name: 'MerchantCheckSearchResult',
		components: {
			CommonMerchant,
			Loading,
			TopHeader,
		},
		data() {
			return {
				isLoading: false,

				pageTitle: '车牌登记',

				detail: {},

				sureForm: {
					carNumber: '',
					id: '',
				},
				today: '',
			}
		},
		created() {
			this.detail = this.$route.params.detail;
			this.sureForm.carNumber = this.detail.carNumber;
			this.sureForm.id = this.detail.id;

			this.today = parseUnixTime(currentTimeStamp(), '{y}.{m}.{d}');
		},
		methods: {
			//确认赠送
			sure() {
				var _this = this;
				var btnArray = ['否', '是'];
				mui.confirm('是否确认赠送？', '提示', btnArray, function(e) {
					if (e.index == 1) {
						_this.sendTicket();
					}
				})
			},
			sendTicket() {
				this.isLoading = true;
				API_Merchant.giveDiscountTicket(this.sureForm).then(response => {

					this.isLoading = false;

					this.$router.push({
						name: 'MerchantCheckResult'
					})
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//返回修改
			goToSearch() {
				this.$router.go(-1);
			},
			asynCallBack() {},
		},
		mounted() {},
		destroyed() {

		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
