116 lines
2.1 KiB
JavaScript
116 lines
2.1 KiB
JavaScript
/**
|
|
* 收货地址相关API
|
|
*/
|
|
|
|
import { http, Method } from "@/utils/request.js";
|
|
|
|
import api from "@/config/api.js";
|
|
|
|
/**
|
|
* 获取收货地址列表
|
|
* @returns {AxiosPromise}
|
|
*/
|
|
export function getAddressList(pageNumber, pageSize) {
|
|
return http.request({
|
|
url: "/memberAddress",
|
|
method: Method.GET,
|
|
needToken: true,
|
|
params: { pageNumber, pageSize },
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取物流公司
|
|
*/
|
|
export function getLogistics() {
|
|
return http.request({
|
|
url: "/logistics",
|
|
method: Method.GET,
|
|
needToken: true,
|
|
params: { pageNumber: 1, pageSize: 200, disabled: "OPEN" },
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 通过cityCode获取地区代码
|
|
*/
|
|
export function getAddressCode(cityCode, townName) {
|
|
return http.request({
|
|
url: api.common + "/region/region",
|
|
method: Method.GET,
|
|
needToken: true,
|
|
params: { cityCode, townName },
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 添加收货地址
|
|
* @param params 地址参数
|
|
* @returns {AxiosPromise}
|
|
*/
|
|
export function addAddress(data) {
|
|
return http.request({
|
|
url: "/memberAddress",
|
|
method: Method.POST,
|
|
needToken: true,
|
|
header: { "content-type": "application/x-www-form-urlencoded" },
|
|
data: data,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 编辑地址
|
|
* @param id 地址ID
|
|
* @param params 地址参数
|
|
* @returns {AxiosPromise}
|
|
*/
|
|
export function editAddress(params) {
|
|
return http.request({
|
|
url: `/memberAddress`,
|
|
method: Method.PUT,
|
|
needToken: true,
|
|
header: { "content-type": "application/x-www-form-urlencoded" },
|
|
data: params,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 删除收货地址
|
|
* @param id
|
|
*/
|
|
export function deleteAddress(id) {
|
|
return http.request({
|
|
url: `/memberAddress/delById/${id}`,
|
|
method: Method.DELETE,
|
|
needToken: true,
|
|
});
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 根据ID获取会员收件地址
|
|
* @param id
|
|
*/
|
|
export function getAddressDetail(id) {
|
|
return http.request({
|
|
url: `/memberAddress/get/${id}`,
|
|
method: Method.GET,
|
|
loading: false,
|
|
needToken: true,
|
|
});
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
export function getAddressDefault() {
|
|
return http.request({
|
|
url: `/memberAddress/get/default`,
|
|
method: Method.GET,
|
|
loading: false,
|
|
needToken: true,
|
|
});
|
|
}
|