<template>
	<view class="page">
		<nav-bar title="My wallet" bgColor="#F5f5f5"></nav-bar>
		<view class="wallet1">
			<view class="txt">My USDT</view>
			<view style="width: 500; font-size: 24px; color: #fff; line-height: 55px;">{{user.money.toFixed(4)}}</view>
			<view style="width: 47%; float: left;">
				<view class="txt">Accumulated earnings</view>
				<view class="txt1">{{user.income_total.toFixed(4)}}</view>
			</view>
			<view style="width: 47%; float: left; margin-left: 6%;">
				<view class="txt">Cash withdrawn</view>
				<view class="txt1">{{user.withdrawl_total.toFixed(4)}}</view>
			</view>
			<view style="clear: both;"></view>
		</view>
		<view style="width: 90%; margin: 10px auto;">
			<view style="width: 30%; float: left;">
				<view class="w" @click="onTokenJump('/pages/wallet/recharge')">
					<view style="text-align: center;">
						<image style="width: 25px; height: 25px; margin: auto;" src="/static/images/w3.png" mode="cover"></image></view>
					<view class="t">Recharge</view>
				</view>
			</view>
			<view style="width: 30%; float: left; margin-left: 5%;">
				  	<view class="w" @click="onTokenJump('/pages/wallet/putforward')">
				  		<view style="text-align: center;"><image style="width: 25px; height: 25px; margin: auto;" src="/static/images/w2.png" mode="cover"></image></view>
				  		<view class="t">Put forward</view>
				  	</view>
			</view>
			<view style="width: 30%; float: left; margin-left: 5%;">
					<view class="w" @click="onTokenJump('/pages/wallet/transfer')">
						<view style="text-align: center;"><image style="width: 25px; height: 25px; margin: auto;" src="/static/images/w4.png" fit="cover"></image></view>
						<view class="t">Transfer</view>
				  	</view>
			</view>
		</view>
		<view style="width: 92%; margin: 10px auto;">
			<view class="cell_list">
				<view style="color: #333; font-size: 18px; font-weight: 600;">Wallet fund records</view>
				<view class="cell_right arrow" @click="onTokenJump('/pages/wallet/fundrecords')">View details</view>
			</view>
			<view class="cell_list" style="border-bottom: 1px solid #ddd;" v-if="list.length > 0" v-for="item in list" :key="item.id">
				<view class="t">{{item.type}}<view class="d1">{{item.created_at.slice(0, 19)}}</view></view>
				<view class="u1 u">
					<span>{{parseFloat(item.amount).toFixed(2)}} USDT</span>
					<view class="d" style="text-align: right; color: #1D61E7;">After:{{parseFloat(item.after).toFixed(2)}}</view>
				</view>
			</view>
			<view style="text-align: center; padding-bottom: 80px;" v-if="list.length == 0">
				<view  style="width: 360rpx; height: 360rpx; margin: 160rpx auto 0rpx auto;">
				<image src="/static/images/w5.png" style="width: 360rpx; height: 360rpx; " mode="cover"></image>
				</view>
				<view style="color: #999; font-size: 14px; font-weight: 400;">No data available</view>
			</view>
		</view>
	</view>
</template>

<script>
	import zPrompt from '@/components/common/prompt';
	import Popup from '@/components/common/popup';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		components: {
			Popup,
			zPrompt
		},
		data() {
			return {
				user:{
					money: 0.0000,
					income_total: 0.0000,
					withdrawl_total: 0.0000,
				},
				list: []
			};
		},
		computed: {
			...mapState(['userInfo']),
			...mapState(['init'])
		},
		//第一次加载
		onLoad(e) {
			this.getlist();
		},
		//页面显示
		onShow() {
			this.user.money = parseFloat(this.userInfo.money);
			this.user.income_total = parseFloat(this.userInfo.income_total == null ? 0 : this.userInfo.income_total);
			this.user.withdrawl_total = parseFloat(this.userInfo.withdrawl_total == null ? 0 : this.userInfo.withdrawl_total);
		},
		//方法
		methods: {
			getlist(){
				let data = {
					page: 1,
					limit: 10,
					currency: 'money'
				};
				this.$http.post('/api/balanceLog/list', data).then(res => {
					if(res.code == 0){
						this.list = res.data.data;
					}
				});
			},
			onTokenJump(url) {
				this.judgeLogin(() => {
					uni.navigateTo({
						url: url
					});
				});
			},
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {},
		//用户点击分享
		onShareAppMessage(e) {
			return this.wxShare();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';
	body{background-color: #fff;}
	.wallet1{
		border-radius: 10px; padding: 20px 15px; width: 90%; margin: 10px auto;
		background: url('/static/images/w1.png') #2B66F6; background-repeat: no-repeat; background-position: 92% 5px;
	}
	.wallet1 .txt{width: 400; font-size: 12px; color: #fff;}
	.wallet1 .txt1{width: 400; font-size: 16px; color: #fff; line-height: 35px;}
	.cell_list .t{
		color: #3d3d3d; font-size: 14px; font-weight: 400; line-height: 25px;
	}
	.cell_list .d{
		color: #3d3d3d; font-size: 16px; font-weight: 400; line-height: 25px;
	}
	.cell_list .d1{
		color: #999; font-size: 14px; font-weight: 400; line-height: 25px;
	}
	.cell_list .u{
		color: #1D61E7; font-weight: 600;float: right; font-size: 16px;
	}
	.cell_list .u1{
		color: #333; font-weight: 600;float: right;font-size: 16px;
	}
	.w{
		background-color: #F8F8F8; border-radius: 10px; padding: 20rpx 10rpx;
	}
	.w .t{
		text-align: center; margin-top: 10px; font-size: 14px;
	}
</style>