Files
2026-07-15 18:29:16 +08:00

77 lines
1.5 KiB
JavaScript

import request from '@/sheep/request';
function normalizeList(data) {
if (Array.isArray(data)) {
return data;
}
if (Array.isArray(data?.list)) {
return data.list;
}
if (Array.isArray(data?.records)) {
return data.records;
}
return [];
}
const StoreApi = {
getStoreListByLocation: async (params) => {
const res = await request({
url: '/trade/store/list-by-location',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
});
if (res?.code === 0) {
res.data = normalizeList(res.data);
}
return res;
},
getStoreListByStoreIds: async (storeIds, params = {}) => {
const res = await request({
url: '/trade/store/list-by-store-ids',
method: 'GET',
params: {
storeIds,
...params,
},
custom: {
showLoading: false,
},
});
if (res?.code === 0) {
res.data = normalizeList(res.data);
}
return res;
},
getStoreById: (storeId) => {
return request({
url: '/trade/store/getStoreById',
method: 'GET',
params: {
storeId,
},
custom: {
showLoading: false,
},
});
},
updateStatus: (storeId, status) => {
return request({
url: '/trade/store/update-status',
method: 'PUT',
params: {
storeId,
status,
},
custom: {
showLoading: false,
},
});
},
};
export default StoreApi;