<template>
	<view class="">
		<switchPopup ref="switchPopupRef" :availableMoney="getBiMoney(from_field)" :from_field="from_field"
			:to_field="to_field">
			<template #accounthint>
				<view class="hint-text">
					温馨提示:无限模式仅盈利部分可划转至合
					约账户中，最小划转金额为100USDT
				</view>
			</template>
			<template #accountbox>
				<view class="account-item">
					{{ getBiName(from_field) }}账户
				</view>
				<view class="account-link" >划转至</view>
				<view class="account-item">
					{{ getBiName(to_field) }}账户
				</view>
			</template>
		</switchPopup>
	</view>
	<!-- <uni-popup ref="popupRef">

		<view class="unopen-box">
			<text class="z-close iconfont" @click.stop="close">&#xe621;</text>
			<view class="unopen-title"> 
				<text>资金划转</text>
			</view>
			<view class="unopen-content">
				<view class="account-box">
					
				</view>
				<view class="capital-type">
					<text class="type-left">全部</text>
					<input class="type-input" type="number">
					<text class="type-rigth">USDT</text>
				</view>
				<view class="capital-nums">
					<text class="num-title">可划转金额：</text>
					<text class="num">{{ getBiMoney(from_field) }} USDT</text>
				</view>
				<view class="capital-btn" @click.stop="changeAccount">
					确定
				</view>
			</view>
		</view>
	</uni-popup> -->
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		biName
	} from "../card.js"
	import {
		setChangeAccount
	} from "./../card.js"
	import switchPopup from "../switch.vue"
	// 合约 - 币币
	// 币币 - 合约 / 法币
	export default {
		name: "capitalSwitchModules",
		components: {
			switchPopup
		},
		data() {
			return {
				from_field: 'micro',
				to_field: 'lever'
			};
		},
		computed: {
			...mapGetters([
				'contractAccount',
				'GiftMoneyAccount'
			]),
			getBiName() {
				return function(key) {
					return biName[key]
				}
			},
			getBiMoney() {
				return function(key) {
					let nums = 0;
					switch (key) {
						case 'micro':
							nums = this.GiftMoneyAccount.usdt_totle
							break;
						case 'lever':
							nums = this.contractAccount.usdt_totle
							break;
					}
					console.log('contractAccount = ', this.contractAccount)
					return nums || 0
				}
			}
		},
		mounted() {
			// this.open()
		},
		methods: {
			// 切换币
			switchBiType() {
				const k = this.from_field;
				this.from_field = this.to_field;
				this.to_field = k;
				// this.from_field:'legal',
				// to_field:'change'
			},
			open() {
				this.$nextTick(() => {
					this.$refs.switchPopupRef.open();
				})
			},
		 
			// changeAccount(){
			// 	let data = {
			// 		currency_id:'1',
			// 		number:100,
			// 		from_field:this.from_field,
			// 		to_field:this.to_field
			// 	}
			// 	setChangeAccount(data).then(res => {

			// 	}).catch(err => {

			// 	}).finally(() => {})
			// }

		}
	}
</script>

<style lang="scss" scoped>
	@import "~./../switch.scss";
	.account-link{
		justify-content: center;
		font-size: 24rpx !important;
	}
	.account-item{
		font-size: 28rpx !important;
	}
</style>