File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -176,17 +176,33 @@ async function handleCheckout() {
176176 class =" flex-1 md:w-auto w-full"
177177 >
178178 <template #item =" { item } " >
179- {{ item.title }}
180-
181- <span class =" text-gray-500" >{{ formatPrice(item.price, item.currency) }} / {{ item.amount }} credits</span >
179+ <span class =" text-gray-500" >
180+ <template v-if =" item .price_discount " >
181+ {{ formatPrice(Number(item.price_discount), item.currency) }}
182+ / {{ item.amount }} {{ $t('credits') }}
183+
184+ <UBadge class =" line-through ml-2" >Giá gốc:{{ formatPrice(Number(item.price), item.currency) }}</UBadge >
185+ </template >
186+ <template v-else >
187+ {{ formatPrice(Number(item.price), item.currency) }}
188+ / {{ item.amount }} {{ $t('credits') }}
189+
190+ </template >
191+ </span >
182192 </template >
183193 </USelect >
184194
185195 <UButton id =" topup" size =" lg" color =" neutral" trailing-icon =" i-lucide-rocket" class =" md:w-auto w-full" @click =" handleCheckout" >
186196 <b >
187197 {{ $t('Buy') }} {{ selectedPrice?.amount || 0 }} credits
188198 </b >
189- ({{ formatPrice(selectedPrice?.amount || 0, selectedPrice?.currency || 'VND') }})
199+ <template v-if =" selectedPrice ?.price_discount " >
200+ (<span class =" line-through" >{{ formatPrice(Number(selectedPrice?.price || 0), selectedPrice?.currency || 'VND') }}</span >
201+ {{ formatPrice(Number(selectedPrice?.price_discount || 0), selectedPrice?.currency || 'VND') }})
202+ </template >
203+ <template v-else >
204+ ({{ formatPrice(Number(selectedPrice?.price || 0), selectedPrice?.currency || 'VND') }})
205+ </template >
190206 </UButton >
191207 </div >
192208 </UFormField >
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export async function createPaymentCheckout(
2020
2121 const [ productType , productId ] = payload . productIdentifier . split ( ':' )
2222
23- let productInfo : { id : string , price : number , amount : number } | undefined
23+ let productInfo : { id : string , price : number , amount : number , price_discount : number } | undefined
2424
2525 const { createOrder, createPayment, createProviderTransaction } = usePayment ( )
2626 const { getProductByProductId } = useProduct ( )
@@ -49,7 +49,7 @@ export async function createPaymentCheckout(
4949 const userPayment = await createPayment (
5050 userOrder . id ,
5151 payload . user . id ,
52- Number ( productInfo . price ) ,
52+ Number ( productInfo . price_discount || productInfo . price ) ,
5353 )
5454
5555 const orderCode = new Date ( ) . getTime ( )
You can’t perform that action at this time.
0 commit comments