<template>
	<view class="page">
		<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back"  :border="false" :shadow="false" :fixed="true"
		:title="$t('wallet.title')" backgroundColor="#fff"></uni-nav-bar>
		<view class="wallet1">
			<view class="txt">{{$t('wallet.text1')}}</view>
			<view style="width: 500; font-size: 48rpx; color: #fff; line-height: 110rpx;">{{user.money.toFixed(4)}}</view>
			<view style="width: 47%; float: left;">
				<view class="txt">{{$t('wallet.text2')}}</view>
				<view class="txt1">{{user.income_total.toFixed(4)}}</view>
			</view>
			<view style="width: 47%; float: left; margin-left: 6%;">
				<view class="txt">{{$t('wallet.text3')}}</view>
				<view class="txt1">{{user.withdrawl_total.toFixed(4)}}</view>
			</view>
			<view style="clear: both;"></view>
		</view>
		<view style="width: 90%; margin: 20rpx auto;">
			<view style="width: 30%; float: left;">
				<view class="w" @click="onTokenJump('/pages/wallet/recharge')">
					<view style="text-align: center;">
						<image style="width: 50rpx; height: 50rpx; margin: auto;" src="/static/images/w3.png" mode="cover"></image></view>
					<view class="t">{{$t('recharge.title')}}</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: 50rpx; height: 50rpx; margin: auto;" src="/static/images/w2.png" mode="cover"></image></view>
				  		<view class="t">{{$t('putforward.title')}}</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: 50rpx; height: 50rpx; margin: auto;" src="/static/images/w4.png" fit="cover"></image></view>
						<view class="t">{{$t('transfer.title')}}</view>
				  	</view>
			</view>
			<view style="clear: both;"></view>
		</view>
		<view style="width: 92%; margin: 20rpx auto;">
			<view class="cell_list" style="padding: 30rpx 0rpx;border-bottom: none;">
				<view style="color: #333; font-size: 36rpx; font-weight: 600;">{{$t('wallet.text4')}}</view>
				<view class="cell_right arrow" @click="onTokenJump('/pages/wallet/fundrecords')">{{$t('wallet.text5')}}</view>
			</view>
			<view class="cell_list" style="padding: 30rpx 0rpx;border-bottom: 2rpx 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: 160rpx;" 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: 28rpx; font-weight: 400;">{{$t('nodata')}}</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',
					lang: this.$i18n.locale
				};
				this.$http.post('/api/balanceLog/list', data).then(res => {
					if(res.code == 0){
						this.list = res.data.data;
					}
				});
			},
			goto(url, type) {
			    if (type == 2) {
			        return uni.switchTab({ url: url })
			    }
			    if (type == 1) {
			        return uni.navigateBack({ delta: url });
			    }
			    uni.navigateTo({
			        url: url
			    })
			},
			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: 20rpx; padding: 40rpx 30rpx; width: 90%; margin: 20rpx auto; 
		background: url('/static/images/w1.png') #2B66F6;background-size: 25%; background-repeat: no-repeat; background-position: 92% 10rpx;
	}
	.wallet1 .txt{width: 400; font-size: 24rpx; color: #fff;}
	.wallet1 .txt1{width: 400; font-size: 32rpx; color: #fff; line-height: 70rpx;}
	.cell_list .cell_right.arrow::after{
		height: 16rpx !important;
	}
	.cell_list .t{
		color: #3d3d3d; font-size: 28rpx; font-weight: 400; line-height: 50rpx;
	}
	.cell_list .d{
		color: #3d3d3d; font-size: 32rpx; font-weight: 400; line-height: 50rpx;
	}
	.cell_list .d1{
		color: #999; font-size: 28rpx; font-weight: 400; line-height: 50rpx;
	}
	.cell_list .u{
		color: #1D61E7; font-weight: 600;float: right; font-size: 32rpx;
	}
	.cell_list .u1{
		color: #333; font-weight: 600;float: right;font-size: 32rpx;
	}
	.w{
		background-color: #F8F8F8; border-radius: 20rpx; padding: 20rpx 10rpx;
	}
	.w .t{
		text-align: center; margin-top: 20rpx; font-size: 28rpx;
	}
</style>