feat: 更新 SubscribeRwa 组件,添加数量输入验证和申购成功提示,优化用户体验
This commit is contained in:
3
auto-imports.d.ts
vendored
3
auto-imports.d.ts
vendored
@@ -340,7 +340,7 @@ declare global {
|
||||
export type { HapticsOptions } from './src/composables/useVibrate'
|
||||
import('./src/composables/useVibrate')
|
||||
// @ts-ignore
|
||||
export type { PageInstance, InputInstance, ModalInstance, FormInstance } from './src/utils/ionic-helper'
|
||||
export type { PageInstance, InputInstance, ModalInstance, FormInstance, ContentInstance } from './src/utils/ionic-helper'
|
||||
import('./src/utils/ionic-helper')
|
||||
}
|
||||
|
||||
@@ -612,7 +612,6 @@ declare module 'vue' {
|
||||
readonly useStorage: UnwrapRef<typeof import('@vueuse/core')['useStorage']>
|
||||
readonly useStorageAsync: UnwrapRef<typeof import('@vueuse/core')['useStorageAsync']>
|
||||
readonly useStyleTag: UnwrapRef<typeof import('@vueuse/core')['useStyleTag']>
|
||||
readonly useSubscribeModal: UnwrapRef<typeof import('./src/composables/useSubscribeModal')['useSubscribeModal']>
|
||||
readonly useSupported: UnwrapRef<typeof import('@vueuse/core')['useSupported']>
|
||||
readonly useSwipe: UnwrapRef<typeof import('@vueuse/core')['useSwipe']>
|
||||
readonly useTemplateRef: UnwrapRef<typeof import('vue')['useTemplateRef']>
|
||||
|
||||
@@ -8,6 +8,12 @@ const config: CapacitorConfig = {
|
||||
url: "http://192.168.1.55:5173", // Vite默认端口
|
||||
cleartext: true, // 允许HTTP连接
|
||||
},
|
||||
plugins: {
|
||||
Keyboard: {
|
||||
resize: "ionic", // 使用ionic模式,让ion-app自动调整大小
|
||||
resizeOnFullScreen: true, // Android全屏模式下也要调整
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -1,22 +1,46 @@
|
||||
<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 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 }}
|
||||
@@ -26,11 +50,10 @@ const maxSubscribeNumber = computed(() => {
|
||||
可用余额: ${{ Number(currentUSDTBalance) }}
|
||||
</div>
|
||||
|
||||
<ion-button expand="block" class="mt-6 ui-button" color="primary">
|
||||
<ion-button expand="block" class="mt-6 ui-button" color="primary" @click="handleSubscribe">
|
||||
确认申购
|
||||
</ion-button>
|
||||
</div>
|
||||
</ion-content>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -2,3 +2,4 @@ export type PageInstance = InstanceType<typeof import("@ionic/vue").IonPage>;
|
||||
export type InputInstance = InstanceType<typeof import("@ionic/vue").IonInput>;
|
||||
export type ModalInstance = InstanceType<typeof import("@ionic/vue").IonModal>;
|
||||
export type FormInstance = InstanceType<typeof import("vee-validate").Form>;
|
||||
export type ContentInstance = InstanceType<typeof import("@ionic/vue").IonContent>;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang='ts' setup>
|
||||
import { toastController } from "@ionic/vue";
|
||||
import CryptocurrencyColorNuls from "~icons/cryptocurrency-color/nuls";
|
||||
import { client, safeClient } from "@/api";
|
||||
|
||||
@@ -7,6 +8,23 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const { data } = safeClient(client.api.rwa.subscription.available_editions({ editionId: props.id }).get());
|
||||
const model = useTemplateRef<ModalInstance>("model");
|
||||
|
||||
async function handleSubscribe(val: number) {
|
||||
await safeClient(client.api.rwa.subscription.apply.post({
|
||||
editionId: props.id,
|
||||
quantity: String(val),
|
||||
}));
|
||||
const toast = await toastController.create({
|
||||
message: "申购成功",
|
||||
duration: 2000,
|
||||
position: "bottom",
|
||||
color: "success",
|
||||
});
|
||||
|
||||
await toast.present();
|
||||
model.value?.$el.dismiss();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -102,8 +120,8 @@ const { data } = safeClient(client.api.rwa.subscription.available_editions({ edi
|
||||
申购
|
||||
</ion-button>
|
||||
|
||||
<ion-modal trigger="open-modal" :initial-breakpoint="0.4" :breakpoints="[0, 0.4]">
|
||||
<subscribe-rwa :unit-price="Number(data?.unitPrice || 0)" />
|
||||
<ion-modal ref="model" trigger="open-modal" :initial-breakpoint="0.4" :breakpoints="[0, 0.4]">
|
||||
<subscribe-rwa :unit-price="Number(data?.unitPrice || 0)" :max="Number(data?.perUserLimit || 0)" @subscribed="handleSubscribe" />
|
||||
</ion-modal>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
|
||||
Reference in New Issue
Block a user