65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
/**
|
|
* 收藏模块 - 收藏列表、添加、取消相关接口
|
|
*/
|
|
import RequestManager from '../request';
|
|
|
|
/**
|
|
* 获取收藏列表
|
|
* @param {Number} page 页码
|
|
* @param {Number} pageSize 每页数量
|
|
* @returns {Promise} 收藏列表
|
|
*/
|
|
export const getCollectionList = async (page = 1, pageSize = 10) => {
|
|
return await RequestManager.get('/collect_list', {
|
|
page,
|
|
pageSize
|
|
}, true);
|
|
};
|
|
|
|
/**
|
|
* 添加收藏
|
|
* @param {Number} goodsId 商品ID
|
|
* @returns {Promise} 添加结果
|
|
*/
|
|
export const addCollection = async (goodsId) => {
|
|
return await RequestManager.post('/addCollect', {
|
|
goods_id: goodsId
|
|
});
|
|
};
|
|
|
|
/**
|
|
* 取消收藏
|
|
* @param {Number} goodsId 商品ID
|
|
* @returns {Promise} 取消结果
|
|
*/
|
|
export const cancelCollection = async (goodsId) => {
|
|
return await RequestManager.post('/cancelCollect', {
|
|
goods_id: goodsId
|
|
});
|
|
};
|
|
|
|
/**
|
|
* 切换收藏状态(添加/取消)
|
|
* @param {Number} goodsId 商品ID
|
|
* @param {Number} goodsNum 箱号(可选)
|
|
* @returns {Promise} 操作结果
|
|
*/
|
|
export const toggleCollection = async (goodsId, goodsNum = null) => {
|
|
const params = { goods_id: goodsId };
|
|
if (goodsNum !== null) {
|
|
params.goods_num = goodsNum;
|
|
}
|
|
return await RequestManager.post('/addCollect', params);
|
|
};
|
|
|
|
/**
|
|
* 获取收藏状态
|
|
* @param {Number} goodsId 商品ID
|
|
* @returns {Promise} 收藏状态
|
|
*/
|
|
export const getCollectionStatus = async (goodsId) => {
|
|
return await RequestManager.get('/collect_status', {
|
|
goods_id: goodsId
|
|
});
|
|
};
|