144 lines
3.0 KiB
JavaScript
144 lines
3.0 KiB
JavaScript
import request from '@/common/system/request';
|
|
|
|
/**
|
|
* 获取所有分类
|
|
* @returns
|
|
*/
|
|
export const getAllCategories = async () => {
|
|
const res = await request.get("Good/GetAllCategories");
|
|
console.log(res, "aaaaaaaaaaa");
|
|
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取商品评价列表分页数据
|
|
* @returns {}
|
|
*/
|
|
export const getGoodsComment = async (otherData, id, page, limit, order, where) => {
|
|
const res = await request.post("Good/GetGoodsComment", {
|
|
"otherData": otherData,
|
|
"id": id,
|
|
"page": page,
|
|
"limit": limit,
|
|
"order": order,
|
|
"where": where
|
|
});
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 获取商品详情
|
|
* @param {number} id 商品ID
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getDetial = async (id) => {
|
|
const res = await request.get("Good/GetDetial", { params: { id } });
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 根据Token获取商品详情
|
|
* @param {number} id 商品ID
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getDetialByToken = async (id) => {
|
|
const res = await request.post("Good/GetDetialByToken", { id });
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 根据查询条件获取分页数据
|
|
* @param {number} page 页码
|
|
* @param {number} limit 每页数量
|
|
* @param {string} order 排序
|
|
* @param {string} where 条件
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getGoodsPageList = async (page, limit, order, where) => {
|
|
const res = await request.get("Good/GetGoodsPageList", {
|
|
params: {
|
|
page,
|
|
limit,
|
|
order,
|
|
where
|
|
}
|
|
});
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 获取单个商品参数
|
|
* @param {number} id 商品ID
|
|
* @param {Object} data 附加数据
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getGoodsParams = async (id, data = {}) => {
|
|
const res = await request.get("Good/GetGoodsParams", {
|
|
params: {
|
|
id,
|
|
data
|
|
}
|
|
});
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 获取随机推荐商品
|
|
* @param {number} id 商品ID
|
|
* @param {Object} data 附加数据
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getGoodsRecommendList = async (id, data = {}) => {
|
|
const res = await request.get("Good/GetGoodsRecommendList", {
|
|
params: {
|
|
id,
|
|
data
|
|
}
|
|
});
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 获取单个货品信息
|
|
* @param {number} id 货品ID
|
|
* @param {string} type 类型
|
|
* @param {number} groupId 分组ID
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export const getProductInfo = async (id, type, groupId) => {
|
|
const res = await request.get("Good/GetProductInfo", {
|
|
params: {
|
|
id,
|
|
type,
|
|
groupId
|
|
}
|
|
});
|
|
if (res.code == 0) {
|
|
return res.data;
|
|
}
|
|
return null;
|
|
}
|