<template>
	<view class="">
		<navigation :showBack="true" :bgnum="true">
			<text class="big_title">
				Choose a wallet
			</text>
			<text class="renYou" @click="goMwallet()">Manage</text>
		</navigation>
		<view class="main flexx">
			<view class="imgcon">
				<image @click="getHeight('one')" id="one"  src="../../../../static/tongyonh/filter-left.png" mode="aspectFit" class="letConimg"></image>
			    <image @click="getHeight('btc')" id="btc" src="../../../../static/tongyonh/bye.png" mode="aspectFit" class="letConimg"></image>
			<image @click="getHeight('eth')" id="eth" src="../../../../static/tongyonh/Frame3299.png" mode="aspectFit" class="letConimg"></image>
			<image @click="getHeight('trx')" id="trx" src="../../../../static/tongyonh/tron1.png" mode="aspectFit" class="letConimg"></image>
			</view>
			
			
			
    <view class="bot_con">
    	   <view class="tiao" id="tiao">
    	   	<!--  -->
    	   </view>
    		<view  class="item flexx" @click="gou(item,index)" v-for="item,index in walletInfoBTC" v-if="type=='btc' || typeBoll==false">
    		 <view class="left flex">
    		 	<image src="../../../../static/tongyonh/btc_icon.png" mode="aspectFit" class="img1"></image>
    		   <view class="textcon"> 
    		   	<view class="text1">
    		   		{{item.coinList[0].name}}
    		   	</view>
    			<view class="text2">
    				{{item.address}}
    			</view>
    		   </view>
    		 </view>
				 <view class="gou" v-if="num==item.privateKey">
				 	<image src="../../../../static/tongyonh/Shape.png" mode="aspectFit" class="img"></image>
				 </view>
    		 <view class="rig">
    		0.00
    		 </view>
    		</view>
    		
    	<view class="item flexx pur"  @click="gou(item,index)"   v-for="item,index in walletInfoETH" v-if="type=='eth' || typeBoll==false">
    	 <view class="left flex">
    	 	<image src="../../../../static/tongyonh/ETH_icon.png" mode="aspectFit" class="img1"></image>
    	   <view class="textcon"> 
    	   	<view class="text1">
    	   	{{item.coinList[0].name}}
    	   	</view>
    		<view class="text2">
    		{{item.address}}
    		</view>
    	   </view>
    	 </view>	
		 <view class="gou" v-if="num==item.privateKey">
		 	<image src="../../../../static/tongyonh/Shape.png" mode="aspectFit" class="img"></image>
		 </view>
    	 <view class="rig">
    	0.00
    	 </view>
    	
    	</view>
    	
    		
    		<view class="item flexx red"  @click="gou(item,index)" v-for="item,index in walletInfoTRX" v-if="type=='trx' || typeBoll==false">
    		 <view class="left flex">
    		 	<image src="../../../../static/tongyonh/tron_icon.png" mode="aspectFit" class="img1"></image>
    		   <view class="textcon"> 
    		   	<view class="text1">
    		 {{item.coinList[0].name}}
    		   	</view>
    			<view class="text2">
    			{{item.address}}
    			</view>
    		   </view>
    		 </view>	
			  <view class="gou" v-if="num==item.privateKey">
	 	<image src="../../../../static/tongyonh/Shape.png" mode="aspectFit" class="img"></image>
	 </view>


    		 <view class="rig">
    		0.00
    		 </view>
    		</view>
    		
    	
    
           </view>
    	
	
	

	</view>
		</view>
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	import tabBar from "@/components/tabBar/tabBar.vue"
	export default {
		data() {
			return {
				type:'',
				typeBoll:false,
				walletInfoBTC:[],
				walletInfoBTC2:[],
				walletInfoETH:[],
				walletInfoETH2:[],
				walletInfoTRX:[],
				walletInfoTRX2:[],
				walletInfo:{},
				walletInfo2:{},
				num:'',
						}
		},
		methods: {
			gou(index,i){
				this.num=index.privateKey
					uni.setStorageSync('walleti',this.num)
				console.log(index)
				if(index.coinList[0].name=='BTC'){
					console.log(this.walletInfoBTC2[i])
					uni.setStorageSync('wallet',this.walletInfoBTC2[i])	
					setTimeout(()=>{
					uni.reLaunch({
						url:'../index'
					})	
					},500)
				}
				if(index.coinList[0].name=='ETH'){
					console.log(this.walletInfoETH2[i],777777777)	
						uni.setStorageSync('wallet',this.walletInfoETH2[i])	
						setTimeout(()=>{
						uni.reLaunch({
							url:'../index'
						})	
						},500)
				}
				if(index.coinList[0].name=='TRX'){
					console.log(this.walletInfoTRX2[i])
						uni.setStorageSync('wallet',this.walletInfoTRX2[i])
						setTimeout(()=>{
						uni.reLaunch({
							url:'../index'
						})	
						},500)
				}
		
			},
				goMwallet(){
				uni.navigateTo({
					url:'../mwallet/index'
				})
			},
			getHeight(type){
				if(type=='one'){
					var a=document.getElementById('one').offsetTop;
					var b=a-57;
					document.getElementById('tiao').style.top=b+"px";
					this.typeBoll=false;
				}
				if(type=='eth'){
					var a=document.getElementById('eth').offsetTop;
					var b=a-57;
					document.getElementById('tiao').style.top=b+"px";
					this.type='eth'
					this.typeBoll=true;
				}
			if(type=='btc'){
				var a=document.getElementById('btc').offsetTop;
				var b=a-57;
				document.getElementById('tiao').style.top=b+"px";
				this.type='btc'
				this.typeBoll=true;
			}
			if(type=='trx'){
				var a=document.getElementById('trx').offsetTop;
				var b=a-57;
				document.getElementById('tiao').style.top=b+"px";
				this.type='trx'
				this.typeBoll=true;
			}
			},
		getStorage(){
			this.walletInfo2 = uni.getStorageSync('walletInfo');
			this.walletInfoBTC2=this.walletInfo2.BTC;
			this.walletInfoETH2=this.walletInfo2.ETH;
			this.walletInfoTRX2=this.walletInfo2.TRON;
		},
			setStorage() {
				this.walletInfo = uni.getStorageSync('walletInfo');
				this.walletInfoBTC=this.walletInfo.BTC;
				
				this.num=this.walletInfoBTC[0].privateKey
				for(var i=0;i<this.walletInfoBTC.length;i++){
			this.walletInfoBTC[i].address = this.walletInfoBTC[i].address.substring(0, 6)+'...'+this.walletInfoBTC[i].address.substring(25,this.walletInfoBTC[i].address.length);		
				}
				this.walletInfoETH=this.walletInfo.ETH;
				for(var i=0;i<this.walletInfoETH.length;i++){
				this.walletInfoETH[i].address = this.walletInfoETH[i].address.substring(0, 6)+'...'+this.walletInfoETH[i].address.substring(25,this.walletInfoETH[i].address.length);		
					}
				this.walletInfoTRX=this.walletInfo.TRON;
				for(var i=0;i<this.walletInfoTRX.length;i++){
				this.walletInfoTRX[i].address = this.walletInfoTRX[i].address.substring(0, 6)+'...'+this.walletInfoTRX[i].address.substring(25,this.walletInfoTRX[i].address.length);		
					}
				console.log(this.walletInfo,111111)
			},
			goManager(itemm){
				console.log(itemm)
				let item = JSON.stringify(itemm)
				uni.navigateTo({
					url:'../../../menu/wallet/mwallet/manage/index?item='+item
				})
			},
			
			
			
		},
		onLoad() {
			var walletInfo = new Object();
			walletInfo =uni.getStorageSync('walletInfo')
			if(walletInfo == ''){
				uni.reLaunch({
					url:'/pages/register/index'
				})
			}
			this.getStorage()
			this.setStorage()
				
			if(uni.getStorageSync('walleti')!=''){
				this.num=uni.getStorageSync('walleti')
			}
		}
	};
</script>
<style scoped>
	page{
		background: #FAFAFA;
	}
</style>

<style>

	@import './index.css';

</style>
