<template>
	<view class="">
		<card @updateShowMoneyStatus="(e) => showMoney = e">
			<template #cardnum>
				{{ contractAccount.usdt_totle || '--'}}
			</template>
			<template #cardnums>
				{{ contractAccount.totle || '--'}}
			</template>
			<template #cardmuen>
				<block v-for="(item , index ) in cardMuen">
					<view class="card-muen-item_1" @click.stop="cardBtns(item)">
						<image class="item-icon" :src="item.icon" mode="aspectFit"></image>
						<text class="item-name">{{item.name}}</text>
					</view>
				</block>
			</template>

		</card>
		<view class="legal-tender-box">

			<uni-table class="table-box" emptyText="暂无更多数据">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th align="left" style="flex: 1;">币种</uni-th>
					<uni-th align="left" style="flex: 1;">账户权益</uni-th>
					<uni-th align="left" style="flex: 1;">冻结</uni-th>
					<uni-th align="right" style="flex: 1;">可用</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<template v-if="contractAccount.balance">
					<uni-tr v-for="(item , index) in contractAccount.balance" :key="`contractAccount_${index}`">
						<uni-td style="flex: 1;">{{ item.currency_name }}</uni-td>
						<uni-td style="flex: 1;">{{ showMoney ? getNums(item.lock_lever_balance , item.usdt_price) : '*****' }}</uni-td>
						<uni-td style="flex: 1;">{{ showMoney ? item.lock_lever_balance : '*****' }}</uni-td>
						<uni-td style="text-align: right; flex: 1;">{{ showMoney ? item.usdt_price : '*****' }}</uni-td>
					</uni-tr>
				</template>
			</uni-table>
		</view>
		
		<capital-switch ref="capitalSwitchRef" />
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import capitalSwitch from "./capital-switch.vue"
	import card from "../card.vue"
	import {
		checkBill
	} from "../card.js"
	export default {
		name: 'contractModules',
		components: {
			card,
			capitalSwitch
		},
 
		data() {
			return {
				showMoney:false,
				cardMuen: [{
					icon: require('@/static/images/zichan/icon_01.png'),
					name: '资金划转',
					btn: "capitalSwitch"
				}, {
					icon: require('@/static/images/zichan/icon_02.png'),
					name: '用户账单',
					path: '/pages/property/bill?type=0'
				}],
			};
		},
		
		computed: {
			...mapGetters([
				'contractAccount',
			])
		},
		methods: {
			cardBtns(item) {
				const btn = item?.btn
				const path = item?.path

				if (btn) {
					// 资金转换
					this.$nextTick(() => {
						this.$refs.capitalSwitchRef.open()
					})
				} else if(path){
					 
					// '用户账单',
					checkBill(path)
				}

			},
			// 
			getNums(a,b){
				return this.$decimalNum.add(a,b)
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "~./../table.scss";

	.legal-tender-box {
		// padding: 0 $pages-padding ;
		width: 100%;


	}

	.table-box {
		padding: 0 $pages-padding ;
	}
</style>