<template>
	<view class="car">
		<view class="cartop">
			<view class="topa flexc">
				<!-- <image :src="reset" class="resetimg" @click="getReset"></image>
				<picker mode="date"   @change='bindDateChangea'>
					<view class="chekt flexc">
						<view>{{cxrq|| "选择日期"}}</view>
						<image :src="up"></image>
					</view>
				</picker> -->
				<view class="search flexc">
					<image :src="search"></image>
					<input placeholder="请输入姓名进行搜索"  v-model="text"/>
					<view class="btn" @click="getConfirm">搜索</view>
				</view>
			</view>
			<view class="flexcj conttips">
				<view class="toptip">当前统计人数共<text>274</text>人</view>
				<view class="topsort" @click="tallflag=!tallflag">
					{{tallflag?"从高到低":"从低到高"}}
					<view class="imgs" v-if="tallflag">
						<image :src="up"></image><image :src="downa"></image>
					</view>
					<view class="imgs" v-else>
						<image :src="upa"></image><image :src="down"></image>
					</view>
				</view>
			</view>
			
			<!-- <view class="tabtop flexc">
				<view class="tabt" :class="ttopval==ite.val?'act':''" v-for="(ite,idx) in ttoplist" :key="idx" @click="getTabtop(ite.val)">{{ite.tit}}</view>
			</view> -->
		</view>
		<!-- 列表 -->
		<view class="carlists">
			<car-list :datainfo="list" :topval="ttopval" :wtdt="wtdt" type='readcount' @getDetail="getDetail"></car-list>
		</view>
		<loading></loading>
	</view>
</template>

<script>
	import config from '@/config'
	const baseUrl = config.baseUrl
	import carList from "@/manage/components/car/list.vue"
	import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
	export default{
		components:{carList},
		data(){
			return{
				reset:require('@/work/static/car/reset.png'),
				search:require('@/work/static/car/search.png'),
				up:require('@/manage/static/community/up.png'),
				upa:require('@/manage/static/community/upa.png'),
				down:require('@/manage/static/community/down.png'),
				downa:require('@/manage/static/community/downa.png'),
				cxrq:"",
				text:'',
				list:[{tit:'皖A IC520',type:1,right:0},{tit:'晋E KD783',type:2,right:0},],
				pageSize: 10,
				pageNum: 1,
				reachflag: true,
				wtdt:'',
				tallflag:true,
				ttopval:'0',
				ttoplist:[{tit:'全部',val:0},{tit:'待回复',val:1},{tit:'已回复',val:2},{tit:'已完成',val:2}]
			}
		},
		onLoad: function() {
		
		},
		// 上拉触底加载更多触发事件
		onReachBottom() {
			if (this.reachflag) {
				this.pageNum++
				this.getDataFn()
			}
		},
		methods:{
			checkPermi, checkRole,
			getDetail(){
				this.$tab.navigateTo("/work/pages/service/complaintdetail")
			},
			getTabtop(val){
				this.ttopval=val
			},
			getConfirm(){
				this.getrefreshData()
			},
			getReset(){
				this.cxrq='';
				this.text='';
				this.getrefreshData()
			},
			getrefreshData(){
				this.pageNum=1;
				this.list=[];
				this.reachflag=true;
				this.getDataFn()
			},
			getTabFn(val){
				this.tabval=val
			},
			bindDateChangea(e){
				var val=e.detail.value;
				this.cxrq=val;
			},
			getDataFn(){
				var params={
					pageSize:this.pageSize,
					pageNum: this.pageNum,
				}
				params.noticeType=this.tabidx
				getNoticeList(params).then(res=>{
					if(res.code==200){
						if (res.rows.length < this.pageSize) {
							this.reachflag = false
							this.wtdt = '到底了~';
						} else {
							var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum -	1)
							if (num < res.total) {
								this.reachflag = true
								this.wtdt = ''
							} else {
								this.reachflag = false
								this.wtdt = '到底了~';
							}
						}
						var newArr=JSON.parse(JSON.stringify(res.rows))
						newArr.forEach(ite=>{
							ite.right=0;
						})
						// console.log(newArr,555)
						if (this.pageNum == 1) {
							this.list = newArr;
						} else {
							this.list = this.list.concat(newArr)
						}
					}else{
						this.$toast(res.msg)
					}
				})
				
			},
		}
	}
</script>
<style>
	page{background: #F3F3F0;}
</style>
<style lang="scss" scoped>
.car{padding: 172rpx 0 0rpx;}
.cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
	.topa{padding: 20rpx;padding-bottom: 30rpx;
		.resetimg{width: 36rpx;height: 36rpx;margin-right: 24rpx;flex: 0 0 auto;}
		.chekt{min-width: 180rpx;
			view{font-weight: 500;font-size: 26rpx;color: #272727;flex: 1;}
			image{width: 24rpx;height: 16rpx;margin-left: 18rpx;flex: 0 0 auto;}
		}
		.search{flex: 1;margin-left: 16rpx;height: 64rpx;background: #EEEEEE;border-radius: 32rpx;border: 2rpx solid #E6E6E6;padding-left: 24rpx;box-sizing: border-box;
		image{width: 32rpx;height: 34rpx;margin-right: 22rpx;flex: 0 0 auto;}
		input{flex: 1;font-size: 26rpx;color: #272727;}
		.btn{width: 100rpx;height: 64rpx;background: #3565ED;border-radius: 32rpx;flex: 0 0 auto;font-weight: bold;text-align: center;line-height: 64rpx;
font-size: 26rpx;
color: #FFFFFF;}
		}
	}
	.tabtop{padding-bottom: 40rpx;padding-top: 24rpx;
		.tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
			&.act{font-weight: bold;font-size: 32rpx;color: #272727;
			&::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
			}
		}
	}
}
.conttips{padding: 18rpx 32rpx;background: #F3F3F0;}
.toptip{font-weight: 500;font-size:26rpx;color: #666666; line-height: 36rpx;
	text{color: #4671ED;display: inline-block;font-weight: bold;padding: 0 6rpx;}
}
.topsort{font-size: 26rpx;color: #FE5A0E;display: flex;align-items: center;
	.imgs{margin-left: 8rpx;height: 34rpx;display: flex;align-items: center;
		image{width: 12rpx;height: 20rpx;margin-left: 4rpx;}
	}
	
}
.carlists{padding: 0 18rpx;}
</style>