<template>
	<view class="content">
		<view class="topView">
			<!-- 切换tab -->
			<view class="tabBox">
				<scroll-view scroll-x="true" class="scroll">
					<view class="tabCotn">
						<view class="tabLine" :class="{tabactive:tabIndex==0}" @click="tabClick(0)">待点评</view>
						<view class="tabLine" :class="{tabactive:tabIndex==1}" @click="tabClick(1)">历史点评</view>
						

					</view>
				</scroll-view>
			</view>

			
		</view>
		<!-- 列表 -->
		<view class="shopList">
			<view v-for="(item,index) in shopData" :key="index">
			
			<!-- shopBox 待点评 -->
				<view class="shopBox"  v-if="tabIndex == 0">
					<view class=" shopTop" @click="goDetal(item)">
			
						<view class="shopName">{{item.ShopName}}</view>
			
						<!-- 订单状态 1 待提交 2 待作业 3 待点评 4 待回复 5 已完成 -->
						<view class="type" v-if="item.State == 1">待提交</view>
						<view class="type" v-if="item.State == 2">待作业</view>
						<view class="type" v-if="item.State == 3">待运营经理点评</view>
						<view class="type" v-if="item.State == 4">待回复</view>
						<view class="type" v-if="item.State == 5">已完成</view>
			
					</view>
			
			
			
					<!-- 第2行 -->
					<view class="secondView" @click="goDetal(item)">
						<!-- 运营经理 -->
						<view class="manager">{{item.ManagerName}} · {{item.CheckTime.slice(0,item.CheckTime.length-8)}}</view>
						<!-- 评分 -->
						<view class="score" v-if="item.ShopScore">{{item.ShopScore}}分</view>
					</view>
					
					<!-- 点评 -->
					<view class="bottomView">
						<view class="reviews" @click="goAppraise(item)">点评</view>
					</view>
					
				</view>
			
			<!-- shopBox 点评历史 -->
				<view class="shopBox" v-if="tabIndex == 1">
					<view class="shopTop">
					
						<view class="shopName">对{{item.ManagerName}}的服务评价</view>
			
						<!-- 星星 -->
						
						<uni-rate :value ="item.UserEvaStar" :max="5" color="#EEEEEE" active-color="#FF4F00"  :size="16" :margin="4" :readonly="true" />
						
							
					</view>
			
			
					 <!-- 第2行 -->
					 <view class="contentMes">{{item.UserEvaContent}}</view>
					 
					<view class="timeView">
						<!-- 时间 -->
						<view class="time">{{item.UserEvaTime}}</view>
						<!-- 评价人 -->
						<view class="appraiser">{{item.UserEvaOpName}}</view>
					</view>
					
			</view>
					
			
			</view>
				
				
		</view>

		<!-- 上拉 加载更多 -->
		<view class="noMore" v-if="noMoreShow">没有更多数据</view>
		<!-- 无数据空白页 -->
		<view class="nodataBox" v-if="shopData.length == 0">
			<image src="../../../static/img/pic_empty_def.png" mode="widthFix" class="nodataImg"></image>
			<view class="noTxt">暂无数据</view>
		</view>

		
	</view>
</template>

<script>
	
	export default {
		
		data() {
			return {
				tabIndex: 0,
				status: '0', 
				shopData: [],
				page: 1,
				noMoreShow: false,
				
				
			}
		},
		onShow() {
			
			this.page = 1
			this.getShopData()
		},
		methods: {
			
			goAppraise(item){
				uni.navigateTo({
					url:'reviewsContent?sheetID='+item.ID
				})
			},
			goDetal(item){
				uni.navigateTo({
					url:'../../reportManage/reportDetail?id='+item.ID
				})
			},
			tabClick(num) {
				this.tabIndex = num;

				this.status = num;
				
				this.page = 1;
				this.getShopData()
			},
			
			getShopData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'accompany/SuperCheckSheet/listMyStayCheckPage',
					params = {
						page: this.page,
						limit: 20,
						userEvaState: this.status,

					}
				this.$http(url, params, 'GET').then(res => {
					var list = res.data.Items

					// 处理 undefined和null转为空白字符串
					list.forEach((item, index) => {
						for (const key in item) {
							item[key] = this.$praseStrEmpty(item[key])
						}
					})

					
					if (this.page == 1) {
						this.shopData = list
					} else {
						this.shopData = this.shopData.concat(list)
					}
					
					if(list.length < 10){
						this.noMoreShow = false
					}
					else {
						this.noMoreShow = true
					}
					
				})
			},
			

		},

		// 下拉刷新 上拉加载更多
		onPullDownRefresh() {
			this.page = 1
			this.getShopData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			this.getShopData()
		},

	}
</script>

<style>
	.content {
		background-color: #F4F5F7;
		min-height: 100vh;
	}

	.topView {
		width: 100%;
		height: 105rpx;
		background-color: #FFFFFF;
		left: 0rpx;
		top: 0rpx;
		position: fixed;
		z-index: 99;
	}

	/* #ifdef H5 */
	.topView {
		top: 44px;
	}

	/* #endif */

	
	.tabBox {
		width: 100%;
	}

	.tabCotn {
		display: flex;
		justify-content: space-around;
	}

	.tabLine {
		
		text-align: center;
		color: #3C3C3C;
		font-size: 30rpx;
		line-height: 104rpx;
	}

	.tabactive {
		color: #FF4F00;
		border-bottom: 4rpx solid #FF4F00;
	}

	.shopList {
		background-color: #F4F5F7;
		padding: 0rpx 24rpx;
		padding-top: 105rpx;
	}

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

	}

	.shopTop {
		display: flex;
		padding: 30rpx 20rpx 10rpx 20rpx;
		justify-content: space-between;

	}

	.shopName {
		font-size: 28rpx;
		color: #3C3C3C;
		font-weight: bold;
		width: 450rpx;
	}

	.type {
		font-size: 28rpx;
		color: #FF4F00;
		margin-left: 10rpx;
	}

	.secondView {
		padding: 28rpx 20rpx;
		display: flex;
		justify-content: space-between;
		border-bottom: 1rpx #EEEEEE solid;
	}

	.manager {
		font-size: 24rpx;
		color: #666666;
	}

	.score {
		font-size: 28rpx;
		color: #B98B5D;
	}
	.bottomView {
		display: flex;
		justify-content: flex-end;
	}
	.reviews{
		width: 150rpx;
		height: 56rpx;
		color: #FF4F00;
		font-size: 28rpx;
		line-height: 56rpx;
		text-align: center;
		border-radius: 28rpx;
		border: 2rpx #FF4F00 solid;
		margin-top: 20rpx;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
	}

	.contentMes{
		padding: 20rpx;
		color: #666666;
		font-size: 26rpx;
		
	} 
	.timeView{
		padding: 20rpx 20rpx 30rpx 20rpx;
		display: flex;
		justify-content: space-between;
		
	}
	.time,
	.appraiser{
		color: #999999;
		font-size: 26rpx;
	}

	/* 空白页css */
	.nodataBox {
		text-align: center;
	}

	.nodataImg {
		width: 400rpx;
		padding-top: 290rpx;
	}

	.noTxt {
		font-size: 30rpx;
		color: #999999;
		padding-top: 50rpx;
	}

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