<template>
<view class="success">
	<img src="@/static/img/su2.jpg" v-if="type == 1" ref="img">
	<img src="@/static/img/su.jpg" v-else>
	<text class="name" :style="{top: -height*1.15+'rpx'}">{{ list.name }}</text>
	<text class="id" :style="{top: -height*1.92+'rpx'}">{{ list.id }}</text>
	<text class="time" :style="{top: -height*0.55+'rpx'}">{{ getTime(list.valid_time) }}</text>
</view>
</template>

<script>
	export default {
		mounted() {
			this.height = this.$refs.img.height
		},
		data() {
			return {
				height: '',
				type: 1,
				list: {
					id: "9",
					type: "2",
					name: "京",
					idcard: "怀疑自己",
					phone: "快递积极",
					province: "安徽省",
					city: "铜陵市",
					area: "郊区",
					detail_address: "古茗",
					job: "李静",
					job_year: "1",
					uid: "33776",
					saver: "刺激感了",
					logo: "/Uploads/Picture/2021-11-17/6194a421bb357.jpg",
					add_time: "1637131806",
					status: "1",
					paid: "1",
					valid_time: "1668673114",
					check_time: "1637137114",
					pay_time: "1637131815",
					pay_money: "0.01",
					order_id: "20211117101575758703",
					grade: "1",
					grade_info: {
						id: "3",
						type: "2",
						year: "3",
						name: "3年企业会员",
						grade: "1",
						price: "0.01"
					}
				}
			}
		},
		methods: {
			//时间戳转换成时间
			getTime(time) {
				const num =13 - (time+'').length;
				let l = 1;//倍数
				for (let i = 0; i < num; i++) {
					l+='0';
				}
				// 重新解析为数字
				l = parseInt(l)
				const date = new Date(parseInt(time) * l);
				const year = date.getFullYear();
				const mon = date.getMonth() + 1;
				const day = date.getDate();
				const hours = date.getHours();
				const minu = date.getMinutes();
				const sec = date.getSeconds();
				return year + '-' + mon + '-' + day 
				// + ' ' + hours + ':' + minu + ':' + sec;
			}
		}
	}
</script>

<style>
img {
	width: 100%;
	height: 507px;
}
.name {
	position: relative;
	left: 35%;
}
.id {
	position: relative;
	left: 70%;
}
.time {
	position: relative;
	left: 25%;
}
</style>
