<template>
	<view class="content">
		<view class="content-money">
			<view class="status_bar"><!-- 这里是状态栏 --></view>
			<view class="body-title">
				<view class="goback-box" @click="toBack">
					<image class="goback" src="/static/img/fanhui.png" mode=""></image>
				</view>
				<view class="header">{{$t('money.a1')}}</view>
			</view>
			<view class="content-bg">
			</view>
			<view class="money-box">
				<view>{{$t('money.a2')}}</view>
				<view class="money">{{userWallet}}U</view>
				
			</view>
			<!-- 数据代办 -->
			<view class="box">
				<view class="moneybtn-box1">
					<view class="money-btn"></view>
					<view class="money-btn" @click="navto('/pages/user/money/recharge')">{{$t('money.a3')}}</view>
				</view>
				<view class="moneybtn-box">
					<view class="money-btn"></view>
					<view class="money-btn" @click="navto('/pages/user/money/withdrawal')">{{$t('money.a4')}}</view>
				</view>
			</view>
			
		</view>
		
		<view class="info-box flex">
			<view class="info-item">
				<view class="info-font">{{$t('money.a7')}}</view>
				<view class="info-num">{{userInfo.brokerage  || '0'}}</view>
			</view>
			<view class="shu"></view>
			<view class="info-item">
				<view class="info-font">{{$t('money.a8')}}</view>
				<view class="info-num">{{userInfo.extract || '0'}}</view>
			</view>
		</view>
		<view class="list flex" v-for="(item, index) in navList" :key="index">
			<view class="">
				<view class="tit" v-if="item.title === '充值'">{{$t('user.a7')}}</view>
				<view class="tit" v-else>{{$t('user.a6')}}</view>
				<view class="tim">{{item.time}}</view>
			</view>
			<view class="boxT">
				<view class="mon">{{item.money}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {qianBao} from "@/api/wallet.js"
	import {
		gameWallet,
	} from "@/api/game.js";
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		getCommissionInfo,
		getUserInfo,
		// getUser
	} from '@/api/user.js';
	import {
		getMoneyStyle
	} from '@/utils/rocessor.js';
	import {
		mapGetters
	} from 'vuex';
	import empty from '@/components/empty';
	import {
		spreadCommission,
		userBalance,
	} from '@/api/wallet.js';
	export default {
		filters: {
			getMoneyStyle
		},
		components: {
			empty,
		},
		
		data() {
			return {
				userInfo: {},
				userWallet: '', //余额
				height: '',
				// 头部图高度
				maxheight: '',
				tabCurrentIndex: 0,
				orderStatusSum: 0,
				recharge: 0,
				navList: [
					{
					title: '充值',
					time: '10.12',
					money: '100',
					},
					{
					title: '提现',
					time: '10.12',
					money: '300',
					}
				],
				money: ''
			};
		},
		onLoad(options) {},
		onShow() {
			this.getUserInfo();
			this.loadData();
			this.getUserWallet();
			this.qianBao()
		},
		methods: {
			// 钱包
			async qianBao() {
				const res = await qianBao()
				console.log('qian', res);
			},
			
			// 获取用户余额信息
			getUserWallet() {
				gameWallet().then((res) => {
					this.userWallet = +res.data.back.USDT.money.money
				})
			},
			getUserInfo() {
				getUserInfo({}).then(({
					data
				}) => {
					this.userInfo = data
				});
			},
			toBack() {
				uni.switchTab({
					url: '/pages/index/user'
				});
			},
			// 页面跳转
			navto(e) {
				uni.navigateTo({
					url: e
				});
			},
			
			//获取收入支出信息
			async loadData(source) {
				let obj = this;
				//这里是将订单挂载到tab列表下
				let index = this.tabCurrentIndex;
				let navItem = this.navList[index];
				let state = navItem.state;
				if (source === 'tabChange' && navItem.loaded === true) {
					//tab切换只有第一次需要加载数据
					return;
				}
				if (navItem.loadingType === 'loading') {
					//防止重复加载
					return;
				}
				// 修改当前对象状态为加载中
				navItem.loadingType = 'loading';
			
				spreadCommission({
					}, state)
					.then(({
						data
					}) => {
						if (data.length > 0) {
							data.forEach(e => {
								navItem.orderList = navItem.orderList.concat(e.list);
							})
							console.log(navItem.orderList);
							navItem.page++;
						}
						//判断是否还有数据, 有改为more, 没有改为noMore
						if (navItem.limit == data.length) {
							navItem.loadingType = 'more';
							return;
						} else {
							navItem.loadingType = 'noMore';
						}
						uni.hideLoading();
						this.$set(navItem, 'loaded', true);
					})
					.catch(e => {
						console.log(e);
					});
			},

			//顶部tab点击
			tabClick(index) {
				this.tabCurrentIndex = index;
			},
			
		}
	};
</script>

<style lang="scss">
	page {
		background: $page-color-base;
		height: 100%;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	.content-money {
		position: relative;
		height: 480rpx;

		.content-bg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			width: 750rpx;
			height: 480rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.body-title {
			height: 80rpx;
			text-align: center;
			font-size: 35rpx;
			position: relative;

			.header {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #ffffff;
				height: 80rpx;
				font-size: 36rpx;
				font-weight: 700;
				z-index: 9;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.goback-box {
				position: absolute;
				left: 18rpx;
				top: 0;
				height: 80rpx;
				display: flex;
				align-items: center;
			}

			.goback {
				z-index: 100;
				width: 34rpx;
				height: 34rpx;
				color: #ffffff
			}
		}
	}

	.info-box {
		width: 670rpx;
		height: 186rpx;
		background: #1d1d22;
		box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;
		margin: -100rpx auto 0;
		position: relative;
		z-index: 2;

		.info-item {
			width: 50%;
			display: flex;
			flex-direction: column;
			align-items: center;
			line-height: 1;

			.info-font {
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #e2e2e2;
			}

			.info-num {
				margin-top: 30rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #ffffff;
			}
		}

		.shu {
			width: 2rpx;
			height: 74rpx;
			background: #ffffff;
		}
	}

	.money-box {
		position: relative;
		z-index: 2;
		/* #ifdef H5 */
		padding-top: 90rpx;
		/* #endif */
		color: #ffffff;
		text-align: center;
		/* #ifdef APP-PLUS */
		height: 200rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		padding-top: 40rpx;
		/* #endif */

		.money {
			font-size: 72rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #fdb242;
		}

		.text {
			font-size: 30rpx;
		}
	}
	.box {
		width: 670rpx;
		height: 50rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.moneybtn-box {
		display: flex;
		justify-content: space-between;
		position: relative;
		z-index: 2;
		// color: #ffffff;
		padding: -20rpx 10rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
	}
	.moneybtn-box1 {
		display: flex;
		justify-content: space-between;
		position: relative;
		z-index: 2;
		color: #ffffff;
		padding: 40rpx 60rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #ffffff;
	}
	
	.content {
		height: 100%;

		.empty-content {
			background-color: #ffffff;
		}

	}
   
   // border-bottom: 1px solid #ffffff;
	.list {
		margin: 40rpx 31rpx;
			.tit {
				height: 26rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #FFFFFF;
			}
			.tim {
				padding-top: 30rpx;
				height: 17rpx;
				font-size: 22rpx;
				font-weight: 400;
				color: #999999;
			}
			.boxT {
				.mon {
					height: 23rpx;
					font-size: 30rpx;
					font-weight: bold;
					color: #FDB242;
				}
				
			}
	}
	
</style>