<template>
	<view class="ac">
		<navigation :showBack="false" :bgnum="true">
			<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()" ></image>
			<text class="big_title">
				{{addressInfo.type}} Transfer
			</text>
		</navigation>
		<view class="main">
	 <view class="main_con">
		 <view class="yuan">
		 	<image :src="addressInfo.coinList[0].icon" mode="aspectFit" class="img1"></image>
		 </view>
		
	 <view class="title">
	 		{{addressInfo.type}}
	 </view>
	<view class="item">
		<view class="top flex"> 
			<view class="text1">
				Receiving address
			</view>
			<view class="text2" @click="goAddress('transfer')">
				Adress Book
			</view>
		</view>
		<view class="inputcon">
		<input type="text" value=""  placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="Please enter the recipient address" class="input1" v-model="recipientAddress" />
		<image src="../../../../static/tongyonh/Frame330.png" mode="aspectFit" class="img1"></image>
		</view>
	</view>
	
	<view class="item">
		<view class="top flex">
			<view class="text1">
			Transfer amount
			</view>
		</view>
		<view class="inputcon2 flex">
			<view class="inputc flex">
				<view class="textt">
					{{addressInfo.type}}
				</view>
			<input type="text" value=""  placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="0.0000000" class="input3" v-model="transAmount"/>	
			</view>
			<text>≈</text>
	<view class="inputc flex">
		<view class="textt">
			USD
		</view>
	<input type="text" value=""  placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="0.0000000" class="input3"/>	
	</view>
		</view>
	<view class="top flex bottom">
		<view class="text3">
		Balance: {{addressInfo.balance}}
		</view>
		<view class="text1 bg" @click="forAll">
		ALL
		</view>
	</view>
	</view>
	
	<view class="item">
		<view class="top flex">
			<view class="text1">
				Remark
			</view>
		
		</view>
		<view class="inputcon">
		<input type="text" value=""  placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="Please enter a note (off-chain)" class="input1"/>
		</view>
	</view>
	
	<view class="item">
		<view class="top flex">
			<view class="text1">
				Transaction fee
			</view>
		
		</view>
		<view class="inputcon" >
		<input type="text"   v-model="fee" value=""  placeholder-style="font-size: 30rpx; color: #D0D0D2;" placeholder="Please enter a note (off-chain)" class="input2"/>
		 <view class="rig">
		 <text class="text1 ac">{{addressInfo.type}}</text> | <text class="text2">USDT</text>
		 </view>
		</view>
	</view>
	 </view>
		</view>
		
		<view class="big_con" v-if="showBottom">	
		<view class="tiao" @click="show=false">	
		</view>
		<view class="bigtitle">
			Transfer confirmation
		</view>
	 <view class="bottom_con">
		 <view class="yuan">
		 	<image :src="addressInfo.coinList[0].icon"  mode="aspectFit" class="img1"></image>
		 </view>
		 <view class="title">
		 	{{addressInfo.type}}
		 </view>
	 	<view class="title_con flex">
	 		<view class="text1">
	 			Amount
	 		</view>
			<view class="text1">
				{{transAmount}} {{addressInfo.type}}
			</view>
	 	</view>
		<view class="item">
			<view class="text1">
				Send address 
			</view>
			<view class="text2">
				{{addressInfo.address}}
			</view>
		</view>
		<view class="item">
			<view class="text1">
				Receiving address
			</view>
			<view class="text2">
				{{recipientAddress}}
			</view>
		</view>
		<view class="item">
			<view class="text1">
		Remark
			</view>
			<view class="text2">
			1.00 TRX
			</view>
		</view>
		<view class="item">
			<view class="text1">
			Transaction fee
			</view>
			<view class="text2">
				{{fee}} {{addressInfo.type}}
			</view>
		</view>
	
		<view class="goto" @click="confirmTo">
		Confirm
		</view>
	 </view>

	</view>
		<u-mask z-index="10" :show="show" @click="show = false"></u-mask>
	<!-- <u-mask z-index="1000" :show="show2" @click="show2 = false"></u-mask> -->
	<view class="zhiwen_con" v-if="showFinger">
		<view class="tiao" @click="cancel">	
		</view>
		<view class="bigtitle">
		Fingerprint password 
		</view>
		<view class="bottom_con">
			<image src="../../../../static/tongyonh/zhiwen.png" mode="aspectFit" class="img1"></image>
		   <view class="text1">
		   	Touch the fingerprint sensor
		   </view>
		<view class="flex con">
				<view class="textt1" @click="goPassword">
					Use Password	
					</view>
					<view class="textt2" @click="cancel">
				Cancel
					</view>
		</view>
		</view>
	</view>
	
	<view class="zhiwen_con" v-if="false">
		<view class="tiao">	
		</view>
		<view class="bigtitle">
		Fingerprint password 
		</view>
		<view class="bottom_con">
			<image src="../../../../static/tongyonh/alert-circle.png" mode="aspectFit" class="img1"></image>
		   <view class="text1 red">
		   Fingerprint not recognized. <br>Try again.
		   </view>
		<view class="flex con">
				<view class="textt1">
					Use Password	
					</view>
					<view class="textt2">
				Cancel
					</view>
		</view>
		</view>
	</view>
	
	<view class="zhiwen_con" v-if="false">
		<view class="tiao">	
		</view>
		<view class="bigtitle">
		Fingerprint password 
		</view>
		<view class="bottom_con">
			<image src="../../../../static/tongyonh/x-circle.png" mode="aspectFit" class="img1"></image>
		   <view class="text1 green">
		 Fingerprint recognized. 
		   </view>
		<view class="flex con">
				<view class="textt1">
					Use Password	
					</view>
					<view class="textt2">
				Cancel
					</view>
		</view>
		</view>
	</view>
	
<view class="btn_con" @click="Confirm">
	<view class="btn">
		Confirm
	</view>
	
</view>


</view>



</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	export default {
		data() {
			return {
	   fee:1000,
	   show: false,
	    show2: false,
		showFinger:false,
		showBottom:false,
		addressInfo:{},
		recipientAddress:'',
		transAmount:'',
		// 不用指纹去密码页面存的信息
		transInfoPass:{
			fromAddress:'',
			toAddress:"",
			privateKey:'',
			amount:'',	
		}
			}
		},
		methods: {
			cancel(){
				this.show=false
				this.showFinger=false
				this.$walletUtil.printCancel()
			},
			// 不用指纹去密码页
			goPassword(){
				this.$walletUtil.printCancel();
				console.log(111)
				uni.navigateTo({
						url:'/pages/menu/sendToken/enPassword/index'
				})
			},
			// 唤起指纹
			confirmTo(){
				this.show=true
				this.showFinger=true
				this.showBottom=false;
				// 指纹识别成功返回一个true
				var bltype=this.$walletUtil.fingerprint();
				console.log(bltype,444444)
				// 存储去密码页面的信息
				this.transInfoPass.fromAddress=this.addressInfo.address;
				this.transInfoPass.toAddress=this.recipientAddress;
				this.transInfoPass.privateKey=this.addressInfo.privateKey;
				this.transInfoPass.amount=this.transAmount;
				console.log(this.transInfoPass,444)
				// 存储去密码页面的信息
				uni.setStorageSync('transInfoPass',this.transInfoPass)
			},
			back(){
				uni.reLaunch({
					url:'../../wallet/index'
				})
			},
			// 点击获取所有钱
			forAll(){
				this.transAmount=this.addressInfo.balance
			},
			// 确认提交
			Confirm(){
				// 做判断
				if(this.transAmount==''){
					uni.showToast({
						title: 'Please enter the transfer amount',
						icon: 'none',
						duration: 1500
					})
					return
				}
				if(this.recipientAddress==''){
					uni.showToast({
						title: 'Please enter the receiving address',
						icon: 'none',
						duration: 1500
					})
					return
				}
				if(this.transAmount==''<0){
					uni.showToast({
						title: 'The entered amount cannot be less than 0',
						icon: 'none',
						duration: 1500
					})
					return
				}
				if(	this.transAmount>this.addressInfo.balance){
					uni.showToast({
						title: 'Sorry, your credit is running low',
						icon: 'none',
						duration: 1500
					})
					return
				}
				this.showBottom=true;
				this.show=true;
			},
        goAddress(text){
			console.log(text)
			uni.navigateTo({
				url:'../address/index?item='+text
			})
		}
		},
		onLoad() {
			// 判断是否从地址页有传地址过来
				if(uni.getStorageSync('myTransAddress')){
					this.recipientAddress=uni.getStorageSync('myTransAddress').address
				}
				this.addressInfo=uni.getStorageSync('infoWallet')
			console.log(this.addressInfo,1111)
		}
	};
</script>
<style scoped>
	page {
		background: #FAFAFA;
    height: 100%;
	}
</style>

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