<template>
	<view class="content">
		<view class="navBg">
			<view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
			<view class="nav">
				
					<view class="backBox" @click="logOut">
						<image src="../../../static/img/icon_tuichu@2x.png" mode="" class="baiheiback" @click="back">
						</image>
						<view class="logOut">退出登录</view>
						
					</view>
				
				<view>运营陪伴</view>
				<view style="width:157rpx;"></view>
			</view>
		</view>
		<view style="background-color: #353847;">
			<view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
			<view style="height: 44px;"></view>
		</view>

		<!-- topView -->
		<view class="topView">
			<!-- shopMessage -->
			<view class="shopMessage">
				<!-- 店铺等级 -->
				<view class="typeBg">
					<view class="storeType">{{storeMess.Name}}</view>
				</view>

				<!-- 店名 -->
				<view class="storeName">{{storeMess.ShopName}}</view>

				<view class="countBg">
					<!-- 报告数 -->
					<view class="reportBg">
						<view class="reportCount count">{{storeMess.checkCount}}</view>
						<view class="title">检测报告</view>
					</view>

					<!-- 得分 -->
					<view class="scoreBg">
						<view class="scoreCount count">{{storeMess.ShopScore == '' ? '--' :storeMess.ShopScore}}</view>
						<view class="title">上次得分</view>
					</view>
				</view>

			</view>

			<!-- 待点评 -->
			<view class="reviewsBg">
				<view class="left">
					<image src="../../../static/img/icon_team@2x.png" class="icon"></image>
					<view class="leftTitle">运营陪伴记录</view>
				</view>

				<view class="right" @click="goReviews(storeMess)">
					<view class="rightTitle">待点评：<text
							style="font-size: 30rpx; color: #FF6E00; font-weight: bold;">{{storeMess.reviewCount}}</text>
						<image src="../../../static/img/icon_zhanghu_arrow.png"
							style="width: 12rpx; height: 22rpx; margin-left: 10rpx;"></image>
					</view>
				</view>
			</view>


			<!-- 筛选 -->
			<view class="siftBg">

				<!-- 日期选择 -->
				<view class="timeChose">
					<view @click="timeClick">{{dateTime == null ? '日期筛选' : dateTime}}</view>
					<image class="downArrow" src="../../../static/img/icon_downArrow.png"></image>
				</view>

				<!-- 访问人 -->
				<picker :value="thirdIndex" mode="selector" :range="thirdArr" @change="bindPickerChange3">
					<view class="uni-input">{{thirdIndex == null ? '访问人' : thirdArr[thirdIndex]}}
						<image class="downArrow" src="../../../static/img/icon_downArrow.png"></image>
					</view>
				</picker>


			</view>



			<!-- 切换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==2}" @click="tabClick(2)">待作业</view>
						<view class="tabLine" :class="{tabactive:tabIndex==4}" @click="tabClick(4)">待回复</view>
						<view class="tabLine" :class="{tabactive:tabIndex==5}" @click="tabClick(5)">已完成</view>

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




		</view>

		<!-- 列表 -->
		<view class="shopList">
			<view v-for="(item,index) in shopData" :key="index">

				<!-- shopBox -->
				<view class="shopBox" @click="goAppraise(item)">
					<view class="shopTop">

						<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="bottomView">
						<!-- 运营经理 -->
						<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>



			</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>

		<timeChose ref="timepop" @returnDate="returnDate" :isShow="timeShow"></timeChose>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				iStatusBarHeight: '',
				tabIndex: 0,
				status: '',
				storeMess: {},
				thirdIndex: null,
				thirdArr: ['请选择'],
				managerName: '',
				shopData: [],
				page: 1,
				noMoreShow: false,
				timeShow: false,
				starTime: '',
				endTime: '',
				dateTime: null,

			}
		},
		onLoad() {
			//页面加载初始化生命周期函数
			this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;

			this.getVisitor()

		},
		onShow() {
			this.getMessage()

			this.page = 1
			this.getShopData()
		},
		methods: {
			//自己定义的方法函数
			goRouter(url) {
				//uni.navigateTo  路由跳转 url 是地址 路由还分为uni.redirectTo switchTab navigateBackreLaunch
				this.$common.isUserId()

				uni.navigateTo({
					url: url
				})
			},
			logOut() {
				uni.clearStorageSync();
				uni.reLaunch({
					url: '../../logIn/logIn'
				})
			},
			goAppraise(item) {
				console.log(item);
				uni.navigateTo({
					url: '../../reportManage/reportDetail?id=' + item.ID
				})
			},
			goReviews(storeMess) {
				uni.navigateTo({
					url: 'reviews'
				})
			},
			timeClick() {

				this.$refs.timepop.father();
			},
			returnDate(e) {
				console.log(e)
				this.starTime = e.startTime
				this.endTime = e.endTime
				if (e.startTime) {
					this.dateTime = e.startTime + '-' + e.endTime
				} else {
					this.dateTime = null
				}

				this.page = 1;
				this.getShopData()
			},
			tabClick(num) {
				this.tabIndex = num;

				if (num == 0) {
					this.status = ''
				} else {
					this.status = num;
				}
				this.page = 1;
				this.getShopData()
			},
			getMessage() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'accompany/SuperCheckSheet/queryMyCheckSheet',
					params = {}
				this.$http(url, params, 'GET').then(res => {
					this.storeMess = res.data
					for (const key in this.storeMess) {
						this.storeMess[key] = this.$praseStrEmpty(this.storeMess[key])
					}
				})
			},

			bindPickerChange3(e) {
				this.thirdIndex = e.target.value
				this.managerName = this.thirdArr[this.thirdIndex]
				if (e.target.value == 0) {
					this.thirdIndex = null
					this.managerName = ''
				}
				this.page = 1
				this.getShopData()
			},

			getVisitor() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'accompany/SuperCheckSheet/myShopCheckManagerPage',
					params = {

					}
				this.$http(url, params, 'GET').then(res => {
					this.thirdArr = this.thirdArr.concat(res.data)
				})
			},
			getShopData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'accompany/SuperCheckSheet/listMyShopCheckPage',
					params = {
						page: this.page,
						limit: 20,
						managerName: this.managerName,
						starTime: this.starTime,
						endTime: this.endTime,
						state: 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.getMessage()
			this.page = 1
			this.getShopData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			this.getShopData()
		},

	}
</script>

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

	}

	/* #ifdef H5 */
	.content {
		background: #F4F5F7;
		min-height: calc(100vh - 44px);

	}

	/* #endif */
	.navBg {
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		width: 100vw;
		z-index: 11;
	}

	.status_bar {
		background: #353847;
	}

	
	.nav{
		display: flex;
		justify-content: space-between;
		line-height: 44px;
		font-size: 36rpx;
		color: #FFFFFF;
		background-color: #353847;
	}
	
	.backBox{
		display: flex;
		justify-content: flex-start;
		padding-left: 24rpx;
		align-items: center;
	}
	.baiheiback{
		width: 32rpx;
		height: 32rpx;
		
	}
	.logOut{
		color: #FFFFFF;
		font-size: 24rpx;
		margin-left: 5rpx;
	}

	.topView {
		width: 100%;
		height: 575rpx;
		background-color: #353847;
		padding-top: 20rpx;
		/* position: fixed; */
		z-index: 99;
	}

	.shopMessage {
		margin-left: 35rpx;
		margin-right: 35rpx;
		margin-top: 0rpx;
		margin-bottom: 40rpx;
		height: 260rpx;

		background: url('http://dmsimg.66km.com/yypb/yypb.png');
		background-size: 100% 100%;
		background-color: #353847;
		border-radius: 35rpx;

	}

	.typeBg {
		width: 120rpx;
		height: 44rpx;
		float: right;
		top: 0rpx;
		right: 0rpx;
		background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAsCAMAAACZpYwBAAAAAXNSR0IArs4c6QAAAJBQTFRFAAAA/9Sq/9uS/8yZ/9SV7ciS89GL/9GX9NSV9cyP8c2V+dKT99KU98+T+M+U9s+T9tCT9s2S9M+R9s+T9c2R9c+T9c6S9c+S9s+T9s6S9c2R9s6T9s6T9s6S9c2R9s6T9c6S9c+T9c2S9s+S9c6S9s6T9c6S9c6S9c6S9s6S9s+S9c6R9s+S9c6R9s+T9c6SqJbrXwAAAC90Uk5TAAYHCgwOFhYYGSQtPkBFVVdweYmVmZufpbKzvcHCw8bHyM7e3+Lq6+/0+Pn5+/7BWE7IAAAAxElEQVRYw8XV2RaBABhF4R+FiAZKxjKUNJ33fzsv4DZ7v8C31rk5ptFq3s/8EG9n9juNXXuJFggsqT/6DCzptoFgDZnHwFIdQLCG/YSBpbMLwXrMIVgPF4J1nkCw9hQ8BBCs2oNgZRQ8bCBYVwqWT8EnCu4XEKyIgi8U3M4gWFsKjin4QME5Bb+sYeC3VQzc2B3a2hIKDinY+UCwpRS86iDYdhQ8LSDYliUE27qEYFsWEGzTXcfAZqv0w8BmTpjcq7+95BckXprWExwToAAAAABJRU5ErkJggg==');
		background-size: 100% 100%;
	}

	.storeType {
		font-size: 24rpx;
		color: #3C3C3C;
		text-align: center;
		line-height: 44rpx;
	}

	.storeName {
		padding: 40rpx;
		padding-bottom: 20rpx;
		font-size: 34rpx;
		color: #3C3C3C;
		font-weight: bold;
	}

	.countBg {
		padding: 0rpx 38rpx;
		display: flex;
		justify-content: flex-start;
	}

	.reportBg,
	.countBg {
		margin-right: 108rpx;
	}

	.count {
		font-size: 56rpx;
		font-weight: bold;
		color: #3C3C3C;
		text-align: center;
		height: 80rpx;
	}

	.title {
		font-size: 24rpx;
		color: #555555;
		text-align: center;

	}

	.reviewsBg {
		width: 100%;
		height: 102rpx;
		background-color: #FFFFFF;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx #EEEEEE solid;
	}

	.left {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.icon {
		width: 32rpx;
		height: 32rpx;
		margin-left: 24rpx;
		margin-right: 5rpx;
	}

	.right {
		margin-right: 24rpx;
	}

	.leftTitle,
	.rightTitle {
		font-size: 30rpx;
		font-weight: bold;
		color: #3C3C3C;
	}




	.siftBg {
		width: 100%;
		height: 88rpx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: space-around;
		align-items: center;
		font-size: 28rpx;
		color: #3C3C3C;
		border-bottom: 1rpx #EEEEEE solid;
	}

	.timeChose {
		display: flex;
		justify-content: space-between;
		align-items: center;

	}


	.downArrow {
		width: 16rpx;
		height: 12rpx;
		padding: 6rpx 8rpx;
	}




	.tabBox {
		width: 100%;
		height: 88rpx;
		background-color: #FFFFFF;

	}

	.tabCotn {
		display: flex;
		justify-content: space-around;
		background-color: #FFFFFF;
	}

	.tabLine {

		text-align: center;
		color: #3C3C3C;
		font-size: 30rpx;
		line-height: 88rpx;
		background-color: #FFFFFF;
	}

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

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

	}

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

	}

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

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

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

	.bottomView {
		padding: 28rpx 20rpx;
		display: flex;
		justify-content: space-between;
	}

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

	.score {
		font-size: 28rpx;
		color: #B98B5D;
	}

	/* 空白页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>
