<template>
	<view class="">
		<navigation :showBack="true">
			{{i18n.Importviaprivatekey}}
		</navigation>
		<view class="main">
			<view class="title">
				{{i18n.Privatekeyimportverification}}
			</view>
			<view class="title2">
				{{i18n.privatekeyanddo}}
			</view>
			<textarea v-model="wordInfo" class="textareaa" :placeholder="teee"
				placeholder-style="color:rgb(224,229,242)">

		</textarea>


			<u-button class="custom-style" @click="confirm">{{i18n.Confirm}}</u-button>


			<view class="info_con" v-if="show">
				<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show=false">
				</image>
				<image src="../../../../static/tongyonh/Frame60.png" mode="aspectFit" class="img"></image>
				<view class="info">
					{{i18n.Successful}}
		 	</view>
				<view class="text">
					{{i18n.backCom}}
				</view>
				<view class="btn">
					{{i18n.Confirm}}
				</view>
			</view>

			<view class="info_con" v-if="show2">
				<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show2=false">
				</image>
				<image src="../../../../static/tongyonh/Subtract.png" mode="aspectFit" class="img"></image>
				<view class="info">
					{{i18n.seed}}
				</view>
				<view class="text">
					{{i18n.wrongWord}}<br>{{i18n.wrongWord2}}
				</view>
				<view class="btncon">
					<view class="can" @click="show2=false">
						{{i18n.Cancel}}
					</view>
					<view class="con" @click="restart">
						{{i18n.Confirm}}
					</view>

				</view>
			</view>



			<u-mask :show="show" z-index="10"></u-mask>
			<u-mask :show="show2" z-index="10"></u-mask>
		</view>

	</view>
	</view>

</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	export default {
		data() {
			return {
				teee:this.$t('index').enteryourprivatekey,
				mnemonics: [],
				wordArr: [],
				show: false,
				index: 0,
				returnIndex: 0,
				// 拿来对比的
				mnemonics2: [],
				show2: false,
				wordInfo: '',
				walletInfo: {},
				go: false,
				name: '',
				typename:'',
				info: {},
				go:true,
			};
		},
		computed: {
						i18n() {
							return this.$t('index')
						},
					},
		methods: {
			// 成功去到设置交易密码
			goTranPaw() {
				uni.navigateTo({
					url: '/pages/menu/backUp/transPaw/index'
				})
			},
			// 失败重刷新
			restart() {
				uni.redirectTo({
					url: '../backUp4/index'
				})
			},
			// 提交
			confirm() {
				this.walletInfo = uni.getStorageSync('walletInfo');
				if (this.wordInfo == '') {
					uni.showToast({
						title: this.$t('index').beempty,
						icon: 'none',
						duration: 1500
					})
					return;
				}

				this.typename = uni.getStorageSync('createWalletName')
				 console.log(this.walletInfo[this.typename].length,1111)
				console.log(this.typename)
						this.walletInfo = uni.getStorageSync('walletInfo');
						for(var i=0;i<this.walletInfo[this.typename].length;i++){
							console.log(i)
							console.log(this.walletInfo[this.typename][i].privateKey,111)
							console.log( this.wordInfo,222)
							if( this.wordInfo==this.walletInfo[this.typename][i].privateKey){
							uni.showToast({
								title: this.$t('index').beenimported,
								icon: 'none',
								duration: 1500
							})
							this.go=false;
							}
					
						}
						if(this.go){
						uni.setStorageSync('privateKey', this.wordInfo);
						uni.navigateTo({
							url:'/pages/menu/backUp/transPawKey/index'
						})	
						}
				
			},



		},
		onLoad(item) {

			if (item != '' || item != undefined) {
				uni.setStorageSync('createWalletName', item.name)
			}
		},
	};
</script>
<style scoped>
	.custom-style {
		height: 112rpx;
		text-align: center;
		color: #fff;
		background-color: #5B53FF !important;
		border-radius: 40rpx;
		margin-top: 50rpx;
	}

	.u-default-hover {
		background-color: #5B53FF !important;
		border-radius: 40rpx !important;
		color: #fff !important;
		border: none;
	}
</style>

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