51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import {get, post} from '../request';
|
||
|
||
const prefix = 'list/'
|
||
|
||
/**
|
||
* 我的清单列表
|
||
* - 不传参数:返回全量数组(老调用方兼容)
|
||
* - 传 { page, pageSize }:后端返回 { items, total, page, pageSize, has_more }
|
||
* @param {{page?: number, pageSize?: number}} params
|
||
*/
|
||
export const getCartListApi = async (params) => {
|
||
return await get(`${prefix}list`, params)
|
||
}
|
||
export const getCartItemApi = async (id) => {
|
||
return await get(`${prefix}detail`, {id})
|
||
}
|
||
export const createCartApi = async (params) => {
|
||
return await post(`${prefix}create`, params)
|
||
}
|
||
export const deleteCartApi = async (id) => {
|
||
return await post(`${prefix}delete`, {
|
||
ids: [id]
|
||
})
|
||
}
|
||
export const deleteCartItemApi = async (id) => {
|
||
return await post(`${prefix}delete-item`, {
|
||
ids: [id]
|
||
})
|
||
}
|
||
export const toCartApi = async (listId, productId, extra = {}) => {
|
||
return await post(`${prefix}to-cart`, {
|
||
list_id: listId,
|
||
product_id: productId,
|
||
...extra
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 改清单明细的规格 / 数量 / 备注。
|
||
* 对齐后端 wx/list/update-item(WxListService::updateItem),
|
||
* 只传需要改的字段即可,后端按 array_key_exists 判断。
|
||
* @param {number} id 明细 id(list_item.id,不是清单 id)
|
||
* @param {{price_sheet_id?: number, quantity?: number, material_key?: string, remark?: string}} params
|
||
*/
|
||
export const updateItemApi = async (id, params = {}) => {
|
||
return await post(`${prefix}update-item`, {
|
||
id,
|
||
...params
|
||
})
|
||
}
|