feat: 更新 @riwa/api-types 依赖版本至 0.0.130,并修正转账用户ID引用及表单验证逻辑

This commit is contained in:
2026-01-12 19:52:15 +07:00
parent d48efd9449
commit 75402348f8
4 changed files with 20 additions and 20 deletions

View File

@@ -10,7 +10,7 @@ import MaterialSymbolsUpload from "~icons/material-symbols/upload";
const userStore = useUserStore();
const { userProfile } = storeToRefs(userStore);
const url = computed(() => {
return `/transfer_to_user/${userProfile.value?.uid}`;
return `/transfer_to_user/${userProfile.value?.userId}`;
});
const qrcode = useQRCode(url, {
type: "image/webp",

View File

@@ -2,6 +2,7 @@
import type { GenericObject } from "vee-validate";
import type { FormInstance } from "@/utils";
import { loadingController, modalController, toastController } from "@ionic/vue";
import { toTypedSchema } from "@vee-validate/zod";
import { ErrorMessage, Field, Form } from "vee-validate";
import { z } from "zod";
import { client, safeClient } from "@/api";
@@ -23,7 +24,7 @@ const targetUser = ref<any>(null);
// 表单初始值
const initialValues = {
assetCode: "USDT",
amount: "",
amount: undefined,
memo: "",
};
@@ -38,15 +39,14 @@ const availableBalance = computed(() => {
});
// 验证规则
const schema = computed(() => z.object({
const schema = computed(() => toTypedSchema(z.object({
assetCode: z.string().min(1, "请选择币种"),
amount: z
.string()
.min(1, "请输入转账金额")
.refine(value => Number(value) > 0, "转账金额必须大于0")
.refine(value => Number(value) <= Number(availableBalance.value), `可用余额不足,当前余额:${availableBalance.value}`),
.number({ required_error: "请输入转账金额", invalid_type_error: "请输入有效的数字" })
.positive("转账金额必须大于0")
.refine(value => value <= Number(availableBalance.value), `可用余额不足,当前余额:${availableBalance.value}`),
memo: z.string().optional(),
}));
})));
// 打开币种选择
async function openSelectCurrency() {
@@ -66,7 +66,7 @@ async function openSelectCurrency() {
// 设置全部金额
function setMaxAmount() {
formInst.value?.setFieldValue("amount", availableBalance.value);
formInst.value?.setFieldValue("amount", Number(availableBalance.value));
}
// 获取目标用户信息
@@ -76,7 +76,7 @@ async function fetchTargetUser() {
});
await loading.present();
const { data, error } = await safeClient(() => client.api.user({ uid: props.id }).get());
const { data, error } = await safeClient(() => client.api.transfer.payee({ userId: props.id }).verify.get());
await loading.dismiss();
@@ -105,7 +105,7 @@ async function onSubmit(values: GenericObject) {
const { error } = await safeClient(() => client.api.transfer.post({
assetCode: values.assetCode as string,
amount: values.amount as string,
amount: String(values.amount),
toUserId: props.id,
memo: values.memo as string,
}));
@@ -153,10 +153,10 @@ onMounted(() => {
<ui-avatar :src="targetUser.avatar" class="size-14" />
<div class="flex-1">
<div class="text-base font-semibold">
{{ targetUser.nickname || targetUser.username }}
{{ targetUser.toUserDisplayName }}
</div>
<div class="text-sm text-text-400 mt-1">
ID: {{ targetUser.uid }}
ID: {{ id }}
</div>
</div>
</div>