<template>
	<view class="content">
		<view class="container">
			<headers :titles="titles"><uni-icons type="arrow-left" color="#fff" size="22px"></uni-icons></headers>
			<view class="box_" @click="goMerDetail(item)" v-for="(item,index) in incompleteMerchantList" :key="index">
				<view class="">
					<view style="font-size: 18px;margin-bottom: 10px;">{{item.merchantName}}</view>
					<view class="">商户联系人:{{item.merchantLegalName}}</view>
					<view class="time">创建时间：{{item.createDate}}</view>
				</view>
				<u-icon name="arrow-right" size="14"></u-icon>
			</view>
			<u-loadmore :status="status" v-if="show == true" />
		</view>

	</view>
</template>

<script>
	import request from '../../utils/request.js'
	import headers from '../../components/header/headers.vue'

	export default {
		data() {
			return {
				limt: 10,
				page: 1,
				totalPage: 0,
				incompleteMerchantList: [],
				titles: "待完善商户",
				msg: "1",
				dataList: [],
				show: false,
				status: 'loading',
				nomoreText: '没有更多了'
			}
		},
		onShow() {
			uni.showLoading({
				title: '加载中'
			});
			this.limit = 10,
				this.page = 1,
				this.totalPage = 0,
				this.incompleteMerchantList = [],
				this.getIncompleteMerchantList()

		},
		onPullDownRefresh() {
			this.limit = 10,
				this.page = 1,
				this.totalPage = 0,
				this.incompleteMerchantList = [],
				this.getIncompleteMerchantList();
			console.log("刷新");
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			this.show = true
			if (this.incompleteMerchantList.length < this.totalPage) {
				this.page++
				this.getIncompleteMerchantList()
			} else {

				this.status = 'nomore'
				uni.showToast({
					title: "没有下一页数据",
					icon: "none"
				})
			}

		},
		components: {
			headers

		},
		methods: {
			goMerDetail(data) {
				if (data.areaType == '7') {
					uni.navigateTo({
						url: '/homePages/merchantsMerchant/merchantsMerchant?merchantId=' + data.id
					})
				} else if (data.areaType == '4') {
					uni.navigateTo({
						url: '/homePages/enterpriseMerchant/enterpriseMerchant?merchantId=' + data.id
					})
				}


			},
			getIncompleteMerchantList() {
				request({
					url: '/app/uaAgent/incompleteMerchant',
					method: 'post',
					data: {
						limit: this.limit,
						page: this.page
					}
				}).then(res => {
					if (res.data) {
						if (this.page != 1) {
							this.incompleteMerchantList = this.incompleteMerchantList.concat(res.data)
						} else {
							this.incompleteMerchantList = res.data
						}
						this.totalPage = res.total
						console.log("incompleteMerchantList:", this.incompleteMerchantList);
					}
					uni.hideLoading();
				})
			},
			goback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #f4f5f6;

		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f5f6;
		box-sizing: border-box;
		padding-top: 88px;
	}

	.box_ {
		width: 100%;
		display: flex;
		box-sizing: border-box;
		padding: 10px;
		background: #fff;
		justify-content: space-between;
		border-bottom: 1px solid #f4f5f6;
	}

	.title- {
		margin-bottom: 15px;
	}

	.img_ {
		width: 100px;
		height: 100px;
		background: #006b1e;
		border-radius: 4px;
		overflow: hidden;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.right-box {
		width: 70%;

	}

	.hui- {
		color: #838384;
		margin-bottom: 10px;
	}

	.time {
		font-size: 12px;
		color: #787878;
		margin-top: 10px;
	}
</style>