<template>
	<view class="box">
		<view style="width: 690rpx;margin: 0 auto;margin-top: 20rpx;">
			<u-search @search='searchinfo()' :show-action='false' placeholder="请输入" v-model="keyword"></u-search>
		</view>
		<!-- <view @click="searchinfo()">搜索</view> -->
		<view class="content" style="background: #F8F8F8;">
			<view class="content-tips" v-for="(item,index) in recordList" :key='index'  @click="tapThevisiting(item)">
				<view class="content-first">
				<view class="left">
					<!-- <view class="img">{{item.agentName.slice(0,1)}}</view> -->
					<view class="name">{{item.agentName}}</view>
					<view class="status" v-if="item.replaceReception==1">代接待</view>
					<view style="margin-left: 6rpx;margin-top: 11rpx;">{{item.receptionStatusName || ''}}</view>
				</view>
				
				<view class="right" v-if="item.recording!=0">
					<view style="margin-right: 6rpx;">{{item.validInvalidName||''}}</view>
					<view v-if="methodsisshow==true">
						<text style="color: red;"  v-if="item.taboo==1">违禁接待</text>
						<text v-if="item.taboo==1"> |</text>
					</view>
					<!-- <view class="point"></view> -->
					<view v-if="item.markAdvisor==0" class="">未标记</view>
					<view v-if="item.markAdvisor==1" class="">已标记</view>
				</view>
				<view class="right"  v-else>
					<view class="">无录音</view>
				</view>
				</view>
				<view class="content-sec">
					<view class="left">
						<view class="cus">客户：{{item.name || '--'}} |</view>
						<view class="arriveNum">{{item.visitRecord || "0"}}次到访</view>
					</view>
					<view class="right">
						{{item.fraction || '0'}}% 
						<!-- | {{item.fraction || '0'}}分 -->
					</view>
				</view>
				<view class="content-last">
					{{item.createTime}} | {{item.mm || '0'}}分钟
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				keyword:'',
				recordList:[],
				buildingID:'',
				nextPage:1,
				totalRecord:"",
				methodsisshow:false,
				userInfo:{}
			}
		},
		onShow() {
			this.userInfo = uni.getStorageSync('weapp_session_userInfo_data');
			if(this.userInfo.dataCode==6 || this.userInfo.dataCode==3){
				this.methodsisshow=false;
			}else{
				this.methodsisshow=true;
			}
			this.buildingID = uni.getStorageSync('buildingID').id;
			this.nextPage=1;
			this.recordList=[];
		},
		onReachBottom() {
			if(this.totalRecord==this.nextPage){
				uni.showToast({
					icon:'none',
				    title: '到底了',
				    duration: 2000
				});
				return
			}else{
				this.nextPage+=1;
				this.getMyCustom();
			}
		},
		methods:{
			tapThevisiting(item) {
				if(item.status==0){
					uni.showToast({
						icon: "none",
						title: "排队中"
					})
					return
				}else{
					const parames = {
						pageNum: 1,
						pageSize: 100,
						query: {
							customerId: item.id,
						}
					}		
					var item={
						bg:0,
						customerId:item.id,
					}
					uni.setStorageSync("entrance", 1); //写入缓存
					uni.setStorageSync("searchobj", item); //写入缓存
					this.$u.post("/corpus/findByPage", parames).then(res => {
						if(res==null){
							uni.showToast({
								icon: "none",
								title: "暂无音频"
							})
							return
						}else{
							let newobj = res[0];
							if(res[0].merge==0){
								uni.navigateTo({
									url: `/pages/mine/details2?customerId=${newobj.customerId}&status=${newobj.status}&stateisshow=${"2"}`
								})
							}else{
								uni.navigateTo({
									url: `/pages/mine/details?customerId=${newobj.customerId}&status=${newobj.status}&stateisshow=${"1"}`
								})
							}
						}
					})
				}
				
			},
			searchinfo(){
				this.nextPage=1;
				this.recordList=[];
				this.getMyCustom();
			},
			getMyCustom(){
				var parames = {
					pageNum: this.nextPage,
					pageSize: 10,
					query: {
						projectId:this.buildingID,
						time:1,
						nameOrPhone:this.keyword
					}
				};
				this.$u.post("/customer/findbypage", parames).then(data => {
					var list = data.results || [];
					this.recordList = [...this.recordList, ...list];
					this.totalRecord=data.totalPage;
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 100%;
		height: 100vh;
		background: #FFFFFF;
	}
	.content{
		.content-tips{
			background: #fff;
			padding: 0 20rpx;
			box-sizing: border-box;
			overflow: hidden;
			margin-top: 20rpx;
			.content-first{
				margin-top: 19rpx;
				display: flex;
				justify-content: space-between;
				.left{
					display: flex;
					.img{
						width: 52rpx;
						height: 52rpx;
						background: #FFFFFF;
						border: 1px solid #C9C9C9;
						border-radius: 50%;
						text-align: center;
						line-height: 52rpx;
					}
					.name{
						font-weight: 600;
						color: #333333;
						// margin-left: 20rpx;
						margin-top: 11rpx;
					}
					.status{
						width: 110rpx;
						height: 42rpx;
						background: #FFF9F5;
						border-radius: 4rpx;
						font-size: 26rpx;
						font-weight: 400;
						color: #EC8D49;
						line-height: 42rpx;
						text-align: center;
						margin-left: 19rpx;
						margin-top: 11rpx;
					}
				}
				.right{
					display: flex;
					margin-top: 11rpx;
					.point{
						width: 12rpx;
						height: 12rpx;
						background: #2B6EFF;
						border-radius: 50%;
						margin-right: 9rpx;
						margin-top: 16rpx;
						
					}
				}
			}
			
			
			.content-sec{
				display: flex;
				justify-content: space-between;
				margin-top: 19rpx;
				.left{
					display: flex;
					.cus{
						font-size: 30rpx;
						font-weight: 400;
						color: #666666;
						line-height: 30rpx;
					}
					.arriveNum{
						font-size: 30rpx;
						font-weight: 400;
						line-height: 30rpx;
						margin-left: 10rpx;
					}
				}
				.right{
					width: 120rpx;
					height: 46rpx;
					background: #F4F8FD;
					border-radius: 6rpx;
					text-align: center;
					line-height: 46rpx;
					font-weight: 400;
					color: #2671E2;
				}
			}
			.content-last{
				margin: 30rpx 0;
				font-size: 30rpx;
				font-weight: 400;
				color: #666666;
				line-height: 30rpx;
			}
				
		}
	}
</style>
