diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 959e51e..778a2fb 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -109,6 +109,7 @@ declare global { const shallowReactive: typeof import('vue').shallowReactive const shallowReadonly: typeof import('vue').shallowReadonly const shallowRef: typeof import('vue').shallowRef + const showSuccessToast: typeof import('vant/es').showSuccessToast const showToast: typeof import('vant/es').showToast const storeToRefs: typeof import('pinia').storeToRefs const syncRef: typeof import('@vueuse/core').syncRef @@ -450,6 +451,7 @@ declare module 'vue' { readonly shallowReactive: UnwrapRef readonly shallowReadonly: UnwrapRef readonly shallowRef: UnwrapRef + readonly showSuccessToast: UnwrapRef readonly showToast: UnwrapRef readonly storeToRefs: UnwrapRef readonly syncRef: UnwrapRef diff --git a/src/views/product/components/subscribe.vue b/src/views/product/components/subscribe.vue index 2e1309f..f9ea74f 100644 --- a/src/views/product/components/subscribe.vue +++ b/src/views/product/components/subscribe.vue @@ -43,20 +43,12 @@ async function confirmSubscribe() { } if (!paymentPassword.value) { - toastController.create({ - message: "请输入交易密码", - duration: 2000, - position: "top", - }).then(toast => toast.present()); + showToast("请输入交易密码"); return; } if (!currentWallet.value || Number(currentWallet.value?.available) < Number(product.value.price)) { - toastController.create({ - message: "所选钱包余额不足,请选择其他钱包或充值", - duration: 2000, - position: "top", - }).then(toast => toast.present()); + showToast("所选钱包余额不足,请选择其他钱包或充值"); return; } @@ -65,17 +57,10 @@ async function confirmSubscribe() { walletTypeId: selectedWallet.value, tradePassword: paymentPassword.value, })); - const toast = await toastController.create({ - message: "产品申购成功!", - duration: 2000, - position: "bottom", - color: "success", - }); - await toast.present(); + showSuccessToast("产品申购成功!"); setTimeout(() => { - toast.dismiss(); emit("success"); - }, 2000); + }, 1000); }