index.js
1.6 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
import Vue from 'vue'
import Vuex from 'vuex'
//挂载Vuex
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
nickname: '请登录',
money: 0,
avatar: '',
pername: '',
ticket_num: 0,
level_name: '',
birthday: '',
gender: '',
vip_logo: '',
storeCount: '', // 购物车
shopcount: [], // 购物车数量
KEY: {},
},
mutations: {
perUserInfo(state, step) {
state.nickname = "欢迎您!" + step.nickname
state.pername = step.nickname || ''
state.money = step.money || ''
state.avatar = step.avatar || ''
state.ticket_num = step.ticket_num || ''
state.level_name = step.level_name || ''
state.birthday = step.birthday || ''
state.gender = step.gender || ''
state.vip_logo = step.vip_logo || ''
localStorage.setItem('KEY', JSON.stringify(step) || '');
state.KEY = step || '';
},
loginoutInfo(state) {
state.nickname = '请登录'
state.pername = ''
state.money = ''
state.avatar = ''
state.ticket_num = ''
state.level_name = ''
state.birthday = ''
state.gender = ''
state.vip_logo = ''
state.storeCount = ''
},
getshopcount(state, step) {
state.storeCount = step;
},
},
actions: {
userinfo(context, step) {
context.commit('perUserInfo', step)
},
addStoreCount(context, step) {
context.commit('getshopcount', step)
},
loginOutInfo(context) {
context.commit('loginoutInfo')
},
},
getters: {
showNum(state) {
return state.storeCount
}
}
})
export default store