<template>
	<view>
		<h-dark :title="t('recharge.title')"></h-dark>
		<view class="flex items-center bg-white px-[50rpx] py-[20rpx] mt-[12rpx]">
			<u-icon size="80" :name="method.logo"></u-icon>
			<view class="ml-[16rpx]">{{method.name}}</view>
		</view>
		<view class="bg-white mt-[20rpx] p-[40rpx]">
			<view class="flex flex-col items-center">
				<u-image width="180px" height="180px" :src="method.qrcode"></u-image>
			</view>
			<view class="text-center text-muted mt-[30rpx]">
				<view class="mb-[16rpx]">{{t('recharge.address')}}</view>
				<view class="bg-[#f6f7fb] rounded p-[20rpx]">
					<view class="flex break-all items-center justify-center" v-if="method.address!=''"
						@click.stop="copyText(method.address)">
						<view>{{method.address}}</view>
						<view><u-icon size="26" name="/static/images/common/copy_1.png"></u-icon></view>
					</view>
				</view>
			</view>
		</view>
		<view class="px-[40rpx] mt-[50rpx] leading-loose font-bold">
			<view class="text-error">
				{{replaceStr(t('recharge.udunTips1'),'{code}',method.protocol)}}
			</view>
			<view class="text-error">
				{{t('recharge.udunTips2')}}
			</view>
			<view class="text-error">
				{{t('recharge.udunTips3')}}
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { ref, reactive } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { rechargeMethodDetailTron } from '@/api/finance'
	import { replaceStr } from '@/utils/util'
	import { useCopy } from '@/hooks/useCopy'
	import { t } from '@/utils/util'

	uni.setNavigationBarTitle({ title: t('recharge.title') })
	const { copy } = useCopy()
	const method = ref<any>({})
	const formData = reactive({
		id: 0,
		money: '',
	})

	const copyText = async (text : string) => {
		copy(text);
		uni.$u.toast(t('common.copySuccess'))
	}

	const getData = async (id : number) => {
		method.value = await rechargeMethodDetailTron({ id })
	}
	onLoad((options : any) => {
		formData.id = options.id
		formData.money = options.money
		getData(formData.id)
	})
</script>

<style lang="scss">
</style>