<template>
	<view class="hzIndex">
		<hzHeader title="受理"></hzHeader>
		<view class="container hzContent">
			<view class="main">
				<view class="tab-box">
					<view class="tab-item" :class="currentTabIndex == 0 ? 'active_tab' : ''"
						@click="currentTabIndex = 0">未回复<view class="tabBottom" v-if="currentTabIndex == 0"></view>
					</view>
					<view class="tab-item" :class="currentTabIndex == 1 ? 'active_tab' : ''"
						@click="currentTabIndex = 1">已回复<view class="tabBottom" v-if="currentTabIndex == 1"></view>
					</view>
					<view class="tab-item" :class="currentTabIndex == 2 ? 'active_tab' : ''"
						@click="currentTabIndex = 2">已办结<view class="tabBottom" v-if="currentTabIndex == 2"></view>
					</view>
				</view>
				<!-- 未审批列表 -->
				<view class="reservation-box" v-if="currentTabIndex == 0">
					<view class="list-box">
						<view class="detail-box" v-for="(item, index) in list0" :key="index">
							<!-- <view @click="detail"> -->
							<view class="detail_header" @click="detail(item)">
								<image class="blueSign" src="@/static/haircut/zx.png" mode=""></image>
								<text v-if="item.report_type==0" class="font-tilte">咨询服务</text>
								<text v-if="item.report_type==1" class="font-tilte">用户投诉</text>
								<text style="color: #FB8107;background-color: #FFEFE3;" class="font-result">未回复</text>
							</view>
							<view class="detail_msg">
								<view class="info-item" @click="detail(item)">
									<text>标题:</text>
									<text class="infoSpan">{{ item.title }}</text>
								</view>
								<view class="info-item" @click="detail(item)">
									<text v-if="item.report_type==0">咨询日期:</text>
									<text v-if="item.report_type==1">投诉日期:</text>
									<text class="infoSpan">{{ formatDate(item.create_time,'dateTime')}}</text>
								</view>
							</view>

						</view>
					</view>
				</view>
				<!-- 已审批列表 -->
				<view class="reservation-box" v-if="currentTabIndex == 1">
					<view class="list-box">
						<view class="detail-box" v-for="(item, index) in list1" :key="index">
							<!-- <view @click="detail"> -->
							<view class="detail_header" @click="detail(item)">
								<image class="blueSign" src="@/static/haircut/zx.png" mode=""></image>
								<text v-if="item.report_type==0" class="font-tilte">咨询服务</text>
								<text v-if="item.report_type==1" class="font-tilte">用户投诉</text>
								<text class="font-result">已回复</text>
							</view>
							<view class="detail_msg">
								<view class="info-item" @click="detail(item)">
									<text>标题:</text>
									<text class="infoSpan">{{ item.title }}</text>
								</view>
								<view class="info-item" @click="detail(item)">
									<text v-if="item.report_type==0">咨询日期:</text>
									<text v-if="item.report_type==1">投诉日期:</text>
									<text class="infoSpan">{{ formatDate(item.create_time,'dateTime')}}</text>
								</view>
							</view>

						</view>
					</view>
				</view>
				<view class="reservation-box" v-if="currentTabIndex == 2">
					<view class="search-box">
						<view class="form-item searchv">
							<picker class="time-data" mode="date" @change="startDateChange">
								<view class="">{{ startDate }}</view>
							</picker>
							<text class="timecenter">至</text>
							<picker class="time-data" 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 class="tj-box">
							<text style="font-size: 28upx; color: #666666;">时段内已办结总数：</text>
							<text style="font-size: 32upx;color: #0DB0A7;font-weight: 600;">{{endCount}}</text>
						</view>
					</view>
					<view class="list-box">
						<view class="detail-box" v-for="(item, index) in list2" :key="index">
							<!-- <view @click="detail"> -->
							<view class="detail_header" @click="detail(item)">
								<image class="blueSign" src="@/static/haircut/zx.png" mode=""></image>
								<text v-if="item.report_type==0" class="font-tilte">咨询服务</text>
								<text v-if="item.report_type==1" class="font-tilte">用户投诉</text>
								<text class="font-result">已办结</text>
							</view>
							<view class="detail_msg">
								<view class="info-item" @click="detail(item)">
									<text>标题:</text>
									<text class="infoSpan">{{ item.title }}</text>
								</view>
								<view class="info-item" @click="detail(item)">
									<text v-if="item.report_type==0">咨询日期:</text>
									<text v-if="item.report_type==1">投诉日期:</text>
									<text class="infoSpan">{{ formatDate(item.create_time,'dateTime')}}</text>
								</view>
							</view>

						</view>
					</view>
				</view>
				<content-none v-if="currentTabIndex == 0 && list0.length == 0" :padTop="20"></content-none>
				<content-none v-if="currentTabIndex == 1 && list1.length == 0" :padTop="20"></content-none>
				<content-none v-if="currentTabIndex == 2 && list2.length == 0" :padTop="20"></content-none>
			</view>
			<load-more v-show="currentTabIndex == 0 " :loadingType="loadingType0"
				:contentText="contentText0"></load-more>
			<load-more v-show="currentTabIndex == 1 " :loadingType="loadingType1"
				:contentText="contentText1"></load-more>
			<load-more v-show="currentTabIndex == 2 " :loadingType="loadingType2"
				:contentText="contentText2"></load-more>
			<!-- <view v-if="checkedListId.length>0" style="position: fixed;bottom:0upx;height: 50upx;width: 100%;z-index: 9999;">
		</view> -->
		</view>
	</view>
</template>

<script>
	import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
	import {
		getReportList,
		getReportCount
	} from '@/common/api.js';
	import {
		callbackRequest,
		alertTip,
		getStorage,
		formatDate
	} from '@/common/util.js';
	import loadMore from '@/components/loadMore.vue';
	import datetimePicker from '@/components/dateTime.vue';
	import contentNone from '@/components/contentNone.vue';
	import UniPopup from "@/components/uni-popup/uni-popup.vue"
	import xflSelect from '../../components/xfl-select/xfl-select1.vue'
	export default {
		data() {
			return {
				formatDate: formatDate,
				userId: getStorage('userInfo').userId,
				currentTabIndex: 0,
				page0: 1,
				pageSize0: 10,
				loadingType0: 2, //0-loading前；1-loading中；2-没有更多了
				page1: 1,
				pageSize1: 10,
				loadingType1: 2, //0-loading前；1-loading中；2-没有更多了
				page2: 1,
				pageSize2: 10,
				loadingType2: 2, //0-loading前；1-loading中；2-没有更多了
				list0: [],
				list1: [],
				list2: [],
				contentText0: {
					contentdown: '上拉加载更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				contentText1: {
					contentdown: '上拉加载更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				contentText2: {
					contentdown: '上拉加载更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				reportType: 0,
				startDate: this.getDay(-7),
				endDate: this.getDay(0),
				endCount: ''
			};
		},
		components: {
			loadMore,
			contentNone,
			UniPopup,
			xflSelect
		},
		watch: {
			currentTabIndex: function(newVal, oldVal) {
				this.currentTabIndex = newVal;
				if (this.currentTabIndex == 0) {
					this.page0 = 1;
					this.loadingType0 = 0;

				} else if (this.currentTabIndex == 1) {
					this.page1 = 1;
					this.loadingType1 = 0;

				}
				this.getReportList();
			}

		},
		onLoad(options) {
			this.currentTabIndex = options.currentTabIndex || 0;
			this.reportType = options.reportType || 0;

		},
		onShow() {
			this.getReportList();
		},
		methods: {
			detail(item) {
				uni.navigateTo({
					url: '/pages/report/report-detail?id=' + item.id + "&queryType=1"
				});
			},
			getReportList() {
				var data = {};
				if (this.currentTabIndex == 0) {
					data = {
						pageNum: this.page0,
						pageSize: this.pageSize0,
						reportStatus: 0,
						reportType: this.reportType
					}
				} else if (this.currentTabIndex == 1) {
					data = {
						pageNum: this.page1,
						pageSize: this.pageSize1,
						reportStatus: 1,
						reportType: this.reportType
					}
				} else if (this.currentTabIndex == 2) {
					data = {
						pageNum: this.page2,
						pageSize: this.pageSize2,
						reportStatus: 2,
						reportType: this.reportType,
						startDate: this.startDate,
						endDate: this.endDate
					}
				}
				let params = {
					method: getReportList,
					data: data
				};
				callbackRequest(params).then(res => {
					if (res.data.returnCode == 1) {
						let result = res.data.returnData || [];
						if (this.currentTabIndex == 0) {
							if (this.page0 == 1) {
								this.list0 = result;
							} else {
								if (result.length > 0) {
									this.list0 = [...this.list0, result];
									this.loadingType0 = 0;
								} else {
									this.loadingType0 = 2;
								}
							}
						} else if (this.currentTabIndex == 1) {
							if (this.page1 == 1) {
								this.list1 = result;
							} else {
								if (result.length > 0) {
									this.list1 = [...this.list1, result];
									this.loadingType1 = 0;
								} else {
									this.loadingType1 = 2;
								}
							}
						} else if (this.currentTabIndex == 2) {
							if (this.page2 == 1) {
								this.list2 = result;
							} else {
								if (result.length > 0) {
									this.list2 = [...this.list2, result];
									this.loadingType2 = 0;
								} else {
									this.loadingType2 = 2;
								}
							}
							this.getReportCount();
						}

					} else {
						alertTip(res.data.returnMsg);
					}
				});
			},
			getReportCount() {
				var data = {
					reportStatus: 2,
					reportType: this.reportType,
					startDate: this.startDate,
					endDate: this.endDate
				}
				let params = {
					method: getReportCount,
					data: data
				};
				callbackRequest(params).then(res => {
					if (res.data.returnCode == 1) {
						this.endCount = res.data.returnData;
					} else {
						alertTip(res.data.returnMsg);
					}
				});
			},
			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;
			},
			startDateChange: function(e) {
				this.page2 = 1;
				this.loadingType2 = 0;
				this.list2 = [];
				this.startDate = e.target.value;
				this.getReportList();
			},
			endDateChange: function(e) {
				this.page2 = 1;
				this.loadingType2 = 0;
				this.list2 = [];
				this.endDate = e.target.value;
				this.getReportList();
			},
		},
		onReachBottom() {
			if (this.currentTabIndex == 0) {
				if (this.loadingType0 !== 0) {
					return;
				}
				this.loadingType0 = 1;
				this.page0 = this.page0 + 1;
				this.getReportList();
			} else if (this.currentTabIndex == 1) {
				if (this.loadingType1 !== 0) {
					return;
				}
				this.loadingType1 = 1;
				this.page1 = this.page1 + 1;
				this.getReportList();
			} else if (this.currentTabIndex == 2) {
				if (this.loadingType2 !== 0) {
					return;
				}
				this.loadingType2 = 1;
				this.page2 = this.page2 + 1;
				this.getReportList();
			}

		}
	};
</script>

<style lang="scss">
	// @import '@/static/css/common.scss';

	.search-box {
		margin-top: 36upx;
		padding: 24upx;
		background-color: #fff;
		border-radius: 20upx;
	}

	.searchv {
		text-align: center;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.timecenter {
		display: inline-block;
		font-size: 24upx;
		margin-left: 10upx;
		margin-right: 10upx;
		color: #555555;
		line-height: 30upx;
		// margin-top: 15upx;
	}

	.time-data {
		width: 300upx;
		height: 60upx;
		font-size: 28upx;
		display: inline-block;
		border: 1px solid #0DB0A7;
		border-radius: 8upx;
		color: #555555;
		line-height: 60upx;
	}

	.tj-box {
		margin-top: 28upx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.batchBtn {
		position: absolute;
		height: 140upx;
		background: white;
		padding-top: 30upx;

		.btn1 {
			width: 40%;
			margin-left: 7%;
			margin-right: 6%;
			border-radius: 10upx;
		}

		.btn2 {
			width: 40%;
			border-radius: 10upx;
		}

		.btn3 {
			width: 28%;
			margin-left: 4%;
			border-radius: 10upx;
		}

		.btn4 {
			width: 28%;
			margin-left: 4%;
			border-radius: 10upx;
		}

		.btn5 {
			width: 28%;
			margin-left: 4%;
			border-radius: 10upx;
			background: #348CF2;
		}
	}

	.container {
		margin-top: 150upx;

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

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

		.main {
			.tab-box {
				// width: 100%;
				display: flex;
				justify-content: space-around;
				font-size: 32upx;
				color: #555555;
				// margin: 0 24upx;

				.active_tab {
					font-weight: 800;

				}

				.tab-item {
					// width: 33%;

					.tabBottom {
						width: 80%;
						height: 6upx;
						border-radius: 5px;
						background: linear-gradient(90deg, #64E182 0%, #1CA7B2 100%);
						margin: 0 auto;
					}
				}
			}

			.form-box {
				padding: 20upx 30upx 0upx;
				margin-bottom: 20upx;
				background: #fff;

				.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;
						}

						.pic {
							width: 60upx;
							height: 60upx;
							line-height: 80upx;
						}
					}

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

						input {
							width: 70%;
						}
					}

					.jian {
						width: 50upx;
						height: 50upx;
						margin-left: 280upx;
					}

					.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;
				}
			}

			.reservation-box {
				margin: 24upx;

				.list-box {
					margin-top: 24upx;

					.detail-box {
						// margin-top: 10upx;
						margin-bottom: 24upx;
						background: #ffffff;
						border-radius: 20upx;
						padding: 24upx;
					}

					.detail_header {
						padding: 15upx 0upx;
						border-bottom: 1px solid #eee;
						display: flex;
						flex-direction: row;
						align-items: center;
						position: relative;
					}

					.detail_header .blueSign {
						width: 48upx;
						height: 48upx;
					}

					.detail_header .font-tilte {
						display: inline-block;
						font-weight: bold;
						font-size: 18px;
						color: #333333;
						margin-left: 16upx;
					}

					.detail_header .font-result {
						display: inline-block;
						position: absolute;
						width: 80*2upx;
						height: 28*2upx;
						right: 0upx;
						background: #C1EFEA;
						border-radius: 15px 15px 15px 15px;
						font-size: 28upx;
						color: #0DB0A7;
						text-align: center;
						line-height: 28*2upx;
					}

					.detail_msg {
						display: grid;
						margin-top: 20upx;
					}

					.detail_msg .info-item {
						font-size: 28upx;
						color: #999999;
						margin-bottom: 10upx;
						font-size: 28upx;
						line-height: 50upx;

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

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

					// .detail_msg .info-item:nth-of-type(6) {
					// 	padding-bottom: 24upx;
					// 	border-bottom: 1px solid #EBEFF7;
					// }

					// .detail_msg .info-item:last-child {
					// 	padding-bottom: 24upx;
					// 	border-bottom: 0px solid #000;
					// }

					.comment-btn {
						margin-top: 24upx;
						width: 84*2upx;
						height: 32*2upx;
						border-radius: 16*2upx;
						border: 1px solid #0DB0A7;
						font-size: 28upx;
						color: #0DB0A7;
						line-height: 32*2upx;
						text-align: center;
						min-width: 140upx;
						justify-self: end;
					}

					.bg-ccc {
						border-color: #CACACA;
						color: #CACACA;
						background-color: #fff !important;
					}
				}
			}
		}
	}

	#addbtn {
		height: 120upx;
		background-color: #ffffff;
		padding: 30upx;
		border-radius: 30upx;
		color: #333333;
		border-bottom: 0.033333rem solid #eee;
		align-items: center;
		position: relative;
		margin-top: 20upx;
	}

	.addbtn view text:nth-child(1) {
		font-size: 32upx;
		margin-left: 220upx;
		color: #00c277;
	}

	.addbtn view text:nth-child(2) {
		font-size: 32upx;
		margin-left: 180upx;
		color: #00c277;
	}

	.tips {
		font-size: 22upx;
		// margin-left: 80upx;
		margin-top: 20upx;
	}

	uni-radio .uni-radio-input {
		-webkit-appearance: none;
		appearance: none;
		margin-right: 5px;
		outline: 0;
		border: 1px solid #d1d1d1;
		background-color: #fff;
		border-radius: 50%;
		width: 18px !important;
		height: 18px !important;
		position: relative;
	}
</style>