完成商城下单功能

This commit is contained in:
gxwebsoft
2024-05-27 01:24:02 +08:00
parent dea6ae1c23
commit 4bae8599e1
26 changed files with 803 additions and 129 deletions

View File

@@ -53,6 +53,7 @@ export interface PeriodParam extends PageParam {
dateTime?: string;
isStatus?: number;
timePeriod?: string;
merchantId?: number;
week?: number;
startTime?: string;
half?: number;

View File

@@ -12,8 +12,8 @@ export interface Goods {
type?: number;
// 商品编码
code?: string;
// 商品标题
title?: string;
// 商品名称
goodsName?: string;
// 商品封面图
image?: string;
// 商品详情

View File

@@ -63,5 +63,6 @@ export interface OrderInfo {
*/
export interface OrderInfoParam extends PageParam {
id?: number;
orderId?: number;
keywords?: string;
}

View File

@@ -0,0 +1,106 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { UserAddress, UserAddressParam } from './model';
import { MODULES_API_URL } from '@/config/setting';
/**
* 分页查询收货地址
*/
export async function pageUserAddress(params: UserAddressParam) {
const res = await request.get<ApiResult<PageResult<UserAddress>>>(
MODULES_API_URL + '/shop/user-address/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询收货地址列表
*/
export async function listUserAddress(params?: UserAddressParam) {
const res = await request.get<ApiResult<UserAddress[]>>(
MODULES_API_URL + '/shop/user-address',
{
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 添加收货地址
*/
export async function addUserAddress(data: UserAddress) {
const res = await request.post<ApiResult<unknown>>(
MODULES_API_URL + '/shop/user-address',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改收货地址
*/
export async function updateUserAddress(data: UserAddress) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/shop/user-address',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 删除收货地址
*/
export async function removeUserAddress(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/shop/user-address/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 批量删除收货地址
*/
export async function removeBatchUserAddress(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
MODULES_API_URL + '/shop/user-address/batch',
{
data
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据id查询收货地址
*/
export async function getUserAddress(id: number) {
const res = await request.get<ApiResult<UserAddress>>(
MODULES_API_URL + '/shop/user-address/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,43 @@
import type { PageParam } from '@/api';
/**
* 收货地址
*/
export interface UserAddress {
// 主键ID
id?: number;
// 姓名
name?: string;
// 手机号码
phone?: string;
// 所在国家
country?: string;
// 所在省份
province?: string;
// 所在城市
city?: string;
// 所在辖区
region?: string;
// 收货地址
address?: string;
// 1先生 2女士
gender?: number;
// 家、公司、学校
type?: string;
// 默认收货地址
default?: string;
// 用户ID
userId?: number;
// 租户id
tenantId?: number;
// 注册时间
createTime?: string;
}
/**
* 收货地址搜索条件
*/
export interface UserAddressParam extends PageParam {
id?: number;
keywords?: string;
}