feat: 更新 SubscribeRwa 组件,添加数量输入验证和申购成功提示,优化用户体验

This commit is contained in:
2025-12-19 22:46:32 +07:00
parent c3321bfbf1
commit 8f449f0c68
5 changed files with 70 additions and 23 deletions

View File

@@ -1,36 +1,59 @@
<script lang='ts' setup>
import { toastController } from "@ionic/vue";
const props = defineProps<{
unitPrice: number;
max: number;
}>();
const emit = defineEmits<{
(e: "subscribed", value: number): void;
}>();
const walletStore = useWalletStore();
const { balances } = storeToRefs(walletStore);
const currentUSDTBalance = computed(() => balances.value[0].available);
const maxSubscribeNumber = computed(() => {
return Math.floor(Number(currentUSDTBalance.value) / props.unitPrice);
});
const num = ref<number | null>(null);
async function handleSubscribe() {
if (!num.value || num.value <= 0) {
const toast = await toastController.create({
message: "请输入申购数量",
duration: 2000,
position: "bottom",
color: "warning",
});
await toast.present();
return;
}
emit("subscribed", num.value);
}
</script>
<template>
<ion-content class="ion-padding" :scroll-y="false">
<div class="space-y-5 mt-3">
<div>申购RWA</div>
<div class="space-y-5 mt-3 ion-padding">
<div>申购RWA</div>
<ion-input :placeholder="`最大可申购数量: ${maxSubscribeNumber}`" type="number" :max="maxSubscribeNumber" />
<ion-input
v-model="num"
:placeholder="`最大可申购数量: ${max}`"
type="number"
inputmode="numeric"
:max="max"
/>
<div class="mt-4 text-sm color-(--ion-text-color-secondary)">
单价: ${{ unitPrice }}
</div>
<div class="mt-4 text-sm color-(--ion-text-color-secondary)">
可用余额: ${{ Number(currentUSDTBalance) }}
</div>
<ion-button expand="block" class="mt-6 ui-button" color="primary">
确认申购
</ion-button>
<div class="mt-4 text-sm color-(--ion-text-color-secondary)">
单价: ${{ unitPrice }}
</div>
</ion-content>
<div class="mt-4 text-sm color-(--ion-text-color-secondary)">
可用余额: ${{ Number(currentUSDTBalance) }}
</div>
<ion-button expand="block" class="mt-6 ui-button" color="primary" @click="handleSubscribe">
确认申购
</ion-button>
</div>
</template>
<style scoped>