init
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/** 接口统一响应结构 */
|
||||
export interface ApiResponse<T = unknown> {
|
||||
success: boolean
|
||||
data: T
|
||||
msg?: string
|
||||
/** 提示类型(预留) */
|
||||
showType?: number
|
||||
}
|
||||
|
||||
/** 分页数据统一结构(位于响应 data 字段内) */
|
||||
export interface PaginatedData<T> {
|
||||
data: T[]
|
||||
total: number
|
||||
pageSize: number
|
||||
current: number
|
||||
}
|
||||
|
||||
/** 请求配置:在 Taro.request 参数基础上扩展 */
|
||||
export interface RequestConfig {
|
||||
url: string
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'TRACE' | 'CONNECT'
|
||||
data?: any
|
||||
header?: Record<string, string>
|
||||
timeout?: number
|
||||
/** 跳过自动附加 token(如登录接口) */
|
||||
skipToken?: boolean
|
||||
/** 跳过自动错误提示(业务失败时不弹 toast,由调用方处理) */
|
||||
skipErrorToast?: boolean
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/** 购物车项 */
|
||||
export interface CartItem {
|
||||
id: number
|
||||
product_id: number
|
||||
/** 商品快照 */
|
||||
name: string
|
||||
spec: string
|
||||
unit: string
|
||||
/** 商品首图 URL */
|
||||
image: string
|
||||
/** 当前等级实际价(商品下架或未设等级价为 null) */
|
||||
price: string | null
|
||||
quantity: string
|
||||
/** 金额 = price × quantity(不可购为 null) */
|
||||
amount: string | null
|
||||
/** 1 可购 / 0 商品下架、缺失或未设等级价 */
|
||||
status: number
|
||||
}
|
||||
|
||||
/** 购物车列表数据 */
|
||||
export interface CartData {
|
||||
items: CartItem[]
|
||||
/** 总项数 */
|
||||
total_count: number
|
||||
/** 可购项总数量 */
|
||||
total_quantity: string
|
||||
/** 可购项总金额 */
|
||||
total_amount: string
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/** 通知类型:order 订单 / price 价格变更 / system 系统 */
|
||||
export type NoticeType = 'order' | 'price' | 'system'
|
||||
|
||||
export const NOTICE_TYPE_MAP: Record<NoticeType, string> = {
|
||||
order: '订单',
|
||||
price: '价格变更',
|
||||
system: '系统',
|
||||
}
|
||||
|
||||
/** 通知 */
|
||||
export interface Notice {
|
||||
id: number
|
||||
type: NoticeType
|
||||
title: string
|
||||
content: string
|
||||
/** 附加数据(价格变更通知含 product_ids、level_ids) */
|
||||
data?: Record<string, unknown>
|
||||
/** 0 未读 / 1 已读 */
|
||||
is_read: 0 | 1
|
||||
read_at: string | null
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
/** 通知列表(分页结构 + 未读总数) */
|
||||
export interface NoticeData {
|
||||
unread_count: number
|
||||
data: Notice[]
|
||||
total: number
|
||||
pageSize: number
|
||||
current: number
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/** 门店订单状态:0 待汇总 / 1 已汇总 / 2 配送中 / 3 已完成 / 9 已取消 */
|
||||
export type OrderStatus = 0 | 1 | 2 | 3 | 9
|
||||
|
||||
export const ORDER_STATUS_MAP: Record<OrderStatus, string> = {
|
||||
0: '待汇总',
|
||||
1: '已汇总',
|
||||
2: '配送中',
|
||||
3: '已完成',
|
||||
9: '已取消',
|
||||
}
|
||||
|
||||
/** 状态筛选(value 为 null 表示全部) */
|
||||
export const ORDER_STATUS_FILTERS: Array<{ value: OrderStatus | null; label: string }> = [
|
||||
{ value: null, label: '全部' },
|
||||
{ value: 0, label: '待汇总' },
|
||||
{ value: 1, label: '已汇总' },
|
||||
{ value: 2, label: '配送中' },
|
||||
{ value: 3, label: '已完成' },
|
||||
{ value: 9, label: '已取消' },
|
||||
]
|
||||
|
||||
/** 门店订单 */
|
||||
export interface Order {
|
||||
id: number
|
||||
order_no: string
|
||||
/** 订货日期(Y-m-d) */
|
||||
order_date: string
|
||||
total_quantity: string
|
||||
total_amount: string
|
||||
status: OrderStatus
|
||||
remark: string
|
||||
/** 详情接口返回 */
|
||||
items?: OrderItem[]
|
||||
}
|
||||
|
||||
/** 订单明细 */
|
||||
export interface OrderItem {
|
||||
id: number
|
||||
order_id: number
|
||||
product_id: number
|
||||
product_name: string
|
||||
product_spec: string
|
||||
/** 下单时等级实际价快照 */
|
||||
price: string
|
||||
quantity: string
|
||||
/** 称重(默认 0) */
|
||||
weight: string
|
||||
amount: string
|
||||
remark: string
|
||||
}
|
||||
|
||||
/** 下单返回 */
|
||||
export interface OrderCreateResult {
|
||||
id: number
|
||||
order_no: string
|
||||
total_amount: string
|
||||
}
|
||||
|
||||
/** 周期汇总分组 */
|
||||
export interface SummaryGroup {
|
||||
period_label: string
|
||||
total_amount: string
|
||||
total_quantity: string
|
||||
order_count: number
|
||||
}
|
||||
|
||||
/** 周期汇总 */
|
||||
export interface OrderSummary {
|
||||
period: 'day' | 'week' | 'month'
|
||||
groups: SummaryGroup[]
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/** 商品分类节点(children 递归) */
|
||||
export interface Category {
|
||||
id: number
|
||||
parent_id: number
|
||||
name: string
|
||||
children: Category[]
|
||||
}
|
||||
|
||||
/** 商品图片 */
|
||||
export interface ProductImage {
|
||||
id: number
|
||||
file_url: string
|
||||
}
|
||||
|
||||
/** 商品 */
|
||||
export interface Product {
|
||||
id: number
|
||||
category_id: number
|
||||
supplier_id: number
|
||||
name: string
|
||||
spec: string
|
||||
unit: string
|
||||
/** 商品图文详情(HTML) */
|
||||
content: string
|
||||
/** 当前门店等级的实际销售价(未设等级价为 null) */
|
||||
price: string | null
|
||||
images_arr: ProductImage[]
|
||||
/** 排序 / 保质期 / 库存 / 状态(仅返回上架商品) */
|
||||
sort?: number
|
||||
shelf_life?: string | null
|
||||
stock?: number | null
|
||||
status?: number
|
||||
}
|
||||
|
||||
/** 商品首图地址 */
|
||||
export function getProductCover(product: Product): string {
|
||||
const first = product.images_arr?.[0]
|
||||
if (!first || !first.file_url) return ''
|
||||
if (/^https?:\/\//i.test(first.file_url)) return first.file_url
|
||||
return first.file_url
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/** 对账单状态:0 待对账 / 1 已对账 / 2 已结算 */
|
||||
export type StatementStatus = 0 | 1 | 2
|
||||
|
||||
export const STATEMENT_STATUS_MAP: Record<StatementStatus, string> = {
|
||||
0: '待对账',
|
||||
1: '已对账',
|
||||
2: '已结算',
|
||||
}
|
||||
|
||||
/** 对账单 */
|
||||
export interface Statement {
|
||||
id: number
|
||||
statement_no: string
|
||||
period_start: string
|
||||
period_end: string
|
||||
total_amount: string
|
||||
/** 生成时快照的回款周期 */
|
||||
payment_cycle_days: number
|
||||
/** 应结算日期 = 周期结束 + 回款周期天 */
|
||||
settlement_date: string | null
|
||||
status: StatementStatus
|
||||
reconciled_at: string | null
|
||||
settled_at: string | null
|
||||
remark: string
|
||||
}
|
||||
|
||||
/** 对账单明细行 */
|
||||
export interface StatementItem {
|
||||
order_id: number
|
||||
order_item_id: number
|
||||
product_id: number
|
||||
product_name: string
|
||||
price: string
|
||||
quantity: string
|
||||
weight: string
|
||||
amount: string
|
||||
/** 0 未对账 / 1 已对账 */
|
||||
is_reconciled: number
|
||||
store_remark: string
|
||||
}
|
||||
|
||||
/** 对账单详情 */
|
||||
export interface StatementDetail extends Statement {
|
||||
items: StatementItem[]
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/** 客户等级 */
|
||||
export interface StoreLevel {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
/** 门店信息 */
|
||||
export interface StoreInfo {
|
||||
id: number
|
||||
name: string
|
||||
/** 客户等级(level_id > 0 才可展示价格) */
|
||||
level: StoreLevel | null
|
||||
}
|
||||
|
||||
/** 供应商信息 */
|
||||
export interface SupplierInfo {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
/** 用户类型:0 待绑定 / 1 门店 / 2 供应商 */
|
||||
export type UserType = 0 | 1 | 2
|
||||
|
||||
export const USER_TYPE_MAP: Record<UserType, string> = {
|
||||
0: '待绑定',
|
||||
1: '门店',
|
||||
2: '供应商',
|
||||
}
|
||||
|
||||
/** 用户信息 */
|
||||
export interface User {
|
||||
id: number
|
||||
nickname: string
|
||||
avatar: string
|
||||
phone: string
|
||||
type: UserType
|
||||
store: StoreInfo | null
|
||||
supplier: SupplierInfo | null
|
||||
}
|
||||
Reference in New Issue
Block a user