Payment.vue
8.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<script setup>
const props = defineProps({
currentStep: {
type: Number,
required: false,
},
checkoutData: {
type: null,
required: true,
},
})
const emit = defineEmits([
'update:currentStep',
'update:checkout-data',
])
const prop = __props
const checkoutPaymentDataLocal = ref(prop.checkoutData)
const selectedPaymentMethod = ref('card')
const cardFormData = ref({
cardNumber: null,
cardName: '',
cardExpiry: '',
cardCvv: null,
isCardSave: true,
})
const giftCardFormData = ref({
giftCardNumber: null,
giftCardPin: null,
})
const selectedDeliveryAddress = computed(() => {
return checkoutPaymentDataLocal.value.addresses.filter(address => {
return address.value === checkoutPaymentDataLocal.value.deliveryAddress
})
})
const updateCartData = () => {
emit('update:checkout-data', checkoutPaymentDataLocal.value)
}
const nextStep = () => {
updateCartData()
emit('update:currentStep', prop.currentStep ? prop.currentStep + 1 : 1)
}
watch(() => prop.currentStep, updateCartData)
</script>
<template>
<VRow>
<VCol
cols="12"
md="8"
>
<!-- 👉 Offers alert -->
<VAlert
color="success"
variant="tonal"
icon="ri-percent-line"
closable
class="mb-6"
>
<VAlertTitle class="text-success mb-1">
Available Offers
</VAlertTitle>
<p class="mb-0">
- 10% Instant Discount on Bank of America Corp Bank Debit and Credit cards
</p>
<p class="mb-0">
- 25% Cashback Voucher of up to $60 on first ever PayPal transaction. TCA
</p>
</VAlert>
<VTabs
v-model="selectedPaymentMethod"
class="v-tabs-pill"
>
<VTab value="card">
Card
</VTab>
<VTab value="cash-on-delivery">
Cash on Delivery
</VTab>
<VTab value="gift-card">
Gift Card
</VTab>
</VTabs>
<VWindow
v-model="selectedPaymentMethod"
class="pt-6"
style="max-inline-size: 600px;"
>
<VWindowItem value="card">
<VForm>
<VRow>
<VCol cols="12">
<VTextField
v-model="cardFormData.cardNumber"
type="number"
label="Card Number"
placeholder="1234 5678 9012 3456"
/>
</VCol>
<VCol
cols="12"
md="6"
>
<VTextField
v-model="cardFormData.cardName"
label="Name"
placeholder="John Doe"
/>
</VCol>
<VCol
cols="6"
md="3"
>
<VTextField
v-model="cardFormData.cardExpiry"
label="Expiry"
placeholder="MM/YY"
/>
</VCol>
<VCol
cols="6"
md="3"
>
<VTextField
v-model="cardFormData.cardCvv"
label="CVV"
placeholder="123"
type="number"
>
<template #append-inner>
<VTooltip
text="Card Verification Value"
location="bottom"
>
<template #activator="{ props: tooltipProps }">
<VIcon
v-bind="tooltipProps"
size="20"
icon="ri-question-line"
/>
</template>
</VTooltip>
</template>
</VTextField>
</VCol>
<VCol cols="12">
<VSwitch
v-model="cardFormData.isCardSave"
label="Save Card for future billing?"
/>
<div class="mt-4">
<VBtn
class="me-4"
@click="nextStep"
>
Save Changes
</VBtn>
<VBtn
variant="outlined"
color="secondary"
>
Reset
</VBtn>
</div>
</VCol>
</VRow>
</VForm>
</VWindowItem>
<VWindowItem value="cash-on-delivery">
<p class="text-base text-high-emphasis my-6">
Cash on Delivery is a type of payment method where the recipient make payment for the order at the time of delivery rather than in advance.
</p>
<VBtn @click="nextStep">
Pay on delivery
</VBtn>
</VWindowItem>
<VWindowItem value="gift-card">
<h6 class="text-base font-weight-medium my-6">
Enter Gift Card Details
</h6>
<VForm>
<VRow>
<VCol cols="12">
<VTextField
v-model="giftCardFormData.giftCardNumber"
label="Gift Card Number"
placeholder="1234 5678 9012 3456"
/>
</VCol>
<VCol cols="12">
<VTextField
v-model="giftCardFormData.giftCardPin"
label="Gift Card Pin"
placeholder="1234"
/>
</VCol>
<VCol cols="12">
<VBtn @click="nextStep">
Redeem Gift Card
</VBtn>
</VCol>
</VRow>
</VForm>
</VWindowItem>
</VWindow>
</VCol>
<VCol
cols="12"
md="4"
>
<VCard
flat
variant="outlined"
>
<VCardText>
<h6 class="text-h6 mb-4">
Price Details
</h6>
<div class="d-flex justify-space-between text-sm mb-2">
<div class="text-body-1 text-high-emphasis">
Order Total
</div>
<div class="text-body-1">
${{ checkoutPaymentDataLocal.orderAmount }}.00
</div>
</div>
<div class="d-flex justify-space-between text-sm">
<div class="text-high-emphasis text-body-1">
Delivery Charges
</div>
<div
v-if="checkoutPaymentDataLocal.deliverySpeed === 'free'"
class="d-flex align-center"
>
<div class="text-body-1 text-disabled me-2">
$5.00
</div>
<VChip
color="success"
size="small"
>
FREE
</VChip>
</div>
<div v-else>
<span>${{ checkoutPaymentDataLocal.deliveryCharges }}</span>
</div>
</div>
</VCardText>
<VDivider />
<VCardText>
<div class="d-flex justify-space-between text-base mb-2">
<div class="text-high-emphasis font-weight-medium">
Total
</div>
<h6 class="text-h6 text-medium-emphasis">
${{ checkoutPaymentDataLocal.orderAmount + checkoutPaymentDataLocal.deliveryCharges }}.00
</h6>
</div>
<div class="d-flex justify-space-between text-base mb-4">
<h6 class="text-h6">
Deliver to:
</h6>
<VChip
color="primary"
size="small"
class="text-capitalize"
>
{{ checkoutPaymentDataLocal.deliveryAddress }}
</VChip>
</div>
<template
v-for="item in selectedDeliveryAddress"
:key="item.value"
>
<h6 class="text-h6">
{{ item.title }}
</h6>
<p class="text-body-1 mb-1">
{{ item.desc }}
</p>
<p class="text-base mb-4">
Mobile : {{ item.subtitle }}
</p>
</template>
<a
href="javascript:void(0)"
class="font-weight-medium text-base d-inline-block"
>Change address</a>
</VCardText>
</VCard>
</VCol>
</VRow>
</template>