<template>
	<view class="phone-navBar-box">
		<view @click="goUpPage" class="nav-bar-icon"></view>
		<text class="nav-bar-title">信用查询</text>
	</view>
	<view>
		<view> 姓名：{{data.userInfo.realName}} </view>
		<view> 身份证号：{{data.userInfo.idcard}} </view>
		
		<button @click="handleUpdate">重新查询</button>
	</view>
	
	<view>
		<view>1 失信人查询 </view>
		<view >
			<view v-if="!data.userInfo.createTime">未查询</view>
			<view v-else>查询时间：{{data.userInfo.createTime}}</view>
		</view>
		<view>
			“失信人”是指被执行人具有履行能力而不履行生效法律文书确定的义务，俗称“老赖”。
		</view>
		<view v-if="data.userInfo.createTime">
			<view v-if="data.userInfo.shixing">验证通过</view>
			<view v-if="!data.userInfo.shixing">验证不通过</view>
		</view>
	</view>	
	
	<view>
		<view>2 限制高消费 </view>
		<view >
			<view v-if="!data.userInfo.createTime">未查询</view>
			<view v-else>查询时间：{{data.userInfo.createTime}}</view>
		</view>
		<view>
			“限制高消费令”是指国家针对拒不执行法院生效法律文书的“老赖”，采取“限制高消费”的措施。
		</view>
		<view v-if="data.userInfo.createTime">
			<view v-if="data.userInfo.xiangao">验证通过</view>
			<view v-if="!data.userInfo.xiangao">验证不通过</view>
		</view>
	</view>	
	
	<view>
		<view>3 法院被执行人查询 </view>
		<view >
			<view v-if="!data.userInfo.createTime">未查询</view>
			<view v-else>查询时间：{{data.userInfo.createTime}}</view>
		</view>
		<view>
			“法院被执行人”是指在法定的上诉期满后，或终审判决做出后，未履行法院判决或仲裁裁决，并进入执行程序的当事人。
		</view>
		<view v-if="data.userInfo.createTime">
			<view v-if="data.userInfo.zhixing">验证通过</view>
			<view v-if="!data.userInfo.zhixing">验证不通过</view>
		</view>
	</view>	
	
</template>

<script setup>
	import * as jzApi from "@/api/jiazheng.js"
	import {onLoad} from "@dcloudio/uni-app"
	import {ref,reactive} from "vue"
	
	const data = reactive({
		userId: null,
		userInfo: null,
		loading: false,
	})
	
	onLoad((options) => {
		data.userId = options.userId;
		
		getUserInfo();
	})
	
	function getUserInfo() {
		jzApi.jiazhengXinyongInfo({userId: data.userId }).then(res => {
			data.userInfo = res.data;
		})
	}
	
	function handleUpdate() {
		if (data.loading) {
			uni.showToast({
				title: '查询中，请稍等'
			})
			return;
		}
		data.loading = true;
		jzApi.jiazhengXinyongUpdate({userId: data.userId}).then( res => {
			if (res.data) {
				uni.showToast({
					title: '查询成功'
				})
				getUserInfo()
			}
		}).finally(() => {
			data.loading = false;
		})
	}
	
	function goUpPage() {
		uni.navigateBack()
	}
	
</script>

<style>

</style>
