addressData.js
1.16 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
/*
* Created by shipfi on 2016/5/31.
*/
import {
MY_ADDRESS_LIST,
MY_ADDRESS_LIST_ClEAR,
SET_DEFAULT_ADDRESS,
SELECT_ADDRESS
} from '../mutationTypes';
const state = {
myAddressList:[],
myAddressCount:0,
selectAddress:{}
};
const mutations = {
[MY_ADDRESS_LIST](state,action){//获取我的地址列表
state.myAddressList = state.myAddressList.concat(action.myAddressList.list);
state.myAddressCount = action.myAddressList.count;
},
[MY_ADDRESS_LIST_ClEAR](state,action){//清除我的地址列表
state.myAddressList = [];
state.myAddressCount ='';
},
[SET_DEFAULT_ADDRESS](state,action){//设置默认地址
let index = state.myAddressList.findIndex(function(element) {
return element.buyerAddressId==action.buyerAddressId;
});
state.myAddressList.forEach(function(element){
element.isDefault=0;
});
state.myAddressList[index].isDefault=1;
},
[SELECT_ADDRESS](state,action){//获取指定地址信息
state.selectAddress = action.selectAddress;
},
};
export default {
state,
mutations
};