<template>
	<NavBar />
	<view class="container">
		<view class="swiper">
			<HomeSwiper :position="1" />
		</view>
		<view class="title">
			<PageTitle :title="$t('personal.personalData')" />
		</view>
		<uni-data-select :localdata="infoTypeOptions" :clear="false" v-model="infoType" style="margin-top: 16px"></uni-data-select>
		<view v-if="infoType === 'personal'"><PersonalInformation :authStatus="authStatus" :ifImprove="ifImprove" /></view>
		<view v-if="infoType === 'financial'"><FinancialInformation /></view>
		<view v-if="infoType === 'accountSecurity'"><AccountSecurity /></view>
	</view>
</template>

<script>
import PersonalInformation from './personalInformation/index.vue';
import FinancialInformation from './financialInformation/index.vue';
import AccountSecurity from './accountSecurity/index.vue';
import { getPersonalAuthStatus , getIfImproveUser } from '@/services/user.ts';
export default {
	data() {
		return {
			infoType: 'personal',
			infoTypeOptions: [
				{ text: this.$t('form.personalData.personalInformation.title'), value: 'personal' },
				{ text: this.$t('form.personalData.financialInformation.title'), value: 'financial' },
				{ text: this.$t('form.personalData.accountSecurity.title'), value: 'accountSecurity' }
			],
			authStatus: {},
      ifImprove:0
		};
	},
	methods: {
		async getAuthStatus() {
			const res = await getPersonalAuthStatus();
			if (res && res.code === 0) {
				this.authStatus = res.data;
			}
		},
    async getImproveUser(){
      const res = await getIfImproveUser();
      if (res && res.code === 0) {
        this.ifImprove = res.data;
      }
    }
	},
	onShow() {
		if (this.infoType === 'personal') {
			this.getAuthStatus();
      this.getImproveUser();
		}
	},
	components: {
		PersonalInformation,
		FinancialInformation,
		AccountSecurity
	}
};
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
