<template>
	<view class="content">
		<view class="datalist" v-for="(item,index) in dataList">
			<view class="item">
				<view class="item_top">
					<view class="item_name">{{item.customerName}}</view>
					<view class="item_audit" ><span @click="auditSubmit(item)">审核</span></view>
				</view>
				<view class="item_lower">
					<view class="item_phone">{{item.customerPhone}}</view>
					<view class="item_date">{{item.updateDate}}</view>
				</view>
			</view>
		</view>
		<view v-show="isLoadMore">
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				dataList: [],
				currentPage:1,
				pageSize:10,
				isLoadMore: false, //是否加载中
				loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
			}
		},
		onShow() {
			this.getList()
		},
		onLoad() {},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		//下拉刷新
		onPullDownRefresh() {
			this.currentPage = 1
			this.pageSize = 10
			this.isLoadMore = false
			this.loadStatus = 'loading'
			this.getList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() { //上拉触底函数
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.isLoadMore = true
				this.currentPage += 1
				this.getList()
			}
		},
		methods: {
			getList() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.$api.doRequest('get', '/identityAuthenticationInfo/selectIdentityAuthenticationInfoPc', {
					currentPage: this.currentPage,
					pageSize: this.pageSize,
					searchType: 1, //searchType:1待审核
					compId: uni.getStorageSync('pcUserInfo').compId,
					searchKeyWord: "个人"
				}).then(res1 => {
					uni.hideLoading()
					if (res1.data.code == 200) {
						if (res1.data.data.records.length > 0) {
							this.isLoadMore = false
							this.loadStatus = 'loading'
						} else {
							this.isLoadMore = true
							this.loadStatus = 'nomore'
						}
						if (this.currentPage == 1) {
							this.dataList = res1.data.data.records
						} else {
							this.dataList = this.dataList.concat(res1.data.data.records)
						}
					}
				})
			},
			auditSubmit(val) {
				let obj = JSON.stringify(val)
				uni.navigateTo({
					url: '/pages/erpbusiness/customerSee?data=' + obj
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx 20rpx;
	}

	.datalist {
		.item {
			margin-bottom: 20rpx;
			background-color: #ffffff;
			padding: 30rpx 20rpx;
			border-radius: 10rpx;
			height: 200rpx;
			padding: 40rpx 40rpx;
		}

		.item_top,
		.item_lower {
			display: flex;
		}
		.item_lower{
			margin-top: 30rpx;
		}

		.item_name,
		.item_phone,
		.item_date,
		.item_audit {
			width: 50%;
		}
		.item_name{
			font-size: 36rpx;
			font-weight: 600;
		}
		.item_audit{
			font-size: 36rpx;
			font-weight: 600;
			color: #5C76DF ;
		}
		.item_phone,.item_date{
			color: #878C9C;
			font-size: 28rpx;
		}

		.item_date,
		.item_audit {
			text-align: right;
		}
	}
</style>
