forked from 14nrv/buefy-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.vue
70 lines (62 loc) · 1.93 KB
/
cart.vue
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
<template lang="pug">
.container
.section
.capsule.cart.content
StepMenu(:actualStep="actualStep", :menu="stepMenuContent")
div(v-if="total > 0")
div(v-if="actualStep === 0")
transition-group.content(name="items", tag="div")
CartProductListItem(v-for="item in cart",
:key="item.name",
:item="item")
.is-clearfix
h3.total.is-pulled-left Total: {{ amount | usdollar }}
button.button.is-success.is-pulled-right(@click="setActualStep(1)") > Next
div(v-if="actualStep === 1")
Checkout(:total="amount")
.empty.has-text-centered(v-else-if="!total && !success")
h3 Your cart is empty.
nuxt-link(exact to="/")
button.button Fill er up!
.has-text-centered(v-else)
h2 Success!
p Your order has been processed, it will be delivered shortly.
nuxt-link(exact to="/")
button.button Fill again your cart
</template>
<script>
import { createNamespacedHelpers } from 'vuex'
import Checkout from '@/components/Checkout'
import CartProductListItem from '@/components/CartProductListItem'
import StepMenu from '@/components/StepMenu'
import stepMenuContent from '@/components/StepMenu/stepMenuContent.json'
const { mapGetters, mapActions } = createNamespacedHelpers('cart')
export default {
head: {
script: [
{ src: 'https://js.stripe.com/v3/' }
]
},
components: {
StepMenu,
CartProductListItem,
Checkout
},
filters: {
usdollar: value => `$${value}`
},
data:() => ({
stepMenuContent
}),
computed: {
...mapGetters(['cart', 'total', 'amount', 'success', 'actualStep'])
},
methods: {
...mapActions(['setSuccess', 'setActualStep'])
},
beforeDestroy() {
this.success && this.setSuccess(false)
this.setActualStep(0)
}
}
</script>