<template>
	<view>
		<view class="search">
			<u-search @custom="search"  border-color="#fff" bg-color="#fff" placeholder="输入商家名称" v-model="keyword"></u-search>
		</view>
		<view class="content">
			<view class="flex text-bold" style="padding:0 20rpx 0 40rpx">
				<view class="area1">
					加入时间
				</view>
				<view class="area2">
					商户名称
				</view>
				<view class="area3">
					审核状态
				</view>
			</view>
			<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
				:up="upOption">
			<navigator :url="'/pagesB/pages/shop-detail?id='+item.id" hover-class="none" class="item" v-for="(item,index) in list" :key="index">
				<view class="area1 flex flex-direction justify-end padding-left-20" >
					{{item.createTime}}
				</view>
				<view class="area2 text-cut-1">
					{{item.name}}
				</view>
				<view class="area3">
					<text class="text-green" v-if="item.auditStatus=='PASS'">审核通过</text>
					<text class="text-red" v-if="item.auditStatus=='FAIL'">审核失败</text>
					<text class="text-red" v-if="item.auditStatus=='STOP'">已停用</text>
					<text class="text-orange" v-if="item.auditStatus.includes('WAITING')">待审核</text>
				</view>
			</navigator>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				list:[],
				downOption:{
					auto:false
				},
				total:0,
				keyword:''
			}
		},
		methods: {
			downCallback() {
				setTimeout(() => {
					uni.showToast({
						title: "刷新成功",
						icon: "none"
					})
					this.mescroll.resetUpScroll();
				}, 1000)
			},
			upCallback(mescroll) {
				let params = {
					agenter:this.vuex_userId,
					current:mescroll.num,
					size:mescroll.size,
				}
				if (!this.$isEmpty(this.keyword)) {
					params.name=this.keyword
				}
				try {
					this.$api.shop.list(params).then(res => {
						let data = res.data.records
						let total = res.data.total
						this.total=total
						mescroll.endBySize(data.length, total);
						if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
						this.list = this.list.concat(data); //追加新数据
					})
				} catch (e) {
					this.mescroll.endErr()
				}
			},
			search(){
				this.mescroll.resetUpScroll();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search{
		padding: 30rpx 30rpx 50rpx;
	}
	
	.tips{
		color: #ff9900;
		padding: 30rpx 30rpx 0rpx;
	}
	
	
	.content{
		.area1 {
			width: 50%;
		}
		
		.area2 {
			width: 30%;
		}
		
		.area3 {
			width: 20%;
		}
		
		.item{
			margin-top: 20rpx;
			background-color: #FFFFFF;
			display: flex;
			padding-top: 20rpx;
			padding-bottom: 20rpx;
		}
	}
</style>
