<template>
	<view class="content">
		<view class="yg-top">
			<image :src="yg_detail.avatar" mode="" class="yg-img"></image>
			<view class="yg-name">
				{{yg_detail.staffName}}
			</view>
			<view class="star-wrap">
				<u-rate :count="count" v-model="yg_detail.evaluate"  active-color="#F3BE69" inactive-color="#eee" disabled></u-rate>
				<!-- <u-icon name="star-fill" color="#F3BE69" v-for="item in star*1" class="start" size="20rpx"></u-icon>
				<u-icon name="star-fill" color="#eee" v-for="itemt in (5-star*1)" class="start" size="20rpx"></u-icon> -->
			</view>
		</view>
		<view class="yg-info">
			<view class="info-line">
				<view class="left-name">
					<image src="https://api.liuniukj.com/img/user/ljfw.png" mode=""></image>
					<view class="">
						累计服务
					</view>
				</view>
				<view class="info-val">
					{{yg_detail.sold}}次
				</view>

			</view>
			<!-- <view class="info-line">
				<view class="left-name">
					<image src="" mode=""></image>
					<view class="">
						从业年限
					</view>
				</view>
				<view class="info-val">
					2年
				</view>

			</view> -->
			<view class="info-line" style="height: auto;border-bottom: none;">
				<view class="left-name">
					<image src="https://api.liuniukj.com/img/user/ygjj.png" mode=""></image>
					<view class="">
						员工简介
					</view>
				</view>
				<view class="info-val" style="line-height: 1.5;padding-top: 20rpx;">
					{{yg_detail.info || '暂无'}}
				</view>
			</view>
		</view>
		<view class="pj-tit">
			服务评价
		</view>
		<scroll-view scroll-y="true" :style="{'height': height}" class="swiper-box">
			<u-empty text="暂无数据" mode="data" v-if="list.length == 0 && loaded"></u-empty>
			<view class="pj-wrap" v-for="item in list">
				<view class="pj-user">
					<image :src="item.customer.avatar" mode="" class="user-logo"></image>
					<view class="user-info">
						<view class="user-name">
							{{item.customer.name | showName}}
						</view>
						<view class="star-wrap">
							<u-rate :count="count" v-model="item.score"  active-color="#F3BE69" inactive-color="#999" disabled></u-rate>
						</view>
					</view>
					<view class="pj-time">
						{{item.createTime}}
					</view>
				</view>
				<view class="pj-info">
					{{item.comment}}
				</view>
			</view>
			<u-loadmore :status="loadingType" v-if="!loaded || list.length > 0"/>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loaded: false,
				count: 5,
				star: 3,
				height: '',
				pjlist: 10,
				ygid: '',
				yg_detail: {},
				page:1,
				pageSize: 10,
				loadingType: 'loadmore',
				list: []
			}
		},
		onLoad(opt) {
			this.ygid = opt.id
			this.getYgdetail()
			this.getYgPj()
		},
		onShow() {

		},
		onReachBottom() {

		},
		onReady() {
			var _this = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.swiper-box').boundingClientRect();
					query.exec(function(res) {
						_this.height = resu.windowHeight - res[0].top + 'px';
						console.log('打印页面的剩余高度', _this.height);
					});
				},
				fail: res => {}
			});
		},
		filters: {
			showName(val) {
				if(val !== '') {
					let arr = val.split('')
					return arr[0] + '***'+ arr[arr.length-1]
				}else {
					return '佚名'
				}
				
			}
		},
		methods: {
			getYgdetail() {
				this.$u.api.getYgdetail({
					request_id: this.ygid
				}).then(({data})=> {
					this.yg_detail = data
				})
			},
			getYgPj() {
				if(this.loadingType == 'nomore' || this.loadingType == 'loading') {
					return
				}
				this.loadingType = 'loading'
				this.$u.api.getYgPj({
					id: this.ygid, //员工id
					page: this.page, //分页页码,数字类型
					pageSize: this.pageSize
				}).then(({data})=> {
					this.list = this.list.concat(data)
					this.page++
					this.loaded = true
					if(this.pageSize == data.length) {
						this.loadingType = 'loadmore'
					}else {
						this.loadingType = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;

	}

	.yg-top {
		height: 326rpx;
		width: 100%;
		// color: #262261;
		background-color: #262261;
		position: relative;

		.yg-img {
			position: absolute;
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			top: 96rpx;
			left: 43rpx;
			background-color: #eee;
		}

		.yg-name {
			position: absolute;
			font-size: 36rpx;
			font-weight: 500;
			color: #FFFFFF;
			top: 115rpx;
			left: 185rpx;
		}

		.star-wrap {
			position: absolute;
			top: 170rpx;
			left: 185rpx;
			display: flex;
			justify-content: flex-start;

			.start {
				margin-right: 10rpx;
			}
		}
	}

	.yg-info {
		margin: -78rpx auto 20rpx;
		position: relative;
		width: 694rpx;
		padding-bottom: 10rpx;
		// height: 299rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
		border-radius: 10rpx;

		.info-line {
			border-bottom: 1px solid #F8F8F8;
			font-size: 20rpx;
			font-weight: 500;
			color: #666666;
			height: 72rpx;
			line-height: 72rpx;
			display: flex;

			.info-val {
				flex-grow: 1;
			}
		}
	}

	.left-name {
		flex-shrink: 0;
		height: 72rpx;
		width: 165rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		font-size: 25rpx;
		font-weight: bold;
		color: #101010;
		padding-right: 10rpx;

		image {
			width: 28rpx;
			height: 28rpx;
			margin-right: 15rpx;
			background-color: #eee;
		}

	}

	.pj-tit {
		font-size: 30rpx;
		font-weight: bold;
		color: #101010;
		padding: 26rpx;
	}
	.pj-wrap {
		width: 100%;
		min-height: 244rpx;
		border-bottom:#f5f5f5 1rpx solid;
		background-color: #fff;
		padding: 30rpx;
		.pj-user {
			display: flex;
			align-items: center;
			height: 75rpx;
			.user-logo {
				width: 75rpx;
				height: 75rpx;
				background-color: #eee;
				border-radius: 50%;
				margin-right: 10rpx;
			}
			.user-info {
				flex-grow: 1;
				.user-name {
					font-size: 26rpx;
					font-weight: 500;
					color: #545456;
					margin-bottom: 10rpx;
				}
				
				.star-wrap {
					display: flex;
					justify-content: flex-start;
					
					.start {
						margin-right: 10rpx;
					}
				}
			}
			.pj-time {
				font-size: 24rpx;
				font-weight: 400;
				color: #545456;
			}
		}
		.pj-info {
			padding-top: 30rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #545456;
		}
	}
	.swiper-box {
	}
</style>