<template>
	<view>
		<ul style="list-style: none;padding-left: 0px;margin-top: 20rpx;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.company}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">职位：{{data.position}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">电话：{{data.phone}}</text>
					<text class="slot-text-msg-data" style="font-size: 30rpx;">年龄：{{data.age}}&nbsp;&nbsp;&nbsp;性别：{{data.sex|filterSex}}</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.customerId)">修改</button>
					<button class="btn-delete" @click="deleteF(data.customerId)">删除</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 { listCustomerInfo,delCustomerInfo } from "../../api/marketmini/index"
	export default {
		data() {
			return {
				isShow:false,
				visit:'visit',
				msgdata:[
					{
						address: "深圳南山",
						age: 23,
						company: "腾讯",
						createBy: null,
						createTime: "2022-07-12 11:47:31",
						createUserId: null,
						customerId: "1",
						customerName: "李嘉欣",
						isIn: 1,
						params: {},
						phone: 18313121312,
						position: "开发员",
						remark: "地中海发型123",
						searchValue: null,
						sex: 0,
						updateBy: null,
						updateTime: "2022-07-12 11:53:14",
						updateUserId: null,
						year: "2022"
					}
				],
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					// customerName: null,
					// company: null,
					// address: null,
					// isIn: null,
					// sex: null,
					// year: null,
					// phone: null,
				},
				deleteid:''
			};
		},
		filters:{
			filterSex(data){
				switch(data){
					case 0 :return "男";
					break;
					case 1 :return "女";
					break;
					case 2: return "未知";
					default: return  "未知"
				}
			},
			filterIn(data){
				switch(data){
					case '1': return "是";
					break;
					case '2': return "否";
					break;
					default: return "否";
				}
			}
		},
		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(){
				delCustomerInfo(this.deleteid).then(data=>{
					this.getlist()
					this.close()
				})
			},
			modifyF(data){
				// console.log("修改")
				uni.navigateTo({
					url:'/pages/addCustomer/addCustomer?id='+data
				})
			},
			exportF(){
				console.log("导出")
			},
			getlist(){
				listCustomerInfo(this.queryParams).then((data)=>{
					this.msgdata = data.rows
				})
			}
		},
		onShow(){
			this.getlist()
		}
	}
</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>
