<template>
	<div class="flex-grow-1">
		<div class="flex-grow-1 box-pack-between flex-y-center">
			<div class="flex-grow-0">
				<!-- {{rest_time}} -->
				<block>
					<div class='flex-y-center miaosha-time-item'>
						<div class="miaosha-time-item-name">{{miaosha_name}}</div>
						<view class="time flex">
								<div v-if="times.d" class='flex-y-center flex-x-center'>{{(times.d?times.d:"00")}}:
								</div>
								<div  class='flex-y-center flex-x-center'>{{(times.h?times.h:"00")}}: </div>
								<div class='flex-y-center flex-x-center'>{{(times.m?times.m:"00")}}:</div>
								<div class='flex-y-center flex-x-center'>{{(times.s?times.s:"00")}} </div>
						</view>
					</div>
				</block>
			</div>
			<div class="flex-y-center ft26 col" v-if='times.m && times.h' @click="navList">
				<span>更多</span>
				<text class="iconfont icon-jiantou" style="font-size: 26rpx;"></text>
			</div>
		</div>
	</div>
</template>

<script>
	import $util from '@/utils/util.js'
	let timer = '';
	export default {
		name: 'moduleMiaosha',
		props: {
			'miaosha': {
				type: Object,
			},
		},
		data() {
			return {
				times: {},
				miaosha_name: '活动已结束',
				dateTime: {},
			}
		},

		mounted() {
		},

		computed: {
			timers(val) {
				this.miaosha_name = this.miaosha.name;
				var rest_time = this.miaosha.rest_time;
				if (rest_time) {
					timer = setInterval(() => {
						rest_time = rest_time - 1;
						if (rest_time < 0) {
							clearInterval(timer)
							this.miaosha_name='活动已结束'
						}
						this.times = $util.setTimeList(rest_time)
					}, 1e3)
				}
			}
		},

		methods: {
			navList() {
				uni.navigateTo({
					url: "../../miaosha/index"
				})
			},
		}

	};
</script>

<style>
	.time {
		border: 1px solid #FF0000;
		border-left: 0;
		padding: 2px 6px;

		border-top-right-radius: 50px;
		border-bottom-right-radius: 50px;
	}

	.miaosha-time-item-name {
		background: #FF0000;
		color: #fff;
		padding: 2px 6px;
		height: 100%;
		border: 1px solid #FF0000;
		border-top-left-radius: 50px;
		border-bottom-left-radius: 50px;
	}

	.miaosha-time-item {
		color: #FF0000;

		padding: 0px 6px 0px 0px;
		overflow: hidden;
		margin-left: 20px;
		font-size: 14px;
	}

	.flex {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
	}

	.flex-row {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-orient: horizontal;
		-webkit-flex-direction: row;
		flex-direction: row;
	}

	.flex-col {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-orient: vertical;
		-webkit-flex-direction: column;
		flex-direction: column;
	}

	.flex-grow-0 {
		min-width: 0;
		-webkit-box-flex: 0;
		-webkit-flex-grow: 0;
		-ms-flex-positive: 0;
		flex-grow: 0;
		-webkit-flex-shrink: 0;
		-ms-flex-negative: 0;
		flex-shrink: 0;
	}

	.flex-grow-1 {
		min-width: 0;
		-webkit-box-flex: 1;
		-webkit-flex-grow: 1;
		-ms-flex-positive: 1;
		flex-grow: 1;
		-webkit-flex-shrink: 1;
		-ms-flex-negative: 1;
		flex-shrink: 1;
	}

	.flex-x-center {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-pack: center;
		-webkit-justify-content: center;
		-ms-flex-pack: center;
		justify-content: center;
	}

	.flex-y-center {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		-ms-flex-align: center;
		-ms-grid-row-align: center;
		align-items: center;
	}

	.col {
		color: #999
	}
</style>
