<template>
	<view>
		<view class="container">
			<view class="banner-box"><image src="/static/imgs/banner-a.png" mode=""></image></view>
			<view class="main">
				<view class="tab-box">
					<view class="tab-item" style="width: 100%;" >理发预约记录</view>
				</view>
				<view >
					<view style="background-color: white;padding: 20upx 0upx;">
						<view  class="form-item searchv">
							<picker  style="width: 33%;float: left;" class="time " mode="date" @change="startDateChange">
								<view class="">{{ startDate }}</view>
							</picker>
							<text class="timecenter">至</text>
							<picker  style="width: 33%;float: right;" class="time " mode="date" @change="endDateChange">
								<view class="">{{ endDate }}</view>
							</picker>
							<!-- <view class="search" style="height: 60upx;font-size: 26upx;margin-top: 7upx;" @click="searchYjList">搜索</view> -->
							<!-- <image style="width: 5vh;height: 5vh;margin-left: 1vh;" @click="search" src="/static/icons/seach.png" mode=""></image>
								 -->
						</view>
						<view style="background-color: white;padding: 20upx 0px 0upx 5%;clear: both;">
							<text style="font-size: 28upx; color: #666666;">时段内预约总数：</text>
							<text style="font-size: 28upx;">{{count}}</text>
						</view>
					</view>
					
					<view class="list-box" v-if="appointlist.length > 0" style="margin-top: 14upx;">
						<view class="detail" v-for="(item, index) in appointlist" :key="index">
							<view class="detail_header">
								<text class="blueSign"></text>
								<text class="font-tilte">理发预约</text>
								<!-- <text class="slect_icon"></text> -->
								<!-- <text class="font-result">{{ item.status }}</text> -->
								<text class="font-result" v-if="item.int_status==0">预约成功</text>
								<text class="font-result" style="color: #666666;" v-if="item.int_status==1">已取消</text>
								<text class="font-result" style="color: red;" v-if="item.int_status==2">客户未至</text>
							</view>
							<view class="detail_msg">
								<view class="info-item">
									<text>预约人员：</text>
									<text class="infoSpan">{{ item.userName }}</text>
								</view>
								<view class="info-item">
									<text>预约时间：</text>
									<text class="infoSpan">{{ item.timeQ }}</text>
								</view>
								<view class="info-item">
									<text>地　　点：</text>
									<text class="infoSpan">{{ areas[item.barber_id||1]}}</text>
								</view>
								<view class="info-item">
									<text>申请时间：</text>
									<text class="infoSpan">{{ formatDate(item.apply_time) }}</text>
								</view>
							</view>
						</view>
					</view>
					<content-none :padTop="20" v-else></content-none>
				</view>
			</view>
		</view>
		<load-more  :loadingType="loadingType" :contentText="contentText"></load-more>
	</view>
</template>
<script>
import {getAllHaircutList} from '@/common/api.js';
import { callbackRequest, getStorage, getNumDate, alertTip, regPhone, formatDate } from '@/common/util.js';
import loadMore from '@/components/loadMore.vue';
import contentNone from '@/components/contentNone.vue';
export default {
	components: {
		loadMore,
		contentNone
	},
	data() {
		return {
			//分页
			page: 1,
			pageSize: 10,
			loadingType: 0, //0-loading前；1-loading中；2-没有更多了
			contentText: {
				contentdown: '上拉加载更多',
				contentrefresh: '正在加载...',
				contentnomore: '没有更多数据了'
			},
			user: getStorage('userInfo'),
			appointlist: [], 
			date: getNumDate(7), //获取今天起 最近7天时间
			formatDate: formatDate,
			startDate: this.getDay(-7),
			endDate: this.getDay(0),
			areas:['','会议中心','科技楼'],
			count:'',
		};
	},
	onLoad() {
		this.page = 1;
		this.loadingType = 0;
		this.getList();
	},
	onShow(){
		this.page = 1;
		this.loadingType = 0;
		this.getList();
	},
	methods: {
		getList() {
			// let lfDatas = uni.getStorageSync('lfDatas');
			// this.appointlist = lfDatas;
			let params = {
				method: getAllHaircutList,
				data: {
					pageNum: this.page,
					pageSize: this.pageSize,
					startDate:this.startDate,
					endDate:this.endDate,
					userId: this.user.id
				}
			};
			callbackRequest(params).then(res => {
				if (res.data.returnCode == 1) {
					if (this.page == 1) {
						this.appointlist = res.data.returnData.list || [];
						this.count = res.data.returnData.count||0;
					} else {
						if (res.data.returnData.length > 0) {
							this.appointlist = this.appointlist.concat(res.data.returnData.list);
							this.loadingType = 0;
						} else {
							this.loadingType = 2;
						}
					}
				}
			});
		},
		startDateChange: function(e) {
			this.startDate = e.target.value;
			this.page = 1;
			this.loadingType = 0;
			this.getList();
		},
		endDateChange: function(e) {
			this.endDate = e.target.value;
			this.page = 1;
			this.loadingType = 0;
			this.getList();
		},
		getDay(i) {
			var date1 = new Date(new Date().getTime()+i*24 * 60 * 60 * 1000);
			
			var year = date1.getFullYear();
			var month = date1.getMonth() + 1;
			if(month<10){
				month = "0"+month;
			}
			var day = date1.getDate();
			if(day<10){
				day = "0"+day;
			}
			return year + '-' + month + '-' + day;
		},
	},
	onReachBottom() {
		if (this.loadingType !== 0) {
			return;
		}
		this.loadingType = 1;
		this.page = this.page + 1;
		this.getList();
	},
};
</script>

<style lang="scss">
@import '@/static/css/common.scss';
@import url('../../static/css/haircut/haircut.css');
.searchv {
	text-align: center;
	width: 90%;
	height:78upx;
	margin-left:5%;
}
.jlsearch{
	width: 90%;margin-left: 5%;border: 1px solid #e5e5e5;color:#666;border-radius: 10upx;font-size: 28upx;padding: 20upx 20upx;
}
.timecenter {
	font-size: 26upx;
	margin-left: 10upx;
	margin-right: 10upx;
	margin-top: 20upx;
	height:78upx;
	line-height: 78upx;
}
.time {
	font-size: 28upx;
	display: inline-block;
	border: 1px solid #e5e5e5;
	border-radius: 10upx;
	color: #666;
	padding: 20upx;
}
page {
	background: #f8f8f8;
	font-size: 30upx;
}

.scroll-view {
	padding-top: 30upx;
	white-space: nowrap;
	width: 100%;
	height: 120upx;

	.time-item-box {
		padding: 0 10upx;
		margin: 0 16upx;
		display: inline-block;

		.time {
			display: block;
			width: 100%;
			font-size: 28upx;
			color: #666;
		}

		.week {
			display: block;
			width: 100%;
			font-size: 28upx;
			color: #666;
		}
	}

	.time-active {
		.time {
			color: #00c277;
		}

		.week {
			color: #00c277;
		}
	}
}

.detail {
	// margin-top: 10upx;
	margin-bottom: 14upx;
	background: #ffffff;
	border-radius: 4upx;
}

.detail_header {
	padding: 15upx 30upx;
	border-bottom: 1px solid #eee;
}

.detail_header .blueSign {
	height: 30upx;
	width: 10upx;
	background: #00c277;
	display: inline-block;
	margin: 10upx 14upx 0 0;
}

.detail_header .font-tilte {
	display: inline-block;
	font-size: 28upx;
	color: #333;
	line-height: 50upx;
	vertical-align: top;
}

.detail_header .font-result {
	display: inline-block;
	float: right;
	font-size: 26upx;
	color: #00c277;
	line-height: 50upx;
	vertical-align: top;
}

.detail_msg {
	padding: 20upx 30upx;
	overflow: hidden;
}

.detail_msg .info-item {
	margin-bottom: 10upx;
	font-size: 28upx;

	text {
		display: inline-block;
		width: 140upx;
	}

	.infoSpan {
		width: auto;
		font-size: 28upx;
		color: #666;
		float: right;
	}
}

.comment-btn {
	float: right;
	font-size: 24upx;
	border-radius: 10upx;
	color: #fff;
	line-height: 50upx;
	text-align: center;
	min-width: 140upx;
	background-color: #00c277;
}

.container {
	position: relative;
	overflow: hidden;

	.banner-box {
		width: 100%;
		height: 240upx;
		position: absolute;
		top: 0;
		left: 0;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.main {
		margin: 172upx 40upx 0;
		position: relative;
		z-index: 10;

		.tab-box {
			overflow: hidden;
			border-radius: 10upx 10upx 0 0;
			background: rgba(132, 149, 167, 0.8);
			height: 70upx;

			.tab-item {
				float: left;
				height: 70upx;
				width: 50%;
				font-size: 30upx;
				color: #e5f6ff;
				text-align: center;
				line-height: 70upx;
			}

			.active_tab {
				background: #fff;
				color: #333;
				border-radius: 10upx 10upx 0 0;
				font-weight: bold;
			}
		}

		.form-box {
			// padding: 20upx 30upx 50upx;
			background: #fff;
			.time-box {
				overflow: hidden;
				padding-top: 20rpx;
				.bg-gray {
					background-color: #c5c5c5;
				}
				.time-item {
					float: left;
					width: 196rpx;
					margin: 0 0rpx 20rpx 20rpx;
					font-size: 26rpx;
					text-align: center;
					line-height: 32rpx;
					padding: 10rpx 0;
					position: relative;
					border: 1px solid #ccc;
					box-sizing: border-box;

					.time-text {
						color: #666;

						text {
							padding: 0 6rpx;
							color: #00c277;
						}

						.color-666 {
						}
					}

					.icon {
						position: absolute;
						right: 0;
						bottom: 0;
						width: 36rpx;
						height: 36rpx;
						display: none;
					}
				}

				.active {
					border: 1px solid #00c277;

					.icon {
						display: block;
					}
				}
			}
			.form-item {
				overflow: hidden;
				border-bottom: 1px solid #eee;
				padding: 30upx 0;

				.label {
					float: left;
					width: 150upx;
					font-size: 28upx;
					color: #333;
					font-weight: bold;
					line-height: 50upx;
				}

				.ipt-box {
					margin-left: 160upx;

					input {
						width: 100%;
						height: 50upx;
						line-height: 50upx;
						font-size: 26upx;
						color: #666;
					}
				}

				.select {
					.arrow {
						float: right;
						width: 16upx;
						height: 29upx;
						margin-top: 10upx;
					}

					.picker {
						height: 50upx;
						line-height: 50upx;
						font-size: 26upx;
						color: #666;
					}
				}
			}

			.sure-btn {
				width: 100%;
				height: 80upx;
				font-size: 28upx;
				color: #fff;
				text-align: center;
				line-height: 80upx;
				border-radius: 8upx;
				background: #0066cc;
				background: linear-gradient(to right, #ffc200, #ff9000);
				/*设置按钮为渐变颜色*/
				margin-top: 50upx;
			}
		}

		.list-box {
			.list-item {
				background: #fff;
				margin-bottom: 10upx;

				.title {
					border-bottom: 1px solid #eee;
					padding: 20upx 10upx;
					overflow: hidden;
					line-height: 40upx;

					.line {
						display: inline-block;
						width: 10upx;
						height: 32upx;
						background: $assistColor;
						margin-top: 4upx;
					}

					.text {
						display: inline-block;
						font-size: 28upx;
						color: #444;
						font-weight: bold;
						margin-left: 10upx;
						vertical-align: top;
					}

					.status {
						font-size: 26upx;
						color: $assistColor;
						float: right;
					}
				}

				.content {
					padding: 5upx 5upx;

					.info-item {
						overflow: hidden;
						padding-bottom: 10upx;

						.fl-text {
							float: left;
							font-size: 26upx;
							color: #444;
							font-weight: bold;
							line-height: 40upx;
						}

						.fr-text {
							float: right;
							font-size: 26upx;
							color: #666;
							line-height: 40upx;
						}
					}
				}
			}
		}
	}
}
</style>
