73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
import {
|
|
request
|
|
} from '../_utils/request';
|
|
|
|
/** 获取经营类目列表 */
|
|
export function fetchGoodsList(params) {
|
|
return new Promise((resolve, reject) => {
|
|
|
|
request({
|
|
url: `GoodsApi/getGoodsList`,
|
|
data: params,
|
|
method: 'GET',
|
|
success: function (res) {
|
|
let list = res.data;
|
|
if (list.result.length) {
|
|
list.result.forEach((item) => {
|
|
// 图片
|
|
if (item.images) {
|
|
item.thumb = item.images.split(',')[0];
|
|
}
|
|
|
|
// 标签
|
|
// if (item.spuTagList) {
|
|
// item.tags = item.spuTagList.map((tag) => tag.title);
|
|
// } else {
|
|
// item.tags = [];
|
|
// }
|
|
});
|
|
}
|
|
resolve(list);
|
|
},
|
|
fail: function (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
/** 获取商品列表 */
|
|
// function mockFetchGoodsList(params) {
|
|
// const { delay } = require('../_utils/delay');
|
|
// // const { getSearchResult } = require('../../model/search');
|
|
// // const data = getSearchResult(params);
|
|
|
|
// if (data.spuList.length) {
|
|
// data.spuList.forEach((item) => {
|
|
// item.spuId = item.spuId;
|
|
// item.thumb = item.primaryImage;
|
|
// item.title = item.title;
|
|
// item.price = item.minSalePrice;
|
|
// item.originPrice = item.maxLinePrice;
|
|
// item.desc = '';
|
|
// if (item.spuTagList) {
|
|
// item.tags = item.spuTagList.map((tag) => tag.title);
|
|
// } else {
|
|
// item.tags = [];
|
|
// }
|
|
// });
|
|
// }
|
|
// return delay().then(() => {
|
|
// return data;
|
|
// });
|
|
// }
|
|
|
|
// /** 获取商品列表 */
|
|
// export function fetchGoodsList(params) {
|
|
// if (config.useMock) {
|
|
// return mockFetchGoodsList(params);
|
|
// }
|
|
// return new Promise((resolve) => {
|
|
// resolve('real api');
|
|
// });
|
|
// }
|