<template>
	<view class="center">
		<view v-for="(item , index) in businessman" :Key="index" class="forList">
			<view class='flex' @click="navToDetailPage(item)">
				<view class="logo">
					粮商
				</view>
				<view class = "company" >{{item.compName}}</view>
				<view class = "company" v-if="item.customerTypeFlag == 1">{{item.customerName}}</view>
				<view class = "geren" v-if="item.customerTypeFlag == 1">  {{item.customerPhone}}</view>
				<view class = "geren" v-if="item.customerTypeFlag == 2">{{item.customerName}}    {{item.customerPhone}}</view>
				<view class="status"  v-if="item.authenticationStatus == '已认证'" >
					<image src="../../static/img/authentication/cert-personal@3x.png" style="width: 16px;height: 16px;top:3px;"></image>
					{{item.authenticationStatus}}
				</view>
				<view class="status1" v-if="item.authenticationStatus == '审核中'" >
					{{item.authenticationStatus}}
				</view>
				<view class="status2" v-if="item.authenticationStatus == '未通过'" >
					{{item.authenticationStatus}}
				</view>
				<view class="status3" v-if="item.authenticationStatus == '已覆盖'" >
					{{item.authenticationStatus}}
				</view>
			</view>
			<hr style="margin: 10px 0;">
			<view class="cu-tag yuan">
				<image src="../../static/img/authentication/selected(2).png" style="width: 16px;height: 16px;">设置默认</image>
			</view>
			<view class='cu-tag but'>更换手机号</view>
			<view class='cu-tag but' @click="companyEdit(item)">修改</view>
			<view class='cu-tag but' @click="deleteLS(item)">删除</view>
			


		</view>
		<button class="btn btns"  @click="Add">新增</button>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		name: "buy",
		data() {
			return {
				businessman: {},
				identityAuthenticationInfo: {},
				judge:"geren",
			}
		},
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		onLoad() {
			this.getList()
		},
		methods: {
			Add(){
				uni.navigateTo({
					url: `/pageD/identity/companyIdentity`
				})
			},
			getList() {
				this.identityAuthenticationInfo.commonId = this.userInfo.id
				this.$api.doRequest('get', '/identityAuthenticationInfo/selectIdentityAuthenticationInfo', {
						pageSize: 10,
						currentPage: 1,
						commonId: this.userInfo.id
					}, 'application/json;charset=UTF-8').then(res => {
						console.log("成功连接")
						this.businessman = res.data.data.records
					})
					.catch(res => {
						uni.showToast({
							title: res.errmsg,
							icon: 'none',
							duration: 2000
						})
					});
			},
			navToDetailPage(item){
				uni.navigateTo({
					url: `/pageD/identity/companyIdentityLook?id=${item.id}`
				})
			},
			deleteLS(item) {
				uni.showModal({
					// title: '登录提示',
					content: '身份信息删除后不可恢复，是否确定删除？',
					showCancel: true,
					confirmText: '确定',
					success: (e) => {
						this.$api.doRequest('post',
								'/identityAuthenticationInfo/api/deleteIdentityAuthenticationInfo', {
									id: item.id
								}, 'application/json;charset=UTF-8').then(res => {
								this.procurementPlanInfos = res.data.data.records
								if (res.errmsg == "Success") {
									this.$api.msg('删除成功！')
									this.getList()
									return
								}
			
							})
							.catch(res => {
								uni.showToast({
									title: res.errmsg,
									icon: 'none',
									duration: 2000
								})
							});
					},
					fail: () => {},
					complete: () => {}
				})
			},
			companyEdit(item) {
				uni.navigateTo({
					url: `/pageD/identity/companyIdentityEdit?id=${item.id}`
				})
			},
		}
	}
</script>

<style>
	.center {
		padding: 10px 20px;
		background-color: #F5F6FA;
	}

	.title {
		font-size: 22px;
		font-weight: 900;
		/* margin-top: 30px; */
		top: 50px;
		left: 24px;
		position: relative;

	}

	.company {
		font-size: 16px;
	    font-weight: 600;
		margin-top: 10px;
		display: inline-block;
		margin-left: 10px;
	}
	.geren{
		color: #AFB3BF;
		font-size: 14px;
		margin-top: 34px;
		margin-left: -54px;
	}

	.infos {
		width: 100%;
		display: inline-table;
	}

	.info {
		line-height: 20px;
	}

	.but {
		border: 1px solid #CDCDCD;
		border-radius: 10px;
		
	}

	.homePage {
		width: 101%;
		height: 200px;
		margin: 20px auto;
	}

	.logo {
		width: 35px;
		height: 35px;
		background-color: #E9F8F0;
		color: #22C572;
		text-align: center;
		line-height: 35px;
		padding: 0 3px;
		border-radius: 6px;
		display: inline-block;
		margin-top: 10px;
	}

	.forList {
		background: #FFFFFF;
		margin-top: 10px;
		padding: 10px 10px;
		border-radius: 16px;

	}
	.status{
	position: absolute;
	margin-top: 10px;
	right: 36px;
		color:#22C572;
	}
	.status1{
	position: absolute;
	margin-top: 10px;
	right: 36px;
	color:#FE6430;
	}
	.status2{
	position: absolute;
	margin-top: 10px;
	right: 36px;
	color: #FB1E1E;
	}
	.status3{
	position: absolute;
	margin-top: 10px;
	right: 36px;
	color: #AFB3BF;
	}	
	.btn {
		margin-top: 10px;
		background-color: #FFFFFF;
		border-radius: 25px;
		border: none;
	}
	
	.btns {
		background-color: #22C572;
	}
</style>
