<template>
	<view>
		<uni-nav-bar  left-icon="left" :statusBar="true"  title="Flash Sale" 
		color="#000000" rightIcon="info" @clickLeft="back" @clickRight="isDelete=!isDelete" :border="false"/>
		
		<view class="body">
			<view class="countDown">
				<text>Ends in</text>
				<uni-countdown :showDay="false" :hour="curEndTime |hours" :minute="curEndTime|minutes" :second="curEndTime|seconds"  
				color="#FFFFFF" background-color="#1B1B1B" class="countDown_assembly" />
			</view>
			<view class="tips">
				Chic selects commodities from time to time to carry
				 out special price activities. 
			</view>
			<view class="tips1">The quantity of special price commodities is limited and will be sold out</view>
			<view class="recommend">
				<view class="recommend_content">
					<view class="recommend_content_item" v-for="(item,index) in list " :key="index" @click="goDetails(item.id)">
						<view class="recommend_content_item_image">
							<image :src="item.goods_img" mode=""></image>
						</view>
						<view class="recommend_content_item_name">{{item.name}}</view>
						<view class="recommend_item_operation">
							<view>
								<view class="recommend_content_item_pric">US${{item.promote_price?item.promote_price:item.shop_price}}</view>
								<view class="recommend_content_item_pric1">US${{item.shop_price}}</view>
							</view>
							<image src="../../static/img/add.png" mode=""></image>
						</view>
						
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {defaultRequest} from '../../api/index.js'
	export default {
		data() {
			return {
				list:[]
			}
		},
		computed:{
			//当天结束时间
			curEndTime(){
				const endtime = new Date(new Date().setHours(23,59,59,999)).getTime()
				 // 获取当前时间
				const nowtime=(new Date()).getTime();
				var date3 = nowtime - endtime;   //时间差的毫秒数      
				date3 = Math.abs(date3)
			  return date3;
			}
		},
		filters:{
			hours (timestamp){
				var leave1=timestamp%(24*3600*1000)    //计算天数后剩余的毫秒数
				var hours=Math.floor(leave1/(3600*1000))
				return hours
			},
			minutes(timestamp){
				var leave2=(timestamp%(24*3600*1000))%(3600*1000)        //计算小时数后剩余的毫秒数
				var minutes=Math.floor(leave2/(60*1000))
				return minutes
			},
			seconds(timestamp){
				var leave3=((timestamp%(24*3600*1000))%(3600*1000))%(60*1000)      //计算分钟数后剩余的毫秒数
				var seconds=Math.round(leave3/1000)
				return seconds
			}
			
		},
		methods:{
			goDetails(id){
				uni.navigateTo({
					url:"../productDetails/index?goods_id="+id
				})
			},
			getList(){
				let data ={_action:'getseckillgoods',gid:'213'}
				defaultRequest(data).then(res=>{
					console.info(res)
					if(res.error==0){
						this.list=res.data
					}
				})
			},
			back(){
				uni.navigateBack()
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.uni-navbar{
		font-size: 32rpx;
		font-weight: bold;
	}
	.body{
		border-top: 13.33rpx #F7F7F7 solid;
		padding:0 26rpx;
		padding-top: 34rpx;
	}
	.recommend{
		padding: 0;
		
		.recommend_item_operation{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 10rpx;
			.recommend_content_item_pric{
				color: #B22234;
				font-weight: 600;
				font-size: 32rpx;
				margin-top: 0;
			}
			.recommend_content_item_pric1{
				font-size: 24rpx;
				color: #666666;
				text-decoration: line-through;
			}
			image{
				width: 58.67rpx;
				height: 58.67rpx;
			}
		}
	}
	.recommend_content_item_name{
		overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2; /* 限制在一个块元素显示的文本的行数 */
		-webkit-box-orient: vertical; /* 垂直排列 */
		word-break: break-all;  /* 内容自动换行 */
	}
	.countDown{
		display: flex;
		align-items: center;
		font-size: 41.33rpx;
		justify-content: center;
		margin-bottom: 34rpx;
		
		.countDown_assembly{
			margin-left: 12.67rpx;
		}
		
	}
	.tips{
		width: 572.67rpx;
		margin: 0 auto;
		font-size: 24rpx;
		margin-bottom: 14rpx;
		text-align: center;
	}
	.tips1{
		font-size: 20rpx;
		color: #666666;
		margin-bottom: 30rpx;
		text-align: center;
	}
</style>