<template>
	<view class="">
		<navigation :showBack="true" :bgnum="true">
			<image src="../../../../static/tongyonh/IconGroup.png" mode="aspectFit" class="renYou" slot="logo" @click="goAddress()"></image>
			<text class="big_title">
				Address
			</text>
		</navigation>
		<view class="main">
			<view class="big_item">
				
			<view class="item flex" v-for="(item,index) in BTCAddressInfo">
				<view class="textcon flex">
					<view class="bigcon">
						<view class="textimg flexx">
							<image :src="item.coinList[0].icon" mode="aspectFit" class="img"></image>
						<text class="textt">{{item.coinList[0].name}}</text>
							<text class="textt2">{{item.name}}</text>
						</view>
						<view class="text1">
						{{item.address}}
						</view>
					</view>
				</view>
				<view class="btncon">
					<image src="../../../../static/tongyonh/more_vert_24px_outlined.svg" mode="aspectFit" class="img2" @click="showIndex(item,index)">
					</image>
				</view>
			
	
			<view class="set_con" v-if="show"  v-show="index==btcIndex">
				<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img1" @click="show = false"></image>
				<view class="itemm flexx" @click="editItem(index)">
					<image src="../../../../static/tongyonh/create_24px.png" mode="aspectFit" class="img"></image>
					Edit
				</view>
				<view class="itemm flexx red" @click="deleteItem()">
					<image src="../../../../static/tongyonh/trash.png" mode="aspectFit" class="img"></image>
				Delete
				</view>
			</view>
					</view>
			
			<view class="item flex" v-for="(item,index) in ETHAddressInfo">
				<view class="textcon flex">
					<view class="bigcon">
						<view class="textimg flexx">
							<image :src="item.coinList[0].icon" mode="aspectFit" class="img"></image>
						<text class="textt">{{item.coinList[0].name}}</text>
							<text class="textt2">{{item.name}}</text>
						</view>
						<view class="text1">
						{{item.address}}
						</view>
					</view>
				</view>
				<view class="btncon">
					<image src="../../../../static/tongyonh/more_vert_24px_outlined.svg" mode="aspectFit" class="img2" @click="showIndex(item,index)">
					</image>
				</view>
				
				<view class="set_con" v-if="show2"  v-show="index==ethIndex">
					<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img1" @click="show2 = false"></image>
					<view class="itemm flexx" @click="editItem(index)">
						<image src="../../../../static/tongyonh/create_24px.png" mode="aspectFit" class="img"></image>
						Edit
					</view>
					<view class="itemm flexx red" @click="deleteItem()">
						<image src="../../../../static/tongyonh/trash.png" mode="aspectFit" class="img"></image>
					Delete
					</view>
				</view>
			</view>
		
			
			
		
			
			<view class="item flex" v-for="(item,index) in TRXAddressInfo">
				<view class="textcon flex">
					<view class="bigcon">
						<view class="textimg flexx">
							<image :src="item.coinList[0].icon" mode="aspectFit" class="img"></image>
						<text class="textt">{{item.coinList[0].name}}</text>
							<text class="textt2">{{item.name}}</text>
						</view>
						<view class="text1">
						{{item.address}}
						</view>
					</view>
				</view>
				<view class="btncon">
					<image src="../../../../static/tongyonh/more_vert_24px_outlined.svg" mode="aspectFit" class="img2" @click="showIndex(item,index)">
					</image>
				</view>
			
		<view class="set_con" v-if="show3" v-show="index==trxIndex">
				<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img1" @click="show3 = false"></image>
				<view class="itemm flexx" @click="editItem(index)">
					<image src="../../../../static/tongyonh/create_24px.png" mode="aspectFit" class="img"></image>
					Edit
				</view>
				<view class="itemm flexx red" @click="deleteItem()">
					<image src="../../../../static/tongyonh/trash.png" mode="aspectFit" class="img"></image>
				Delete
				</view>
			</view>
		</view>
			</view>
		

		
		<view class="info_con green" v-if="showImte">
				<view class="text">
					
					{{itemCoin}}  {{itemAddress}}
				</view>
				<view class="text text2">
				DELETE
				</view>
			</view>
	
		
		</view>

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



</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	export default {
		data() {
			return {
				ethIndex:0,
				btcIndex:0,
				trxIndex:0,
				showImte:false,
				BTCAddressInfo:{},
				ETHAddressInfo:{},
				TRXAddressInfo:{},
				walletIndex:-1,
				itemCoin:'',
				itemAddress:'',
				info:{},
show: false,
show2: false,
show3: false,
	list: [
					{
						name: 'Single address',
						checked: true,
						disabled: false
					},
					{
						name: 'Batch add 10 addresses',
						checked: false,
						disabled: false
					},
					{
						name: 'Batch add 50 addresses',
						checked: false,
						disabled: false
					}
				]
			}
		},
		methods: {
			back(){
				uni.navigateTo({
					url:'/pages/menu/profile/index'
				})
			},
			editItem(index){
				console.log(index,78787)
				uni.setStorageSync('editIndex',index)
			      uni.setStorageSync('AddressInfo',this.info)
				  uni.setStorageSync('AddressName',this.itemCoin)
				  uni.setStorageSync('AddressIndex',this.walletIndex)
				  uni.navigateTo({
				  	url:'../addAddress2/index'
				  })
			},
			showIndex(item,index){
				this.itemCoin=item.coinList[0].name
				if(item.coinList[0].xname=='Bitcoin'){	
					this.btcIndex=index
					this.show=true
				}else if(item.coinList[0].xname=='Ethereum'){
					this.show2=true
					this.ethIndex=index
				}else{
					this.trxIndex=index
					this.show3=true
				}
				 this.info= item
				this.itemCoin=item.coinList[0].name
				this.itemAddress=item.address
				this.walletIndex=index;
			},
			deleteItem(){
				console.log(this.walletIndex,4444444)
				if(this.itemCoin=='BTC'){
					console.log(this.BTCAddressInfo.length,'length')
					if(this.BTCAddressInfo.length==1){
					let BTCAddressInfo=[]
					uni.setStorageSync('BTCAddressInfo',BTCAddressInfo)
					
					}
					console.log(this.BTCAddressInfo,1111)
					console.log(this.walletIndex,44444)
			
					this.BTCAddressInfo.splice(this.walletIndex,1)
					console.log(this.BTCAddressInfo,'删除后')
					uni.setStorageSync('BTCAddressInfo',	this.BTCAddressInfo)
					this.showImte=true;
					this.show=false;
					setTimeout(()=>{
				    this.showImte=false;
					},1500)
				
				}
				if(this.itemCoin=='ETH'){
					if(this.ETHAddressInfo.length==1){
					let ETHAddressInfo=[]
					uni.setStorageSync('ETHAddressInfo',ETHAddressInfo)
					
					}
					console.log(this.ETHAddressInfo,1111)
					console.log(this.walletIndex,44444)
					this.ETHAddressInfo.splice(this.walletIndex,1)
					uni.setStorageSync('ETHAddressInfo',this.ETHAddressInfo)
					this.showImte=true;
					this.show2=false;
					setTimeout(()=>{
				this.showImte=false;
					},1500)
				
				}
				if(this.itemCoin=='TRX'){
					if(this.TRXAddressInfo.length==1){
					let TRXAddressInfo=[]
					uni.setStorageSync('TRXAddressInfo',TRXAddressInfo)
					
					}
					this.TRXAddressInfo.splice(this.walletIndex,1)
					uni.setStorageSync('TRXAddressInfo',this.TRXAddressInfo)
					this.showImte=true;
					this.show3=false;
					setTimeout(()=>{
				this.showImte=false;
					},1500)
				
				}
			},
goAddress(){
	uni.navigateTo({
		url:'../addAddress/index'
	})
}
		},
		onLoad() {
			if(uni.getStorageSync('BTCAddressInfo').length>0){
				this.BTCAddressInfo=uni.getStorageSync('BTCAddressInfo')
				console.log(this.BTCAddressInfo,777)
			}
			if(uni.getStorageSync('ETHAddressInfo').length>0){
				this.ETHAddressInfo=uni.getStorageSync('ETHAddressInfo')
				console.log(this.ETHAddressInfo,777)
			}
			if(uni.getStorageSync('TRXAddressInfo').length>0){
				this.TRXAddressInfo=uni.getStorageSync('TRXAddressInfo')
				console.log(this.TRXAddressInfo,777)
			}
		}
	};
</script>
<style scoped>
	page {
		background: #FAFAFA;
       height: 100%;
	}
</style>

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