<template>
	<view class="Pay_success">
		<view class="successbox">
			<image v-show="flag" src="../../../static/images/success.png" mode=""></image>
			<view class="title">
				签约 <text>{{text}}</text>
			</view>
			<view class="content" v-show="flag">
				<view class="bd">
					<view class="">订单编号</view> <text>{{orderNo}}</text>
				</view>
				<!-- <view class="bd">
					<view class="">下单时间</view> <text>{{shopobj.date}}</text>
				</view> -->
				<view class="bd">
					<view class="">支付方式</view> <text>分期支付</text>
				</view>
				<!-- <view class="bd">
					<view class="">支付金额</view> <text>{{shopobj.shopmey}}</text>
				</view> -->
				<text class="text" v-show="flag">恭喜签约成功,您的宝贝将在一小时内发货</text>
			</view>
			<view class="" v-show="flag">
				<navigator url="../../../pages/users/order_list/index" class="ckdj">查看订单</navigator>
				<navigator url="../../../pages/index/index" open-type="switchTab" class="fhsy">返回首页</navigator>
			</view>
		</view>

		<!-- 加载logo -->
		<view class="logobox" v-show="logoflag">
			<image class="logoicon" src="../../../static/img/logo.png"></image>
			<text>正在签约中，请稍等...</text>
		</view>

	</view>
</template>

<script>
	import {
		getqianyue
	} from '@/api/order.js'
	export default {
		data() {
			return {
				shopobj: {},
				orderNo: '',
				id: '',
				signStatus: '', //签约状态
				flag: false,
				text: '失败',
				logoflag: true,
			}
		},
		onLoad(option) {
			this.orderNo = this.$Cache.get('qyids')
			// console.log(this.id)
			// this.orderNo = option.orderId
			// this.shopobj = JSON.parse(option.shopobj)
			this.getnews(this.orderNo)
			this.logoflag = true
			
			this.timer = setInterval(() => {
				this.getnews()
			}, 1000);
		},
		onShow() {
		  
		},
		methods: {
			getnews(orderNo) {
				getqianyue(orderNo).then(res => {
					console.log(res)
					this.signStatus = res.data.signStatus
					if (this.signStatus == 2) {
						this.flag = true
						this.text = '成功'
						this.logoflag = false
					}
				})
			},
		},
		onReady() {

		},
		onUnload() {
			// 在页面卸载时清除定时器  
			clearInterval(this.timer);
		}
	}
</script>

<style lang="less">
	page {
		position: relative;
	}

	.logobox {
		width: 100%;
		height: 100vh;
		background-color: red;
		position: fixed;
		top: 0;
		left: 0;
		opacity: 1;
		padding-top: 30%;
		box-sizing: border-box;
		background-color: #000;
		text-align: center;
		z-index: 1;
	}

	.logobox text {
		display: block;
		color: #fff;
		font-size: 14px;
		z-index: 999;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translateX(-50%);
	}

	.logoicon {
		width: 80rpx;
		height: 140rpx;
		z-index: 99;
		position: absolute;
		top: 38%;
		left: 50%;
		transform: translateX(-50%);
	}

	.Pay_success {
		width: 100%;
		margin-top: 200rpx;
		background-color: #fff;
		padding-bottom: 80rpx;
		height: 100vh;

		.successbox {
			position: relative;
			width: 100%;
			box-sizing: border-box;
			padding: 0 40rpx;

			image {
				position: absolute;
				top: -65rpx;
				left: 50%;
				transform: translateX(-50%);
				width: 138rpx;
				height: 138rpx;
			}

			.title {
				width: 100%;
				text-align: center;
				padding-top: 100rpx;
				box-sizing: border-box;
				font-weight: 700;
				line-height: 120rpx;
				border-bottom: 1px solid #ccc;
			}

			.content {
				.bd {
					display: flex;
					width: 100%;
					justify-content: space-between;
					margin-top: 20rpx;

					text {
						color: #666;
					}
				}

				.text {
					display: block;
					color: #666;
					margin-top: 40rpx;
				}
			}

			.ckdj {
				width: 100%;
				height: 84rpx;
				border: 1px solid #ccc;
				border-radius: 50rpx;
				line-height: 84rpx;
				text-align: center;
				margin-top: 50rpx;
				background-color: #42ca4d;
				color: #fff;
			}

			.fhsy {
				width: 100%;
				height: 84rpx;
				border: 1px solid #ccc;
				border-radius: 50rpx;
				line-height: 84rpx;
				text-align: center;
				margin-top: 50rpx;
			}
		}
	}
</style>