<template>
	<view class="container">
		<view class="recharge">
			<view class="tplName">提币网络</view>
			<view class="tplNum">USDT-TRC20</view>
			<view class="tplName">提币地址</view>
			<view class="inputBox">
				<input class="input" type="text" v-model="address" placeholder="请输入提币地址" />
			</view>
			<view class="tplBox flex">
				<view class="tplName">提币数量</view>
				<view class="tplTip">可用{{dataMoney.money||0}}USDT</view>
			</view>
			<view class="inputBox flex">
				<input class="input" type="text" v-model="number" placeholder="请输入提币数量" />
				<view class="text" @click="number=dataMoney.money">USDT <text>全部</text></view>
			</view>
			<!-- <view class="free">手续费:0</view> -->
		</view>
		<view class="submission">
			<button class="golden" type="golden" hover-class="none" @click="submission">确认提币</button>
		</view>
	</view>
</template>
<script type="text/javascript">
	import {
		qianBao,extractCash
	} from '@/api/wallet.js';
	export default {
		data() {
			return {
				address: '',
				number: '',
				dataMoney: {},
			};
		},
		onLoad() {
			this.loadData();
		},
		methods: {
			//获取数据
			loadData() {
				const that = this;
				qianBao({})
				  .then(res => {
						that.dataMoney = res.data.back.USDT.money
						that.dataMoney.money = +that.dataMoney.money
						that.val = that.dataMoney.address;
						console.log(that.dataMoney, 'dataMoney');
					})
				  .catch(err => {
				    console.log(err);
				  });
			},
			//确认提交
			submission() {
				let obj = this;
				uni.showModal({
					title: '请输入支付密码',
					editable: true,
					success: res => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中。。。',
								mask: true
							});
							//确认提现调接口，成功跳转页面
							extractCash({
									address: obj.address,
									money: obj.number,
									money_type: "USDT",
									trade_psw: res.content
								})
								.then(function(e) {
									uni.showToast({
										title: '请耐心等待系统审核通过',
										duration: 1500,
										mask: false,
										icon: 'none'
									});
									obj.address = ''
									obj.number = ''
									uni.hideLoading();
								})
								.catch(function(e) {
									uni.hideLoading();
									console.log(e);
								});
						}
					},
				});

			},
			//上传图片
			scImg() {
				upload({
					file: ''
				}).then((e) => {
					console.log(e, 55)
					this.img = e[0].url;
				});
			},
		}
	};
</script>

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

	.recharge {
		border-radius: 25rpx;
		background-color: #1F2A4A;
		padding: 37rpx 25rpx;

		.tplName {
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 24rpx;
		}

		.tplNum {
			margin: 40rpx 0rpx;
			padding: 15rpx 30rpx;
			border-radius: 10rpx;
			border: 1px solid #1356FF;
			font-size: 26rpx;
			color: #1356FF;
			display: inline-block;
		}

		.tplTip {
			font-size: 20rpx;
			color: #FFFFFF;
		}
	}

	.inputBox {
		background: #29314D;
		border-radius: 20rpx;
		margin: 30rpx 0rpx;
		padding: 0 25rpx;

		.input {
			height: 80rpx;
			line-height: 80rpx;
			color: #FFFFFF;
		}

		.text {
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 26rpx;
			color: #FFFFFF;

			text {
				padding-left: 25rpx;
			}
		}
	}

	.free {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #1355F5;
		text-align: center;
	}

	.input-placeholder {
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #797C8B;
		line-height: 24rpx;
	}

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

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