<template>
	<view class="box">
		<view class="itemHistory" v-for="(item,index) in itemData" :key="index" @click="goDetail(item.ID)">

			<view class="carPlate">
				<view class="time">{{item.BillDate}}</view>
				<view class="mileage" v-if="item.SheetState == 0" style="color: #F03B3B">待确认</view>
				<view class="mileage" v-if="item.SheetState == 1" style="color: #3F90F7">预约中</view>
				<view class="mileage" v-if="item.SheetState == 2" style="color: #00A040;">已到店</view>
				<view class="mileage" v-if="item.SheetState == 3">已取消</view>
			</view>

			<view class="plate">{{item.PlateNumber}}</view>

			<view class="shopName">{{item.ShopName}}</view>

			<view class="itemN">
				<view class="itemContent" v-if="item.OrderItem.length != 0">{{item.OrderItem}}</view>
			</view>


		</view>

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

	</view>
</template>

<script>
	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: 'bespeakDetail?id=' + id
				})
			},
			myOrderCoupon() {
				uni.showLoading({
					title: '加载中'
				})
				this.$http('openreservation/listOrderSheet', {

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

					// 处理 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>
	.box {
		min-height: 100vh;
		background-color: #F4F5F7;
		padding-top: 20rpx;
	}

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

	}

	.time {
		font-size: 24rpx;
		color: #999999;
	}

	.carPlate {
		margin-bottom: 20rpx;

		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.plate {
		font-size: 30rpx;
		color: #3C3C3C;
		font-weight: bold;
		margin-right: 20rpx;
	}

	.mileage {
		font-size: 24rpx;
		color: #999999;

	}

	.itemN {
		display: flex;

	}

	.shopName,
	.itemContent {
		color: #666666;
		font-size: 24rpx;
		margin: 15rpx 0rpx;
		/* 隐藏文字显示 ...不换行 */
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

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