-
Notifications
You must be signed in to change notification settings - Fork 0
/
Loja.vue
78 lines (69 loc) · 1.86 KB
/
Loja.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
71
72
73
74
75
76
77
78
<template>
<Painel titulo="Loja Virtual" verde>
<div class="loja">
<span>Adicionar</span>
<input type="number" v-model.number="quantidade">
<span>itens de <strong>R$</strong></span>
<input type="number" v-model.number="preco">
<button @click="adicionar">Agora!</button>
</div>
</Painel>
</template>
<script>
import {mapActions} from 'vuex';
export default {
data() {
return {
sequencia: 1,
// quantidade: 1,
// preco: 9.99,
}
},
computed:{
quantidade() {
return this.$store.state.parametros.quantidade;
},
preco(){
return this.$store.state.parametros.preco;
}
},
methods: {
...mapActions('carrinho',["adicionarProduto"]),
/* adicionarProduto(){
this.$store.dispatch('adicionarProduto', produto);
},*/
adicionar() {
const produto = {
id: this.sequencia,
nome: `Produto ${this.sequencia}`,
quantidade: this.quantidade,
preco: this.preco
}
this.sequencia++
// eslint-disable-next-line
//console.log(produto)
//this.$store.state.produtos.push(produto)
//this.$store.commit("adicionarProduto", produto);
this.adicionarProduto(produto);
//this.$store.dispatch('adicionarProduto', produto);
// eslint-disable-next-line
console.log(this.$store.getters.getNome)
// eslint-disable-next-line
console.log(this.$store.getters.getNomeCompleto)
}
}
}
</script>
<style>
.loja {
display: flex;
justify-content: center;
}
.loja > * {
margin: 0px 10px;
}
input {
font-size: 2rem;
width: 90px;
}
</style>