修复:用户资料及认证提交页面,需求定制页面

This commit is contained in:
2025-02-15 18:38:21 +08:00
parent ca3b5a296e
commit 9081e41188
29 changed files with 925 additions and 284 deletions

106
api/shop/shopCart/index.ts Normal file
View File

@@ -0,0 +1,106 @@
import request from '@/utils/request';
import type {ApiResult, PageResult} from '@/api';
import type {ShopCart, ShopCartParam} from './model';
import {SERVER_API_URL} from "~/config";
/**
* 分页查询购物车
*/
export async function pageShopCart(params: ShopCartParam) {
const res = await request.get<ApiResult<PageResult<ShopCart>>>(
SERVER_API_URL + '/shop/shop-cart/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询购物车列表
*/
export async function listShopCart(params?: ShopCartParam) {
const res = await request.get<ApiResult<ShopCart[]>>(
SERVER_API_URL + '/shop/shop-cart',
{
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 添加购物车
*/
export async function addShopCart(data: ShopCart) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改购物车
*/
export async function updateShopCart(data: ShopCart) {
const res = await request.put<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 删除购物车
*/
export async function removeShopCart(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 批量删除购物车
*/
export async function removeBatchShopCart(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
SERVER_API_URL + '/shop/shop-cart/batch',
{
data
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据id查询购物车
*/
export async function getShopCart(id: number) {
const res = await request.get<ApiResult<ShopCart>>(
SERVER_API_URL + '/shop/shop-cart/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}