<template>
	<view>
		<ul style="list-style: none;padding-left: 0px;margin-top: 20rpx;">
			<li v-for="data in msgdata" :key="data.customerId" style="margin:0 auto 40rpx;padding: 20rpx;width: 90%;background-color: #f5f5f5;">
				<view class="slot-text-filename" @click="clickDetail(data)">
					<text>{{data.customerName}}</text>
				</view>
				<view class="slot-text-msg" @click="clickDetail(data)" style="display: flex;flex-direction: column;">
					<text class="slot-text-msg-data" style="font-size: 30rpx;">拜访时间：{{data.visitTime}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">拜访方式：{{data.visitMethod | filterMethod}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">回访记录：{{data.record}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">是否内部客户：{{data.isIn | filterIn}} </text>
				</view>
				<view class="slot-text-btn">
					<button class="btn-modify" @click="modifyF(data.visitId)">修改</button>
					<button class="btn-delete" @click="deleteF(data.visitId)">删除</button>
				</view>
			</li>
		</ul>
		<view  class="tips-box" v-show="isShow">
			<text style="line-height: 150rpx;">确认删除？</text>
			<view class="tips-btn">
				<button @click="close">取消</button>
				<button @click="handleDelete()">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	import { listVisit,delVisit } from "../../api/marketmini/index"
	export default {
		data() {
			return {
				visit:'visit',
				msgdata:[
					{
						customerId: 7,
						customerName: "周杰伦",
						isIn: 2,
						record: "新歌不错",
						visitId: "1",
						visitMethod: 1,
						visitTime: "2022-07-12"
					}
				],
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					// visitMethod: null,
					// isIn: null,
				},
				isShow:false,
				deleteid:''
			};
		},
		methods:{
			createF(){
				uni.navigateTo({
					url:"/pages/newAdd/newAdd"
				})
			},
			deleteF(data){
				// delCustomerInfo()
				this.isShow= true
				// this.$refs.popup.open('top')
				this.deleteid = data
				// console.log(this.deleteid)
				
			},
			close() {
				// this.$refs.popup.close()
				this.isShow = false
			},
			handleDelete(){
				delVisit(this.deleteid).then(data=>{
					this.getlist()
					this.close()
				})
			},
			modifyF(id){
				uni.navigateTo({
					url:'/pages/addVisit/addVisit?id='+id
				})
			},
			exportF(){
				console.log("导出")
			},
			getlist(){
				listVisit(this.queryParams).then(data=>{
					this.msgdata = data.rows
				})
			}
		},
		onShow() {
			this.getlist()
		},
		filters:{
			filterIn(data){
				switch(data){
					case '1': return "是";
					break;
					case '2': return "否";
					break;
					default: return "否";
				}
			},
			filterMethod(val){
				if(val==1){
					return "自驾"
				}else if(val==2){
					return "交通工具"
				}else if(val==3){
					return "步行"
				}else{
					return "其他"
				}
			}
		}
	}
</script>

<style lang="scss">
@import url("@/common/scss/core.scss");
.commonlist-text{
	margin: 50rpx 20rpx 20rpx;
}
/deep/ checkbox.round .wx-checkbox-input,
/deep/ checkbox.round .uni-checkbox-input {
	border-radius: 50%;
	width: 14px;
	height: 14px;
}
.slot-box {
	display: flex;
	flex-direction: row;
	align-items: center;
}

.slot-image {
	display: block;
	margin-right: 10px;
	width: 30px;
}

.slot-text {
	flex: 1;
	font-size: 13px;
	color: #000000;
	margin-right: 10px;
	.slot-text-msg{
		color: #8F8F94;
		font-size: 35rpx;
		.slot-text-msg-data{
			margin-right: 10px;
			font-size:20px ;
		}
	}
}
// .slot-box-checkbox{
// }
.slot-text-filename{
	font-size: 40rpx;
	border-bottom: 2px solid #c9c9cd;
}
.slot-text-btn{
	margin-top: 30rpx;
	display: flex;
	justify-content: space-around;
	button{
		width: 25%;
		font-size: 20rpx;
		color: white;
		background-color: blue;
	}
}
.tips-box{
	padding: 40rpx;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%,-50%);
	// height: 100px;
	width: 70%;
	background-color: #fff;font-size: 40rpx;
	border-radius: 20px;
	text-align: center;
	.tips-btn{
		display: flex;
		justify-content: space-around;
	}
	// span{
	// 	margin-bottom: 50rpx;
	// 	line-height: 100rpx;
	// }
	button{
		background-color: blue;
		color: #fff;
		font-size: 35rpx;
		width: 30%;
	}
		
}
</style>
