<template>
	<view class="center">
		<view class="top">
			<view class="top-num">{{ jf }}</view>
			<view class="top-font">可转账购物积分</view>
		</view>
		<view class="main">
			<view class="main-font">收款人账户</view>
			<input class="main-input" type="text" value="" v-model="account" placeholder="请输入收款人账户" placeholder-class="main-input" />
		</view>
		<view class="main">
			<view class="main-font">收款人UID</view>
			<input class="main-input" type="text" value="" v-model="uid" placeholder="请输入收款人UID" placeholder-class="main-input" />
		</view>
		<view class="main">
			<view class="main-font">交易密码</view>
			<input class="main-input" type="text" value="" v-model="password" placeholder="请输入交易密码" placeholder-class="main-input" />
		</view>
		<view class="main">
			<view class="main-font">转账数量</view>
			<input class="main-input" type="text" value="" v-model="num" placeholder="请输入转账数量" placeholder-class="main-input" />
		</view>
		<view class="btn" @click="transfer">
			提交申请
		</view>
	</view>
</template>

<script>
import { moneyLog, recharge, wallet } from '@/api/finance.js';
export default {
	data() {
		return {
			jf: 0, //可转账购物积分
			uid: '', //收款人UID
			account:'',//收款人账号
			password:'',//交易密码
			num: '' ,//转账数量
			type:'',//转账的类型0是拼团积分，1是货款
		};
	},
	onLoad(option) {
		if(option.type == 1) {
			uni.setNavigationBarTitle({
				title: "货款转账"
			});
		}
		wallet({}).then(({ data }) => {
			const obj = this
			const arr = Object.keys(data.back);
			console.log(arr);
			arr.forEach(e => {
				if(e == 'USDC'){
					obj.jf = (data.back[e].money.money*1)
				}
			});
		});
	},
	methods:{
		transfer() {
			let obj = this;
			if (obj.account == '') {
				obj.$api.msg('请输入对方账号！');
				return;
			}
			if (obj.uid == '') {
				obj.$api.msg('请输入对方UID！');
				return;
			}
			if (obj.password == '') {
				obj.$api.msg('请输入交易密码！');
				return;
			}
			if (obj.num == '') {
				obj.$api.msg('请输入转账数量！');
				return;
			}
			goPay({
				type: 'USDC',
				num: obj.num,
				to_uid: obj.uid,
				trade_psw: obj.password,
				to_user_account: obj.account
			}).then(data => {
				obj.num = '';
				obj.UID = '';
				obj.password = '';
				obj.account = '';
				obj.$api.msg(data.msg);
			});
		},
	}
};
</script>

<style lang="scss">
page,
.center {
	background: #f2f3f5;
	height: 100%;
}
.top {
	margin-top: 20rpx;
	background: #ffffff;
	padding: 30rpx 0;
	text-align: center;
	.top-num {
		font-size: 42rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
	}
	.top-font {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666666;
	}
}
.main {
	padding: 36rpx 24rpx;
	background-color: #ffffff;
	margin-top: 20rpx;
	.main-font {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #333333;
	}
	.main-input {
		margin-top: 10rpx;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 110px;
	}
}
.btn {
	text-align: center;
	margin: 120rpx auto;
	width: 670rpx;
	height: 88rpx;
	background: linear-gradient(0deg, #2E58FF, #32C6FF);
	border-radius: 10px;
	text-align: center;
	line-height: 88rpx;
	font-size: 32rpx;
	font-family: SourceHanSansCN;
	font-weight: 500;
	color: #FEFEFE;
}
</style>
