<template>
	<view class="client-appraise">
		<view class="operation">
			<view class="">
				<button v-if="index!=5" @click="upday()" class="cu-btn round line-red">上一天</button>
			</view>
			<view class="">
				<picker  mode="date" :value="date" :start="timeArr[5]" :end="currentDate" @change="bindDateChange">
				<text class="text-red">{{date}}</text>
				</picker>
			</view>
			<view class="">
				<button v-if="index!=-1" @click="dowmday" class="cu-btn round line-red">下一天</button>
			</view>
		</view>
		<view v-if="todayList.length==0">
			<view class='empty cuIcon-info'></view>
			<view class='empty-text text-gray'>暂无数据</view>
		</view>
		<view class="client  radius shadow shadow-lg bg-white " v-for="(item,index) in todayList" :key="index">
			<!-- 今日 -->
			<view class="cu-bar bg-white  margin-top">
				<view class='action '>
					<text class='cuIcon-titles text-orange'></text>
					<text class='text-black'>{{item.tradeName}}</text>
				</view>
			</view>
			<view class="cu-card case no-card ">
				<view class="cu-item shadow">
					<view class="appraise">
						<text>态度评价:</text>
						<view class="stars-wrapper">
							<view v-for="n in 5" :key='n' :class="{'on':item.csAttitudeStar>=n}"></view>
						</view>
					</view>
					<view class="appraise">
						<text>技术评价:</text>
						<view class="stars-wrapper">
							<view v-for="n in 5" :key='n' :class="{'on':item.csTechnicalStar>=n}"></view>
						</view>
					</view>
					<view class="appraise">
						<text>其他评价:</text>
						<view class="stars-wrapper">
							<view v-for="n in 5" :key='n' :class="{'on':item.csOtherStar>=n}"></view>
						</view>
					</view>
					<view class="appraise" style="margin-bottom: 10upx;">
						<text>评价内容:</text>
						<text style="width: 60%; padding: 0 20upx; ">{{item.csAppraise}}</text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {

		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				userInfo: null,
				todayList: [{
					tradeName: '精品玻尿酸疗程',
					csOtherStar: 5, //其他
					csTechnicalStar: 5, //技术
					csAttitudeStar: 2, //态度
					nr: '这是评价内容这是评价内容这是评价是评价内容'
				}, {
					tradeName: '精品玻尿酸疗程',
					csOtherStar: 5, //其他
					csTechnicalStar: 5, //技术
					csAttitudeStar: 2, //态度
					nr: '这是评价内容这是评价内容这是评价是评价内容'
				}],
				currentDate: currentDate,
				date: currentDate,
				timeArr: [],
				index: -1,

			}
		},
		onLoad() {
			this.timeArr = this.GetTime()
		},
		methods: {
			bindDateChange(e){
				this.date = e.detail.value
				this.timeArr.forEach((item,index)=>{
					if(this.date==item){
						this.index = index
					}
				})
				this.selectMemberCsByStaff()
			},

			GetTime() {
				var date = new Date();
				var base = Date.parse(date); // 转换为时间戳
				var year = date.getFullYear(); //获取当前年份
				var mon = date.getMonth() + 1; //获取当前月份
				var day = date.getDate(); //获取当前日
				var oneDay = 24 * 3600 * 1000
				var daytime = `${year}${mon >= 10 ? mon : '0' + mon}${day >= 10 ? day : '0' + day}`; //今日时间
				this.$data.daytime = daytime; // 今日时间赋值给变量
				var daytimeArr = []
				for (var i = 1; i < 7; i++) { //前七天的时间
					var now = new Date(base -= oneDay);
					var myear = now.getFullYear();
					var month = now.getMonth() + 1;
					var mday = now.getDate()
					daytimeArr.push([myear, month >= 10 ? month : '0' + month, mday >= 10 ? mday : '0' + mday].join('-'))
				}
				return daytimeArr
			},
			upday() {
				this.index += 1
				this.date = this.timeArr[this.index]
				this.selectMemberCsByStaff()
			},
			dowmday() {
				this.index -= 1
				this.date = this.timeArr[this.index]
				if (this.index == -1) {
					this.date = this.currentDate
				}
				this.selectMemberCsByStaff()
			},
			selectMemberCsByStaff() {
				this.userInfo = uni.getStorageSync('userInfo')
				var form = {
					docDate: new Date(this.date),
					staffIds: this.userInfo.id,
					storeId: this.userInfo.storeId,
					state: 1
				}
				this.$api.selectMemberCsByStaff(form).then(res => {
					if (res.code == '000000') {
						this.todayList = res.rows
					}
				})
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate()
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;;
				return `${year}-${month}-${day}`
			},


		},
		onShow:function() {
			this.newdate = new Date()
			this.selectMemberCsByStaff()
		}
	}
</script>

<style>
	.client {
		margin: 0 3%;
		border-radius: 20upx;
	}

	.operation {
		width: 100%;
		height: 80upx;
		background-color: #FFFFFF;
	}

	.operation view {
		padding: 10upx 0;
		display: inline-block;
		text-align: center;
	}

	.operation view:nth-child(2n-1) {
		width: 30%;
	}

	.operation view:nth-child(2n) {
		width: 40%;
	}

	.client-appraise .appraise {
		padding: 5upx 5%;
		font-size: 24upx;
	}

	.client-appraise .appraise text {
		font-size: 24upx;
		padding-right: 10upx;
	}

	.stars-wrapper {
		display: inline-block;
		background-color: #FFFFFF;
		padding: 0upx 30upx;
	}

	.stars-wrapper view {
		width: 24upx;
		height: 24upx;
		background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDp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WxfB7JdITKIStQW7Qw3B95MNuQSp0WN4mToAc7Ai/lubaWex3q2k+IgSpaQB/wpotKM61gZ0xgl7pgDumS2VlBHnhLlbYF9pOVXC+zIRP1YPDORv+kTRGUGWvnFrUms7wcr/oMoWQvvsF4IUWvNhqS7YIa6ESyxUVQ0e0YG+mGIWtXeWHkR7GS9FMy1QZSHW7so9szSYIP4ZubyaqBaNdl39mc0SLKaXahAXWGDsKegDXQCzVaFTWL5zAZhEvyrmJ3EWhHm0fKnGpsG/2OWw6wIU1/1lcHeDntueHZQwmK0bmyzSVg1yzh/FwU6VFE3vzDxwtmcceeYw/myKjPCAnks0TAuvJkE/5dcVvKZSBaBfgE8ZqkrEwwP020yuA1O8SX3JDvgf8s5JnO4NOjWSo9GBiust7aJqDHMVPHODS6SjUw25bggjaFMcquO3CXJR6V4Wc/UfiAoYSpnr9c2r7UcT2I7GJALDKFsJFgJPnC1v8r20bzmbKAlwx0g2LoY21IoKM/171izlJuGLeCbj/uLuDlWRwjTuF3L1U6GxgUzK9VRZYrWFZKq7KIHzFgTvXwZbASphn1FSzAek13Mbm5YL3CGJrdDlG63eBAjW7UTFHQTHPF1wx8BBgBGdNDH1AgKhgAAAABJRU5ErkJggg==');
		background-repeat: no-repeat;
		background-size: 100% 100%;
		margin-right: 30upx;
		display: inline-block;
	}

	.stars-wrapper .on {
		background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xN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wis0x7o2CECvESkA9434UVanpYlMK8gyZLVYEKhTkE79al5likyry9polFgmqVeR3gFi1L1Ey8seBdJAPsoFTw5/ZpR58D27o941VIMBjrnQL5IEMUAAKQSqNS3rGK3gEZ+Aa3IFz8IS5894tlobfVZALwgVr4xecgnZRbBsXtYJ/xZuNqsrfIlIU6/RDsQF3468DW34itYAO0OrZKxvAmsVSm5Byeg+w66DNQqkdt5TUyD8POiyQ2oNUjdyUNAu6TZRyQaqKNfJ7h5M2FkbGDKS61E7iLlqFGhWHrCWR3OpihPaLeoc4H1byLnveDRD7Bl+8YuUGiOWAZB6xOFqDGREOHrE8HY8RvKOARyzbwF5p5xGzGyiWySOWY6BYNI9YvooXXYEjM8Ri5D43xQvtuMVqLxX+j6QuFZRLYsnZZIYKuaOkCeog4x5py7SxGSBpXxEMsrSIxTPuLdJQMsh4+SRJTzOeU6xF7NdHO2oELeBCYTX30amQVPsL1yJ2DPbBD3gQ/o+U7Bon9W1qf+Jh3i2lPYMlXwX+BBgA/6doZQMn2nUAAAAASUVORK5CYII=');
	}

	.the-month,
	.last-month,
	.season,
	.half-a-year,
	.this-year {
		background: white;
		padding-top: 30rpx;
		position: absolute;
		top: 90rpx;
		bottom: 0;
		left: 0;
		right: 0;
	}

	/* 汇总标题 */
	.month-title {
		display: flex;
		padding: 20rpx 20rpx 20rpx 25rpx;
	}

	.month-title view {
		text-align: center;
		font-size: 31rpx;
	}

	.month-title .projectname {
		flex: 5;
		font-size: 31rpx;
	}

	.month-title .servicenums {
		flex: 2.5;
	}

	.month-title .averagescore {
		flex: 2.5;
	}

	/* 汇总列表 */
	.month-content {
		display: flex;
		align-items: center;
		padding: 10rpx 20rpx 30rpx 25rpx;
	}

	.month-content view {
		text-align: center;
		font-size: 28rpx;
	}

	.month-content .projectname-list {
		flex: 5;
	}

	.month-content .servicenums-list {
		flex: 2.5;
	}

	.month-content .averagescore-list {
		flex: 2.5;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 29rpx;
	}

	.averagescore-icon {
		margin-right: 10rpx;
	}

	.averagescore-fraction {
		font-weight: 550;
		color: orange;
	}
</style>
