|
|
import * as Types from './types';
|
|
|
import {
|
|
|
get
|
|
|
} from 'lodash';
|
|
|
|
|
|
export default {
|
|
|
// 获取用户地址列表
|
|
|
async fetchUserAddressList({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.get('/api/address/gethidden', {
|
|
|
uid: '500031912',
|
|
|
});
|
|
|
|
|
|
console.log('----------', result.data);
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.FETCH_USER_ADDRESS_LIST, {
|
|
|
list: get(result, 'data', [])
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 获取地址标签
|
|
|
async fetchAddressTags({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.get('/api/address/getTags');
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.FETCH_ADDRESS_TAGS, {
|
|
|
list: get(result, 'data', [])
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
async fetchAddressProvinces({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.get('/api/address/getProvinces');
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.FETCH_ADDRESS_PROVINCES, {
|
|
|
list: get(result, 'data', [])
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 设置默认地址, post请求
|
|
|
async setDefaultAddress({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.post('/api/address/setDefaultAddress');
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.SET_DEFAULT_ADDRESS);
|
|
|
}
|
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
|
|
|
// 添加、更新、删除地址,post请求
|
|
|
async addUserAddress({
|
|
|
commit
|
|
|
}, {
|
|
|
uid
|
|
|
}) {
|
|
|
const result = await this.$api.post('/api/address/addAddress', {
|
|
|
uid
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.ADD_USER_ADDRESS_INFO);
|
|
|
}
|
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
|
|
|
async updateUserAddress({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.post('/api/address/updateAddress');
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.UPDATE_USER_ADDRESS_INFO);
|
|
|
}
|
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
|
|
|
async deleteUserAddress({
|
|
|
commit
|
|
|
}) {
|
|
|
const result = await this.$api.post('/api/address/delAddress');
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit(Types.DELETE_USER_ADDRESS_INFO);
|
|
|
}
|
|
|
|
|
|
return result || {};
|
|
|
},
|
|
|
}; |
...
|
...
|
|