<template>
	<view class="pageBgImg">
		<topNavbar title="驾校场地"></topNavbar>
		<view class="pad">
			<view class="search_Box">
				<searchRow placeholder="搜索场地名称" @searchFn="searchFn"></searchRow>
			</view>
			<view class="ul">
				<view class="card" v-for="(item,index) in list" :key="index">
					<view class="name_row">
						<view class="icon">
							<image src="@/static/images/userCenter/siteIcon.png" mode=""></image>
						</view>
						<view class="name">{{item.name}}</view>
					</view>
					<view class="addres_row">
						<view class="icon">
							<image src="@/static/images/userCenter/adsIcon.png" mode=""></image>
						</view>
						<view class="ads">{{item.address}}</view>
					</view>
					<view class="status_row">
						使用状态：<text v-if="item.siteStatus==1">正常</text> <text v-if="item.siteStatus==0" class="orange">停用</text>
					</view>
				</view>
			</view>
		</view>
		<view style="padding-bottom: 20rpx;" v-if="list.length">
			<u-loadmore :status="status" />
		</view>
		<nodata v-if="!list.length&&status=='nomore'"></nodata>
	</view>
</template>


<script>
	import { sitePage } from '@/config/api.js'
	export default {
		data() {
			return {
				list: [],
				params: {
					pageNo: 1,
					pageSize: 20
				},
				total: 20,
				status: 'loading'
			}
		},
		onLoad() {
			this.params.schoolId = this.vuex_schoolId
			this.sitePageFn()
		},
		onPullDownRefresh() {
			this.list = []
			this.params.pageNo = 1
			this.sitePageFn().then(()=>{uni.stopPullDownRefresh()})
		},
		onReachBottom() {
			if(this.total>this.list.length) {
				this.sitePageFn()
			}
		},
		methods: {
			async sitePageFn() {
				const {data: res} = await sitePage(this.params)
				this.params.pageNo ++
				this.list.push(...res.list)
				this.total = res.total
				if(this.list.length>=this.total) {
					 this.status = 'nomore'
				}else {
					 this.status = 'loading'
				}
				console.log(res)
			},
			searchFn(val) {
				console.log(val)
				this.params.name = val
				this.list = []
				this.params.pageNo = 1
				this.sitePageFn()
			}
		}
	}
</script>


<style lang="scss" scoped>
	.pageBgImg {
	  .search_Box {
		  margin-bottom: 20rpx;
	    searchrow {
	
	    }
	  }
	
	  .ul {
		  width: 100%;
	    .card {
			padding: 28rpx 30rpx;
			margin-bottom: 20rpx;
	      .name_row {
			  display: flex;
			  align-items: center;
	        .icon {
				width: 30rpx;
				height: 32rpx;
	        }
	
	        .name {
				font-size: 32rpx;
				font-weight: 600;
				color: #333333;
				margin-left: 10rpx;
	        }
	      }
	
	      .addres_row {
			  padding: 16rpx 0 36rpx 0;
			  display: flex;
			  align-items: center;
	        .icon {
	          width: 30rpx;
	          height: 32rpx;
	        }
	
	        .ads {
				font-size: 24rpx;
				color: #333333;
				margin-left: 10rpx;
	        }
	      }
	
	      .status_row {
			  font-size: 24rpx;
			  color: #686B73;
	        text {
				color: #1989FA;
				&.orange {
					color: #FF6A2A;
				}
	        }
	      }
	    }
	  }
	}
</style>