<template>
	<view class="content">
		<!-- 搜索 -->
		<view class="searchBoxBg">
			<!-- <view class="searchBox">
				<image src="../../static/img/icon_search.png" mode="" class="searchImg"></image>
				<input type="text" class="searchInput" placeholder="请输入姓名、手机号" v-model="searchValue"
					@confirm="searchDone" />
			</view> -->
			<searchBox placeholder="请输入姓名、手机号" @search='search($event)'></searchBox>
		</view>
		


		<!-- 团队数量 -->
		<view class="teamTop">
			<image class="iconTeam" src="../../static/img/icon_team@2x.png" mode=""></image>
			<view class="teamCount">我的团队：<text style="color: #FF4F00;">{{count}}</text>人</view>
		</view>

		<!-- 内容 -->
		<view class="teamContent">
			<view v-for="(item,index) in shopData" :key="index">
				<view class="team" @click="goRouter(item)">
					<!-- 第一行 -->
					<view class="customer">
						<view class="name">{{item.name}}  {{item.AccountName}}</view>
						<view class="shopCount" style="color: #FF4F00;">管理门店：{{item.shopCount}}
							<image src="../../static/img/icon_arrow_go.png"
								style="width: 12rpx; height: 22rpx; margin-left: 5rpx;"></image>
						</view>
					</view>

					<!-- 报告数量 -->
					<view class="informCount">已提交报告：<text style="color: #FF4F00;">{{item.checkSheet}}</text>条</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>
	import searchBox from '@/components/searchBox/searchBox.vue'
	export default {
		components: {
			searchBox
		},
		data() {
			return {
				shopData: [],
				count: 0,
				searchValue: '',
				page: 1,
				noMoreShow: false,
			}
		},
		onLoad() {
			this.page = 1
			this.getData()
			
		},
		methods: {
		
			search(val) {
				// console.log(val);
				this.searchValue = val
				this.page = 1
				this.getData()
			},
			goRouter(v) {
				uni.navigateTo({
					url: 'manageStore?managerID=' + v.ID
				})
			},
			getData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'accompany/SuperAccounts/queryMyteam',
					params = {
						page: this.page,
						limit: 20,
						name: this.searchValue
					}
				this.$http(url, params, 'GET').then(res => {
					this.count = Number(res.data.count)
					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.getData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			this.getData()()
		},
	}
</script>

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

	}

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

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

	/* #endif */
	.searchBox {
		display: flex;
		height: 72rpx;
		margin: 24rpx;
		background-color: #F4F5F7;
		border-radius: 36rpx;
	}

	.searchImg {
		margin-top: 20rpx;
		margin-left: 20rpx;
		width: 32rpx;
		height: 32rpx;
	}

	.searchInput {
		height: 72rpx;
		font-size: 28rpx;
		padding-left: 16rpx;
		width: 80%;
	}

	.teamTop {
		background-color: #F4F5F7;
		height: 80rpx;
		position: fixed;
		left: 0;
		top: 120rpx;
		display: flex;
		align-items: center;
		padding-left: 24rpx;
		z-index: 99;
		width: 100%;
	}

	/* #ifdef H5 */
	.teamTop {
		top: calc(120rpx + 44px);
	}

	/* #endif */
	.iconTeam {
		width: 32rpx;
		height: 32rpx;
	}

	.teamCount {
		font-size: 30rpx;
		font-weight: bold;
		color: #3C3C3C;
		line-height: 32rpx;
		padding-left: 8rpx;

	}

	.teamContent {
		background-color: #F4F5F7;
		padding: 0rpx 24rpx;
		padding-top: 200rpx;
		display: flex;
		flex-direction: column;
	}

	.team {
		background-color: #FFFFFF;
		margin: 10rpx 0rpx;
		border-radius: 10rpx;
	}

	.customer {
		padding: 30rpx 20rpx 16rpx 20rpx;
		display: flex;
		justify-content: space-between;
	}

	.name {
		font-size: 28rpx;
		margin-right: 10rpx;
	}

	.shopCount {
		font-size: 28rpx;

	}

	.informCount {
		padding: 0rpx 20rpx 30rpx 20rpx;
		color: #666666;
		font-size: 24rpx;
	}

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

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

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

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