first commit
This commit is contained in:
66
金壶/appV1/store/modules/path.js
Normal file
66
金壶/appV1/store/modules/path.js
Normal file
@@ -0,0 +1,66 @@
|
||||
export default {
|
||||
state:{
|
||||
list:[
|
||||
{
|
||||
name:"金壶医药",
|
||||
phone:"158****531",
|
||||
path:"安徽省合肥市肥东县经济开发区临泉路",
|
||||
detailPath:"六号楼五楼",
|
||||
isdefault:false
|
||||
},
|
||||
{
|
||||
name:"小崔",
|
||||
phone:"158****531",
|
||||
path:"地球村",
|
||||
detailPath:"哈哈哈...",
|
||||
isdefault:false
|
||||
}
|
||||
],
|
||||
},
|
||||
getters:{
|
||||
// 获取默认地址
|
||||
defaultPath:(state)=>{
|
||||
return state.list.filter(v=> v.isdefault)
|
||||
}
|
||||
},
|
||||
mutations:{
|
||||
// 创建收货地址
|
||||
createPath(state,item){
|
||||
state.list.unshift(item)
|
||||
},
|
||||
// 删除收货地址
|
||||
delPath(state,index){
|
||||
state.list.splice(index,1)
|
||||
},
|
||||
// 修改收货地址
|
||||
updatePath(state,{index,item}){
|
||||
for (let key in item) {
|
||||
state.list[index][key] = item[key]
|
||||
}
|
||||
},
|
||||
// 取消默认地址
|
||||
removeDefault(state){
|
||||
state.list.forEach((v)=>{
|
||||
if (v.isdefault) {
|
||||
v.isdefault = false
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
actions:{
|
||||
// 修改地址
|
||||
updatePathAction({commit},obj){
|
||||
if (obj.item.isdefault) {
|
||||
commit('removeDefault');
|
||||
}
|
||||
commit('updatePath',obj)
|
||||
},
|
||||
// 增加地址
|
||||
createPathAction({commit},item){
|
||||
if (item.isdefault) {
|
||||
commit('removeDefault');
|
||||
}
|
||||
commit('createPath',item)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user