<template>
	<view>
		<view class="tips">为了更方便的为您服务，请先完善认证信息！</view>
		<!--<step-bar :stepList="stepList" :active="active"></step-bar>-->
		<first v-if="active === '0' || active === 0" ref="first" @firstSubmit="backSubmit"></first>
		<second v-if="active === '1' || active === 1" ref="second" @secondSubmit="backSubmit" :stepLength="stepLength"></second>
		<three v-if="active === '2' || active === 2"></three>
		<view class="backLogin" @click="logout">
			退出登录
		</view>
	</view>
</template>

<script>
	import stepBar from '@/components/step-bar/index.vue'
	import first from './step/first.vue'
	import second from './step/second.vue'
	import three from './step/three.vue'
	export default{
		data() {
			return {
				stepList: ['实名认证','银行卡认证'],
				active: 0,
				stepLength: 2
			}
		},
		onLoad(options){
			if (Number(options.active) === 2) {
				this.stepList.push('个人签名')
				this.stepLength = 3
			}
			this.active = options.active
		},
		components: {stepBar,first, second, three},
		methods: {
			logout() {
				this.$store.dispatch('LogOut').then(() => {
					uni.reLaunch({
						url: '/pages/login/login'
					})
					this.$store.dispatch('clearAuthState')
					this.$store.dispatch('endRefreshNewsTimer')
				})
			},
			backSubmit(){
				this.sign()
			},
			sign(){
				this.loading = false
				if (Number(this.active)+1 === this.stepList.length) {
					if (this.stepList.length === 2) {
						uni.switchTab({
							url: '/pages/index/index'
						})
					} else if (this.stepList.length === 3) {
						uni.navigateBack({
							delta: 1
						})
					}
				} else {
					this.active++
				}
			}
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
	.tips{
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
		line-height: 28rpx;
		margin: 45rpx 0 50rpx 30rpx;
	}
	.backLogin{
		width: 128rpx;
		height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #1C66FF;
		line-height: 45rpx;
		position: absolute;
		bottom: 100rpx;
		left: 40%;
	}
</style>
