<!-- 支付成功即将返回首页 -->
<template>
	<view class="content">
		<view class="c-top">
			<view class="" @click="getback()">
				<uni-icons type="left" size="18"></uni-icons>
			</view>
			<view class="c-title">{{titles}}</view>
			<view class=""></view>
		</view>
		<view class="dqiu">
			<view class="">
				<uni-icons type="checkmarkempty" size="36" color="#ffffff"></uni-icons>
			</view>

		</view>
		<view class="top-title">
			<view>{{titles}}</view>
			<p>{{ countdown }}秒后自动返回</p>
			<p style="font-size: 16px;margin-top: 10px;">稍后会有预约短信发送至您的手机</p>
		</view>
		<view class="lananniu" @click="afterCountdown()">
			<view class="">返回首页</view>
		</view>
	</view>
</template>

<script>
	import config from '@/config'
	import request from '../../utils/request';

	export default {
		data() {
			return {
				countdown: 3,
				titles: '下单成功'
			}
		},
		onLoad(option) {
			console.log("option", option);
			if (option.type == "xd") {
				this.titles = "下单成功"
			} else {
				this.titles = "支付成功"
			}
		},
		mounted() {
			this.startCountdown()
		},
		methods: {
			startCountdown() {
				const timer = setInterval(() => {
					this.countdown--;
					if (this.countdown === 0) {
						clearInterval(timer);
						// 倒计时结束后执行你希望执行的方法
						this.afterCountdown();
					}
				}, 1000);
			},
			afterCountdown() {
				// 在这里写你希望执行的方法
				console.log("倒计时结束，执行方法");
				uni.reLaunch({
					url: '/pages/detection/detection'
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		width: 100%;
		height: calc(100vh);
		background-color: #F6F6F6;
		box-sizing: border-box;

	}

	.c-top {
		width: 100%;
		box-sizing: border-box;
		padding: 15px;
		padding-top: 55px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: white;
	}

	.dqiu {
		width: 80px;
		height: 80px;
		border-radius: 50%;
		margin: 0px auto;
		margin-top: 60px;
		margin-bottom: 20px;
		background: #0D2E8D;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.top-title {
		width: 100%;
		text-align: center;
		font-size: 24px;
		font-weight: bold;
	}

	.lananniu {
		width: 90%;
		height: 40px;
		margin: 10px auto;
		display: flex;
		justify-content: center;
		align-items: center;
		color: white;
		background-color: #0D2E8D;
		border-radius: 50px;
		margin-top: 60px;

	}
</style>