<template>
	<view class="container">
		<view class="listBox">
			<view class="titleTetx">收款地址</view>
			<view class="flex listTpl">
				<input type="number" class="inputBox" v-model="address" placeholder="请输入收款地址" />
			</view>
		</view>
		<view class="listBox" style="padding-top: 0rpx;">
			<view class="titleTetx">转账数量</view>
			<view class="listTpl flex">
				<input type="number" class="inputBox" v-model="number" placeholder="请输入转账金额" />
				<view class="listAll" @click="number=dataMoney.money">全部</view>
			</view>
			<view class="flex tipBox">
				<view class="tip1">可用余额{{dataMoney.money||0}}USDT</view>
			</view>
		</view>
		<view class="submission">
			<button class="golden" type="golden" hover-class="none" @click="submission">确认转账</button>
		</view>
	</view>
</template>

<script>
	import {
		trade
	} from '@/api/game.js';
	import {
		qianBao
	} from '@/api/wallet.js';
	export default {
		data() {
			return {
				address: '',
				number: '',
				dataMoney:{},
			};
		},
		onLoad() {
			this.qianBao();
		},
		methods: {
			qianBao(){
				const taht = this;
				qianBao({}).then(
					(res) => {
						taht.dataMoney = res.data.back.USDT.money
						taht.dataMoney.money = +taht.dataMoney.money;
					}
				).catch(
					(res) => {
						
					}
				)
			},
			submission() {
				const that = this;
				uni.showModal({
					title: '请输入支付密码',
					editable:true,
					success: res => {
						if(res.confirm){
							trade({
								type: "USDT",
								num: that.number,
								to_user_address: that.address,
								trade_psw: res.content,
							}).then((res) => {
									uni.showToast({
										title: res.msg,
										duration: 1500,
									});
									that.number = ''
									that.qianBao();
								}
							).catch(
								(res) => {
									
								}
							)
						}
					},
					fail: () => {},
					complete: () => {}
				});
				
			}

		}
	};
</script>

<style lang="scss">
	.container {
		padding: 25rpx 25rpx;
	}

	.listBox {
		padding: 46rpx 25rpx;
		background: #1F2A4A;
		border-radius: 10rpx;

		.titleTetx {
			font-weight: bold;
			font-size: 24rpx;
			color: #FFFFFF;
			padding-bottom: 25rpx;
		}

		.tipBox {
			padding-top: 15rpx;
			font-size: 24rpx;

			.tip1 {
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #0C5AFA;
				line-height: 45rpx;
			}
		}
	}

	.listTpl {
		border-bottom: 1rpx solid #6A7288;
		padding-bottom: 25rpx;

		.inputBox {
			font-size: 35rpx;
			color: #FFFFFF;
		}

		.listTip {}

		.listAll {
			padding-left: 30rpx;
			font-size: 30rpx;
			color: #0C5AFA;
		}
	}

	.input-placeholder {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #666666;
	}

	.submission {
		padding: 80rpx 25rpx;
		padding-bottom: 25rpx;

		.golden {
			background: #0C5AFA;
			color: #ffffff;
		}
	}
</style>