<template>
	<view class="">
		<navigation :showBack="true" :bgnum="false">
			<text class="big_title">
				{{i18n.transPaw}}
			</text>
		</navigation>
		<view class="main">
			<view class="big_title" v-if="borNum">
				{{i18n.settransPaw}}
				
			</view>
			<view class="big_title" v-if="borNum2">
			{{i18n.transPawAgain}}
			</view>
			<view class="title">
				{{i18n.Securetransaction}}<br>{{i18n.Securetransaction2}}
			</view>
			<u-message-input @finish="finish" inactive-color="#E0E5F2" active-color="#5B53FF" :width="94" :maxlength="6"
				mode="box" :focus="fes" :dot-fill="true" v-if="borNum"></u-message-input>
			<u-message-input @finish="finish2" :inactive-color="info?'#F16063':'#E0E5F2'" active-color="#5B53FF"
				:width="94" :maxlength="6" mode="box" :focus="fes" :dot-fill="true" v-if="borNum2" @change="back">
			</u-message-input>

			<view class="infoText" v-if="info">
				{{i18n.Passworddiscrepansies}}
			</view>

		</view>



	</view>
	</view>



</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	export default {
		data() {
			return {
				password: '',
				password2: '',
				msg: '',
				msgLength: 0,
				fes: false,
				borNum: true,
				borNum2: false,
				info: false,
				word: {},
				walletInfo: {},
				btcBalance: 0,
				ethBbalance: 0,
				trxBbalance: 0,
			}
		},
		watch: {

		},
computed: {
						i18n() {
							return this.$t('index')
						},
					},
		methods: {
	

			// 删除密码触发
			back(e) {
				if (e.length < 6) {
					this.info = false;
				}
			},
			finish2(e) {
				if (this.password != e) {
					this.info = true;
					return;
				} else {
	
				// 私鑰創建
		var createWalletName= uni.getStorageSync('createWalletName')
		var privateKey= uni.getStorageSync('privateKey')
	uni.setStorageSync('privateKey', this.wordInfo);
	try { 
	 this.$walletUtil.privateKeyEstablishWallet(createWalletName,privateKey,this.password);
	 			uni.showToast({
	 				title: this.$t('index').Setsuccessfully,
	 				icon: 'success',
	 				duration: 1500,
	 			})
	 			setTimeout(() => {
	 				uni.navigateTo({
	 					url: '../../wallet/index'
	 				})
	 			}, 1500)
	}
	catch(err){
		console.log(err,11)
	   uni.showToast({
	   	title: this.$t('index').Creationfailed,
	   	icon: 'none',
	   	duration: 1500,
	   })
	   
	}
		 
				
				
					this.info = false;
				}
				
			},
			// 第一次存密码
			finish(e) {
				this.password = e
				var that = this;
				that.borNum = false;
				that.borNum2 = false;
			
				setTimeout(() => {
					that.borNum2 = true;
				}, 50)

			},
		},
		onLoad() {

		}
	};
</script>
<style scoped>

</style>

<style>
	@import './index.css';
</style>
