<template>
	<view class="box">

		<view class="itemHistory" v-for="(item,index) in itemData" :key="index" @click="goDetail(item.id)">
			<image :src="item.Img" mode="" class="itemImg"></image>
			<view class="timeBox">
				<!-- <image v-if="item.state==2" src="../../static/img/bg_huangse.png" mode="" class="state"></image> -->
				<!-- <image v-if="item.state==1" src="../../static/img/bg_hongse.png" mode="" class="state"></image> -->
				<view class="time" v-if="item.StartTime">{{item.StartTime.slice(0,10)}}-{{item.EndTime.slice(0,10)}}</view>
			</view>
			<view class="name">{{item.ActivityName}}</view>
			
			<view class="name" @click="goEdit(item.id)">编辑</view>
		</view>

		<!-- 上拉 加载更多 -->
		<view class="noMore" v-if="noMoreShow && (itemData.length!=0)">没有更多数据</view>
		<!-- 无数据空白页 -->
		<nodata v-if="itemData.length==0"></nodata>


		
	</view>
</template>

<script scoped>
	import nodata from '../../components/nodata/nodata.vue'
	export default {
		components: {
			nodata,
		},

		data() {
			return {
				
				page: 1,
				itemData: [],
				noMoreShow: false,
				
			}
		},
		onLoad() {
			
			this.page = 1
			this.myOrderCoupon()
		},

		methods: {
			goDetail(id) {
				// uni.navigateTo({
				// 	url: 'jkDetail?id=' + id
				// })
			},
			goEdit(id) {
				// uni.navigateTo({
				// 	url: 'jkDetail?id=' + id
				// })
			},
			myOrderCoupon() {
				uni.showLoading({
					title: '加载中'
				})
				this.$http('openH5SetTheGuest/getAtivity', {

					page: this.page,
					limit: 10,
					 state:""
				}, 'GET').then(res => {
					uni.hideLoading();
					// var list = res.data.Items
					var list = res.data.Items

					// 处理 undefined和null转为空白字符串
					// list.forEach((item, index) => {
					// 	for (const key in item) {
					// 		item[key] = this.$praseStrEmpty(item[key])
					// 	}
					// })

					if (this.page == 1) {
						this.itemData = list
					} else {
						this.itemData = this.itemData.concat(list)
					}

					if (list.length < 10) {
						this.noMoreShow = true
					} else {
						this.noMoreShow = false
					}





				})
			},


		},

		// 下拉刷新 上拉加载更多
		onPullDownRefresh() {
			this.page = 1
			this.myOrderCoupon()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			this.myOrderCoupon()
		},
	}
</script>

<style scoped lang="less">
	.box {
		background: #F4F5F7;
		min-height: 100vh;
		padding-top: 20rpx;
	}

	

	.itemHistory {
		margin: 0rpx 24rpx 20rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;

	}

	.itemImg {
		height: 280rpx;
		width: 702rpx;
border-radius: 10rpx 10rpx 0px 0px;
	}

	.timeBox {
		display: flex;
		margin-top: -61rpx;
		align-items: flex-end;
	}
	.state{
		width: 102rpx;
		height: 53rpx;
	}

	.time {
		padding: 5rpx 10rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		background: #000000;

		border-radius: 0 10rpx 0 0;
	}

	.name {
		padding: 24rpx 20rpx;
		color: #333333;
		font-size: 28rpx;
		background: #FFFFFF;
		border-radius: 0 0 10rpx 10rpx;
	}


	.noMore {
		text-align: center;
		line-height: 50rpx;
		color: #999999;
		font-size: 28rpx;
	}
</style>
