feat: 添加交易密码状态检查,优化交易密码验证逻辑

This commit is contained in:
2026-01-24 17:23:17 +07:00
parent c68b2d2af0
commit 0b50a52845
4 changed files with 39 additions and 29 deletions

View File

@@ -10,6 +10,7 @@ const router = useRouter();
const walletStore = useWalletStore(); const walletStore = useWalletStore();
const { wallets } = storeToRefs(walletStore); const { wallets } = storeToRefs(walletStore);
const filterWallets = computed(() => wallets.value.filter(w => w.walletType.allowExchange === true)); const filterWallets = computed(() => wallets.value.filter(w => w.walletType.allowExchange === true));
const { data: transactionPasswordStatus } = safeClient(client.api.user.security["transaction-password"].status.get());
// 兑换金额 // 兑换金额
const exchangeAmount = ref(""); const exchangeAmount = ref("");
@@ -137,7 +138,8 @@ async function handleSubmit() {
return; return;
} }
// 验证交易密码 // 验证交易密码(如果已设置)
if (transactionPasswordStatus.value?.enabled) {
if (!transactionPassword.value) { if (!transactionPassword.value) {
await showToast("请输入交易密码", "warning"); await showToast("请输入交易密码", "warning");
return; return;
@@ -147,6 +149,7 @@ async function handleSubmit() {
await showToast("交易密码至少6位", "warning"); await showToast("交易密码至少6位", "warning");
return; return;
} }
}
const alert = await alertController.create({ const alert = await alertController.create({
header: "确认兑换", header: "确认兑换",
@@ -280,7 +283,7 @@ function goToRecords() {
</div> </div>
<!-- 交易密码 --> <!-- 交易密码 -->
<div class="section-card"> <div v-if="transactionPasswordStatus?.enabled" class="section-card">
<div class="section-title"> <div class="section-title">
<ion-icon :icon="keyOutline" class="title-icon" /> <ion-icon :icon="keyOutline" class="title-icon" />
交易密码 交易密码

View File

@@ -15,6 +15,7 @@ const emit = defineEmits<{
}>(); }>();
const { data: product } = safeClient(() => client.api.subscription.products({ productId: props.productId }).get()); const { data: product } = safeClient(() => client.api.subscription.products({ productId: props.productId }).get());
const { data: transactionPasswordStatus } = safeClient(client.api.user.security["transaction-password"].status.get());
const paymentPassword = ref(""); const paymentPassword = ref("");
const selectedWallet = ref<string | null>(null); const selectedWallet = ref<string | null>(null);
@@ -42,7 +43,7 @@ async function confirmSubscribe() {
return; return;
} }
if (!paymentPassword.value) { if (transactionPasswordStatus.value?.enabled && !paymentPassword.value) {
showToast("请输入交易密码"); showToast("请输入交易密码");
return; return;
} }
@@ -119,7 +120,7 @@ async function confirmSubscribe() {
</div> </div>
<!-- 交易密码 --> <!-- 交易密码 -->
<div class="password-section"> <div v-if="transactionPasswordStatus?.enabled" class="password-section">
<div class="section-title"> <div class="section-title">
交易密码 交易密码
</div> </div>

View File

@@ -23,6 +23,7 @@ const recipientPhone = ref("");
// 交易密码 // 交易密码
const transactionPassword = ref(""); const transactionPassword = ref("");
const { data: transactionPasswordStatus } = safeClient(client.api.user.security["transaction-password"].status.get());
onMounted(async () => { onMounted(async () => {
await walletStore.syncWallets(); await walletStore.syncWallets();
@@ -110,7 +111,8 @@ async function handleSubmit() {
return; return;
} }
// 验证交易密码 // 验证交易密码(如果已设置)
if (transactionPasswordStatus.value?.enabled) {
if (!transactionPassword.value) { if (!transactionPassword.value) {
await showToast("请输入交易密码", "warning"); await showToast("请输入交易密码", "warning");
return; return;
@@ -120,6 +122,7 @@ async function handleSubmit() {
await showToast("交易密码至少6位", "warning"); await showToast("交易密码至少6位", "warning");
return; return;
} }
}
const alert = await alertController.create({ const alert = await alertController.create({
header: "确认转账", header: "确认转账",
@@ -275,7 +278,7 @@ function goToRecords() {
</div> </div>
<!-- 交易密码 --> <!-- 交易密码 -->
<div class="section-card"> <div v-if="transactionPasswordStatus?.enabled" class="section-card">
<div class="section-title"> <div class="section-title">
<ion-icon :icon="keyOutline" class="title-icon" /> <ion-icon :icon="keyOutline" class="title-icon" />
交易密码 交易密码

View File

@@ -17,6 +17,7 @@ const selectedWallet = ref<Wallet | null>(null);
const transactionPassword = ref(""); const transactionPassword = ref("");
const selectedBankAccount = ref<Receipt | null>(null); const selectedBankAccount = ref<Receipt | null>(null);
const { data: bankAccounts } = await safeClient(client.api.receipt_method.get()); const { data: bankAccounts } = await safeClient(client.api.receipt_method.get());
const { data: transactionPasswordStatus } = safeClient(client.api.user.security["transaction-password"].status.get());
onMounted(async () => { onMounted(async () => {
await walletStore.syncWallets(); await walletStore.syncWallets();
@@ -100,7 +101,8 @@ async function handleSubmit() {
return; return;
} }
// 验证交易密码 // 验证交易密码(如果已设置)
if (transactionPasswordStatus.value?.enabled) {
if (!transactionPassword.value) { if (!transactionPassword.value) {
await showToast("请输入交易密码", "warning"); await showToast("请输入交易密码", "warning");
return; return;
@@ -110,6 +112,7 @@ async function handleSubmit() {
await showToast("交易密码至少6位", "warning"); await showToast("交易密码至少6位", "warning");
return; return;
} }
}
const alert = await alertController.create({ const alert = await alertController.create({
header: "确认提现", header: "确认提现",
@@ -316,7 +319,7 @@ function goToRecords() {
</div> </div>
<!-- 交易密码 --> <!-- 交易密码 -->
<div class="section-card"> <div v-if="transactionPasswordStatus?.enabled" class="section-card">
<div class="section-title"> <div class="section-title">
<ion-icon :icon="keyOutline" class="title-icon" /> <ion-icon :icon="keyOutline" class="title-icon" />
交易密码 交易密码