<template>
	<view class="lotterylist_wrapper">
		<view class="lotterylist" v-if="lotteryList.length>0">
			<view class="item" v-for="(item,index) in lotteryList" :key="index" @tap="goPage(item)">
				<image class="image" :src="$util.img(item.images)" mode=""></image>
				<view class="item_info">
					<view class="item_title">
						{{item.title||'-'}}
					</view>
					<view class="">
						<view class="item_time">
							开始时间：{{item.start_time||'-'}}
						</view>
						<view class="item_time">
							结束时间：{{item.end_time||'-'}}
						</view>
					</view>

				</view>
			</view>

		</view>

		<view v-else-if="lotteryList.length==0">
			<ns-empty text="暂无抽奖活动"></ns-empty>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lotteryList: []
			};
		},
		onShow() {
			this.getDrawLlist()
		},
		methods: {
			// 获取抽奖活动列表
			getDrawLlist() {
				this.$api.sendRequest({
					url: '/api/draw/getDrawList',
					data: {
						page: 1,
						page_size: 1000,
					},
					success: ({ data }) => {
						this.lotteryList = data.list;
					}
				});
			},
			goPage(item) {
				console.log(item);
				// let newTime = new Date().getTime() / 1000
				// let start_time = this.$util.timeTurnTimeStamp(item.start_time)
				// let end_time = this.$util.timeTurnTimeStamp(item.end_time)
				// if (newTime >= start_time && newTime < end_time) {
				this.$util.redirectTo('/pages_tool/lottery/lottery', { draw_id: item.id });
				// } else {
				// 	this.$refs.uToast.show({
				// 		type: 'default',
				// 		message: "未在活动时间内",
				// 	})
				// }

			}
		}
	}
</script>

<style lang="scss" scoped>
	.lotterylist_wrapper {
		width: calc(100vw - 60rpx);
		// height: 100vh;
		margin: 30rpx auto;

		.lotterylist {
			width: 100%;
			height: 100%;

			.item {
				width: 100%;
				height: 300rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				box-shadow: 0rpx 0rpx 18rpx 0rpx rgba(163, 163, 163, 0.25);
				margin-bottom: 30rpx;
				display: flex;

				.image {
					width: 240rpx;
					height: 240rpx;
					margin: 30rpx 20rpx;
					border-radius: 20rpx 20rpx 20rpx 20rpx;
					background-size: 100% 100%;
				}

				.item_info {
					margin: 50rpx;
					margin-left: 0;

					.item_title {
						font-size: 32rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
						margin-bottom: 60rpx
					}

					.item_time {

						font-size: 24rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}
				}
			}
		}
	}
</style>