<template>
	<view style="height: 100vh;width: 100%;overflow: hidden;background-color: #F6F6F6;">
		<view style="flex:1;overflow: hidden;">
			<u-tabs bg-color="#f6f6f6" name="Name" :is-scroll="false" :list="typeList" :active-color="mainColor"
				:current="active" @change="changeHandler"  :activeFontSize="34" :bold="true" height="100"
				duration="0" font-size="28"></u-tabs>
		</view>
		<u-empty v-if="g.length == 0" text="暂无认证" mode="list"></u-empty>
		<view v-if="g.length>0">
			<scroll-view scroll-y="true" :enable-back-to-top="true" :enable-flex="true" @scrolltolower="lower" style="box-sizing: border-box;height:calc(100vh - 50px) ;padding:30rpx 30rpx 0;">
				<view style="margin-bottom:30rpx;position: relative;background: #FFFFFF;box-shadow: 0px 10px 50rpx 0px rgba(218, 220, 230, 0.85);border-radius: 30rpx;display: flex;align-items: center;padding:30rpx;"
					v-for="(x, i) in g" :key="i"  @click="godetails(x,i)"
				>
					<image :src="x.CoverImage" style="width: 130rpx;margin-right:30rpx;height: 130rpx;border-radius: 17rpx;" mode="aspectFill"></image>
					<view style="flex:1">
						<view style="font-size: 30rpx;font-weight: 600;color: #1F1F1F;">{{x.Name}}</view>
						<view style="font-size: 24rpx;color: #999;margin-top: 30rpx;">开业时间：{{x.OpenTime.split(' ')[0]}}</view>
					</view>
					<view style="position: absolute;top: 4rpx;right: 28rpx; color: #00DFB8;font-size: 24rpx;">{{x.AuditState==1?'未审核':(x.AuditState==2?'审核通过':'审核不通过')}}</view>
				</view>
				<u-loadmore
				  :status="status"	
				  :load-text="loadText"
				  :font-size="24"
				  :margin-top="20"
				  :margin-bottom="20"
				  bg-color="#f6f6f6"
				/>
			</scroll-view>
		</view>
		<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth= 'gbAuth'></auth>
	</view>
</template>

<script>
	import auth from "../../../components/auth/index.vue";
	export default {
		components: {
		  auth
		},
		data() {
			return {
				showAuth:false,
				mainColor:"",
				typeList:[{Id:0,Name:'全部'},{Id:1,Name:'未审核'},{Id:2,Name:'审核通过'},{Id:3,Name:'审核不通过'}],
				active:0,
				msg:{
					pageIndex:1,
					pageSize:20,
					Name:'',
					AuditState:0
				},
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				page_count:1,
				status: "loadmore",
				g: [],
			}
		},
		mounted() {
			uni.setNavigationBarTitle({
				title: '我的认证'
			});
			this.mainColor = this.$uiConfig.mainColor;
			this.u = uni.getStorageSync("mall_UserInfo");
			if (!this.u) {
			  this.u = {
				nickName: "未登录",
				avatarUrl: ""
			  };
			  this.showAuth = true;
			}else{
				this.init();
			}
			 
		},
		methods: {
			init() {
			  this.request2(
			  	{
			  		url: '/api/AppletTrade/GetAuthenticationPageList',
			  		data: this.msg
			  	},
			  	res => {
			  		if(res.resultCode==1){
						this.g = this.g.concat(res.data.pageData);
						 this.page_count = res.data.pageCount;
						 if (this.page_count == 1) {
						   this.status = "nomore";
					}
			  		}
			  	}
			  );
			},
			changeHandler(i) {
				this.active = i;
				this.msg.AuditState = this.typeList[i].Id;
				this.msg.pageIndex = 1;
				this.g= [];
				 this.init();
			},
			lower(e) {
			  if (this.msg.pageIndex < this.page_count) {
			    this.msg.pageIndex++;
				this.status = "loading";
			    this.init();
			  } else {
				this.status = "nomore";
			  }
			},
			godetails(x,i){
				uni.navigateTo({
					url: '/pages/kotra/firstShop/firstShop?Id='+x.Id +'&index='+i
				})
			},
			getsplice(index){
				this.g.splice(index,1)
			},
			reloadUserinfo() {
			  this.u = uni.getStorageSync("mall_UserInfo");
			  // this.showAuth=false;
			  this.init();
			},
			//关闭登录窗口
			gbAuth(){
				uni.navigateBack()
			},
		}
	}
</script>

<style>

</style>
