Files
lgp-wx-plus/api/page/cart.js
年糕崽崽 516f077568 初始化
缺陷:主题配色需要优化整体的同风格
2026-08-14 23:17:19 +08:00

51 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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-itemWxListService::updateItem
* 只传需要改的字段即可,后端按 array_key_exists 判断。
* @param {number} id 明细 idlist_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
})
}