From fbc99361c005dae0e08c8af1ff6fd74af3fa347c Mon Sep 17 00:00:00 2001 From: Wayne Hsu Date: Tue, 30 May 2023 08:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8B=95=E5=85=8C=E6=8F=9B=E5=BA=8F?= =?UTF-8?q?=E8=99=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Cart/Checkout.vue | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/pages/Cart/Checkout.vue b/src/pages/Cart/Checkout.vue index c4c210d..5b08c8a 100644 --- a/src/pages/Cart/Checkout.vue +++ b/src/pages/Cart/Checkout.vue @@ -193,13 +193,18 @@ data-bs-parent="#accordionBonus" >
-
- +
+ +
+
+ 兌換 +
{{ bonus.name }} @@ -332,14 +337,6 @@ const bonus = reactive({ //檢查優惠代碼 const handleCheckBonusSn = async () => { - if (bonus.sn.length !== 10) { - bonus.name = "沒有優惠劵"; - bonus.number = 0; - bonus.remain = 0; - - orderStore.discount = 0; - return; - } let res = await checkBonusSn(bonus.sn); @@ -349,7 +346,7 @@ const handleCheckBonusSn = async () => { bonus.remain = res.data.remain_number; bonus.number = res.data.bonus_number; //如果res.data最後是% 就相剩,沒有%就直接扣 - if (res.data.type_money.slice(-1) === "%") { + if (res.data.type_money.slice(-1) == '%' || res.data.type_money.slice(-1) ==='%') { orderStore.discount = ((100 - res.data.type_money.slice(0, -1)) / 100) * orderStore.sum_amount; } else { orderStore.discount = res.data; @@ -359,8 +356,6 @@ const handleCheckBonusSn = async () => { } }; -watch(() => bonus.sn, _.debounce(handleCheckBonusSn, 500)); - //將購物車商品資料轉換成訂單商品資料 const cartToOrder = () => { if (cartStore.cartItems.length === 0) { @@ -613,4 +608,16 @@ const detail = computed(() => { .bonus-desc { padding: 0 10px; } + +.bonus-input{ + display: flex; + align-items: center; + div:nth-child(1){ + flex: 1; + padding-right: 10px; + } + div:nth-child(2){ + width: 50px; + } +}