<template>
	<view class="">
		<navigation :showBack="true" :bgnum="true" class="head">
			<text class="big_title">
				{{coin.name}}
			</text>

		</navigation>
		<view class="main">
			<view class="money_con"
				:class="{'money_con': coin.type=='ETH', 'money_con2': coin.type=='BTC', 'money_con3': coin.type=='TRX'}">
				<view class="textcon1">
					<text class="text1">
						<view class="">
							{{coin.balance}}
						</view>
						<text class="text2">≈ $ {{coin.balancePrice}}</text>
					</text>
					<image src="../../../../static/tongyonh/ethereum.png" mode="aspectFit" class="img1"
						v-if="coin.type=='ETH'&&!coin.contractAddress"></image>
					<image src="../../../../static/tongyonh/Frame28.png" mode="aspectFit" class="img1"
						v-if="coin.type=='BTC'&&!coin.contractAddress"></image>
					<image src="../../../../static/tongyonh/tronicon.png" mode="aspectFit" class="img1"
						v-if="coin.type=='TRX'&&!coin.contractAddress"></image>
				</view>
				<view class="textcon1">
					<view class="v1">
						<view class="t1">
							0.0
						</view>
						<view class="t2">
							Existing balance
						</view>
					</view>
					<view class="v1 v2">
						<view class="t1">
							0.0
						</view>
						<view class="t2">
							Freeze balance
						</view>
					</view>
				</view>
			</view>

			<view class="select_con">
				<view class="select">
					<u-tabs height="120" bar-width="172" active-font="13" inactive-font="13" active-color="#6F69FF"  inactive-color="#A3AED0" :list="list"
						:is-scroll="false" :current="current" @change="change"></u-tabs>

					<u-empty text="No content" mode="list" v-if="showInfo"></u-empty>

					<view class="" v-if="!showInfo">
						<view class="item1" v-for="(item,index) in trxs" @click="goDetail(item,index)">
							<view class="lef_con">
								<image src="../../../../static/tongyonh/arrow-up-left.png" mode="aspectFit" class="img1"
									v-if="item.type=='in'"></image>
								<image src="../../../../static/tongyonh/arrow-up-left_1.png" mode="aspectFit"
									class="img1" v-if="item.type=='out'"></image>
								<view class="textcon">

									<view class="text1">
										{{item.address}}
									</view>
									<view class="text2">
										{{item.time}}
									</view>
								</view>
							</view>
							<view class="rig_con">
								<view class="text1">
									<text v-if="address==item.to">+</text>
									<text v-if="address==item.from">-</text>
									{{item.value}}
									<text class="">
										{{item.network}}
									</text>



								</view>
								<image src="../../../../static/tongyonh/Shape.png" mode="aspectFit" class="img1">
								</image>
							</view>
						</view>



					</view>
				</view>

			</view>


			<view class="btnconn">
				<view class="btn active" @click="goSend">
					<image src="../../../../static/tongyonh/arrow-up-leftw.png" mode="aspectFit" class="arrow-up-left">
					</image>
					Send
				</view>
				<view class="btn" @click="goReceive">
					<image src="../../../../static/tongyonh/arrow-up-leftp.png" mode="aspectFit" class="arrow-up-left">
					</image>
					<text class="btn13">Receive</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import cont from "@/components/navigation/navigation.vue"
	import api from '@/utils/api'
	import index from '@/utils/index.js'
	export default {
		data() {
			return {
				// 拿账单的address
				trxs:{},
				coin: {},
				showInfo: false,
				list: [{
					name: 'All',

				}, {
					name: 'Send',

				}, {
					name: 'Receive',

				}],
				infoWallet: {},
				current: 0,
				pageSize: 20,
				pageNum: 1,

				balance: 0,

				address: '',
				type: 'all',
				trueType: '',
				contract: '',
				balancePrice: '',
			}
		},
		methods: {
			goSend() {
				uni.navigateTo({
					url: '/pages/menu/sendToken/transfer/index'
				})
			},
			goReceive() {
				uni.setStorageSync('infoWallet', this.infoWallet)
				uni.navigateTo({
					url: '/pages/menu/sendToken/index'
				})
			},
			goDetail(item, index) {
				uni.setStorageSync('transDetail', this.trxs[index])
				uni.navigateTo({
					url: '/pages/menu/transction/detail/index'
				})

			},
			change(index) {
				if (index == 0) {
					this.type = 'all'
				}
				if (index == 1) {
					this.type = 'send'
				}
				if (index == 2) {
					this.type = 'receive'
				}
				this.current = index;
				console.log(this.current)
				this.getWalletInfo();
			},

			getWalletInfo() {
				var that = this
				this.$dataUtil.transactionData(this.coin.type, this.type, this.coin.address, this.coin.contractAddress,
					this.pageNum, this.pageSize,
					function(data) {
						console.log(data, 121211212112121)
						if (data.length == 0) {
							that.showInfo = true;
						} else {
							that.showInfo = false;
						}
						that.trxs = data
						
					})
			}
		},
		onLoad() {
			this.coin = uni.getStorageSync('coin');
			this.change(0);
		},
	
		onReachBottom() {
			this.pageSize += 5;
			this.getWalletInfo()
		}
	};
</script>
<style scoped>
	page {
		background: #FAFAFA;

	}
</style>

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