<template>
	<view class="">
		<navigation :showBack="false" :bgnum="true" class="head">
			<image src="../../../static/tongyonh/san.png" mode="aspectFit" class="renYou" slot="logo"
				@click="goCwallet()"></image>
			<image src="../../../static/tongyonh/erwei.png" mode="aspectFit" class="renYou2" slot="logo"
				@click="chooseImage()"></image>
			<text class="big_title">
				Wallet
			</text>
		</navigation>
		<view class="main">
			<view
				:class="{'money_con': userObj.coinList[0].xname=='Ethereum', 'money_con2': userObj.coinList[0].xname=='Bitcoin', 'money_con3': userObj.coinList[0].xname=='TRON'}">
				<image src="../../../static/tongyonh/ethereum.png" mode="aspectFit" class="imgicon"
					v-if="userObj.coinList[0].xname=='Ethereum'"></image>
				<image src="../../../static/tongyonh/Frame28.png" mode="aspectFit" class="imgicon"
					v-if="userObj.coinList[0].xname=='Bitcoin'"></image>
				<image src="../../../static/tongyonh/tronicon.png" mode="aspectFit" class="imgicon"
					v-if="userObj.coinList[0].xname=='TRON'"></image>
				<view class="textcon1 flex">
					<text class="text">{{this.userObj.name}}</text>
					<image src="../../../static/tongyonh/visibility_24px.png" mode="aspectFit" class="img1"
						@click="showMoney()" v-if="showMoney1"></image>
					<image src="../../../static/tongyonh/eyeno.png" mode="aspectFit" class="img1" @click="showMoney22()"
						v-if="showMoney2"></image>
				</view>
				<view class="textcon2" v-if="showMoney1">
					$ {{!userObj.balancePrice?0.00:userObj.balancePrice}}
				</view>
				<view class="textcon2" v-if="showMoney2">
					***
				</view>
				<view class="textcon3">
					{{this.userObj.ellipsisAddress}}
				</view>
			</view>

			<view class="bot_con">
				<view class="jiacon">
					<view class="title">
						Assets
					</view>
					<image src="../../../static/tongyonh/IconGroup.png" mode="aspectFit" class="jiaimg"
						v-if="userObj.coinList[0].xname!='Bitcoin'&&userObj.coinList[0].xname!='TRON'" @click="goOther">
					</image>
				</view>
				<view class="scroll">
					<view class="item flexx" @click="goTrans(item,index)" v-for="item,index in this.userObj.coinList">
						<view class="left flex">
							<image :src="item.icon" mode="aspectFit" class="img1"></image>
							<view class="textcon">
								<view class="text1">
									{{item.name}}
								</view>
								<view class="text2">
									{{item.xname}}
								</view>
							</view>
						</view>
						<view class="rig">
							<view class="text1">
								{{item.balance}}
							</view>
							<view class="text2" v-if="item.balancePrice">
								≈ $ {{item.balancePrice}}
							</view>
							<view class="text2" v-if="!item.balancePrice">
								≈ $ 0.00
							</view>
						</view>
					</view>
				</view>



			</view>



		</view>
		<tab-bar :selectActive="1"></tab-bar>
	</view>
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	import token from "@/utils/TokenUtil"
	export default {
		data() {
			return {
				eth: '',
				trc: 'Hello',
				walletInfo: {},
				userObj: {},
				userObj2: {},
				showMoney1: true,
				showMoney2: false,
				btcBalance: 0,
				isStop:false
			}
		},
		onUnload: function() {
			this.isStop = true
		},
		onLoad() {
			// 拿钱包
			this.userObj = uni.getStorageSync('wallet');
			let that=this;
			this.$walletUtil.updateBalance(function(){
				that.userObj = uni.getStorageSync('wallet');
				that.userObj2 = uni.getStorageSync('wallet');
			});
		},

		// onPullDownRefresh() {
		// 	console.log('refresh');
		// 	this.$walletUtil.updateBalance();
		// 	setTimeout(function() {
		// 		uni.stopPullDownRefresh();
		// 	}, 500);
		// },
		methods: {
			
			goOther() {
				console.log(this.userObj2, 8888)
				let item = JSON.stringify(this.userObj2)
				uni.navigateTo({
					url: 'otherCoin/index?type=' + item
				})
			},
			showMoney() {
				this.showMoney1 = false
				this.showMoney2 = true
			},
			showMoney22() {
				this.showMoney1 = true
				this.showMoney2 = false
			},
			setStorage() {

			},
			goTrans(itemm, index) {
				let coin = this.userObj.coinList[index];
				coin.type=this.userObj.type;
				coin.privateKey=this.userObj.privateKey;
				coin.address=this.userObj.address;
				coin.password=this.userObj.password;
				uni.setStorageSync('coin',coin)
				uni.navigateTo({
					url: '/pages/menu/token/btc/index'
				})

			},

			// 唤醒摄像头
			chooseImage() {
				var _this = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], //从相册选择、摄像头
					success: function(res) {
						_this.imgShow = res.tempFilePaths[0]
					}
				});
				// ass()
			},

			goCwallet() {
				this.isStop = true
				uni.navigateTo({
					url: './cwallet/index'
				})
			}
		}
	};
</script>
<style scoped>
	page {
		background: #FAFAFA;
	}
</style>

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