Files
xinlong-shop-taro/src_bak/api/shop/shopUserCard/index.ts
赵忠林 1fa58040f3 feat(user): 新增收货地址管理及售后申请页面
- 新增地址类型定义,增强前端地址数据结构
- 新增地址编辑页面,支持地址智能识别和定位选点功能
- 地址编辑支持省市区选择及默认地址设置
- 新增地址列表页面,支持地址展示、删除、编辑和选择功能
- 实现售后申请页面,支持选择售后类型和退款原因
- 售后申请支持商品选择、退款金额计算和凭证上传
- 新增售后详情页面,支持售后状态展示及申请取消
- 优化页面加载和用户交互体验,增加错误提示和权限处理
2026-07-01 12:11:56 +08:00

58 lines
1.5 KiB
TypeScript
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 request from '@/utils/request'
import type { ApiResult } from '@/api'
import type { UserCardStats, UserOrderStats } from './model'
/**
* 获取用户卡片统计(余额/积分/优惠券/礼品卡)
* 后端聚合接口:/api/user/card/stats60s 缓存)
* 余额数据来源:后端跨库读取 gxwebsoft_core.sys_user
*/
export async function getUserCardStats(): Promise<UserCardStats> {
try {
const res = await request.get<ApiResult<any>>('/user/card/stats')
if (res.code === 0 && res.data) {
const d = res.data
return {
balance: d.balance != null ? String(d.balance) : '0.00',
points: d.points || 0,
coupons: d.coupons || 0,
giftCards: d.giftCards || 0,
}
}
} catch (e) {
console.error('[CardStats] /user/card/stats 请求失败:', e)
}
return {
balance: '0.00',
points: 0,
coupons: 0,
giftCards: 0,
}
}
/**
* 获取用户订单统计
* 后端接口:/api/user/orders/stats60s 缓存)
*/
export async function getUserOrderStats(): Promise<UserOrderStats> {
try {
const res = await request.get<ApiResult<any>>('/user/orders/stats')
if (res.code === 0 && res.data) {
return {
pending: res.data.pending || 0,
paid: res.data.paid || 0,
shipped: res.data.shipped || 0,
completed: res.data.completed || 0,
}
}
} catch (e) {
console.error('获取订单统计失败:', e)
}
return {
pending: 0,
paid: 0,
shipped: 0,
completed: 0,
}
}