feat(user): 新增收货地址管理及售后申请页面
- 新增地址类型定义,增强前端地址数据结构 - 新增地址编辑页面,支持地址智能识别和定位选点功能 - 地址编辑支持省市区选择及默认地址设置 - 新增地址列表页面,支持地址展示、删除、编辑和选择功能 - 实现售后申请页面,支持选择售后类型和退款原因 - 售后申请支持商品选择、退款金额计算和凭证上传 - 新增售后详情页面,支持售后状态展示及申请取消 - 优化页面加载和用户交互体验,增加错误提示和权限处理
This commit is contained in:
119
src_bak/api/shop/shopEvaluation/index.ts
Normal file
119
src_bak/api/shop/shopEvaluation/index.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import request from '@/utils/request'
|
||||
import type { ApiResult, PageResult } from '@/api'
|
||||
import type {
|
||||
ShopEvaluation,
|
||||
ShopEvaluationParam,
|
||||
CreateEvaluationParams,
|
||||
LikeEvaluationParams,
|
||||
EvaluationStats,
|
||||
} from './model'
|
||||
|
||||
/**
|
||||
* 分页查询评价
|
||||
*/
|
||||
export async function pageShopEvaluation(params: ShopEvaluationParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopEvaluation>>>(
|
||||
'/shop/shop-evaluation/page',
|
||||
params
|
||||
)
|
||||
if (res.code === 0) {
|
||||
return res.data
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询评价列表
|
||||
*/
|
||||
export async function listShopEvaluation(params?: ShopEvaluationParam) {
|
||||
const res = await request.get<ApiResult<ShopEvaluation[]>>(
|
||||
'/shop/shop-evaluation',
|
||||
params
|
||||
)
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询评价
|
||||
*/
|
||||
export async function getShopEvaluation(id: number) {
|
||||
const res = await request.get<ApiResult<ShopEvaluation>>(
|
||||
'/shop/shop-evaluation/' + id
|
||||
)
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建评价
|
||||
*/
|
||||
export async function createShopEvaluation(data: CreateEvaluationParams) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-evaluation',
|
||||
data
|
||||
)
|
||||
if (res.code === 0) {
|
||||
return res.message
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评价
|
||||
*/
|
||||
export async function removeShopEvaluation(id?: number) {
|
||||
const res = await request.del<ApiResult<unknown>>(
|
||||
'/shop/shop-evaluation/' + id
|
||||
)
|
||||
if (res.code === 0) {
|
||||
return res.message
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞/取消点赞评价
|
||||
*/
|
||||
export async function likeShopEvaluation(params: LikeEvaluationParams) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/shop/shop-evaluation/like',
|
||||
params
|
||||
)
|
||||
if (res.code === 0) {
|
||||
return res.message
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品评价统计
|
||||
*/
|
||||
export async function getEvaluationStats(goodsId: number) {
|
||||
const res = await request.get<ApiResult<EvaluationStats>>(
|
||||
'/shop/shop-evaluation/stats',
|
||||
{ goodsId }
|
||||
)
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单的评价信息(用于判断是否已评价)
|
||||
*/
|
||||
export async function getOrderEvaluationStatus(orderId: number) {
|
||||
const res = await request.get<ApiResult<{ evaluated: boolean; evaluationId?: number }>>(
|
||||
'/shop/shop-evaluation/order-status',
|
||||
{ orderId }
|
||||
)
|
||||
if (res.code === 0 && res.data) {
|
||||
return res.data
|
||||
}
|
||||
return Promise.reject(new Error(res.message))
|
||||
}
|
||||
77
src_bak/api/shop/shopEvaluation/model/index.ts
Normal file
77
src_bak/api/shop/shopEvaluation/model/index.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 商品评价模型
|
||||
*/
|
||||
|
||||
// 评价维度
|
||||
export interface EvaluationDimension {
|
||||
name: string // 维度名称(如:质量、服务、物流)
|
||||
score: number // 维度评分(1-5)
|
||||
}
|
||||
|
||||
// 评价数据
|
||||
export interface ShopEvaluation {
|
||||
id: number
|
||||
goodsId: number // 商品ID
|
||||
goodsName: string // 商品名称
|
||||
goodsImage: string // 商品图片
|
||||
orderId: number // 订单ID
|
||||
userId: number // 用户ID
|
||||
userName: string // 用户名(脱敏)
|
||||
userAvatar?: string // 用户头像
|
||||
score: number // 总评分(1-5)
|
||||
dimensions?: EvaluationDimension[] // 评价维度
|
||||
content: string // 评价内容
|
||||
images: string[] // 评价图片
|
||||
isAnonymous: boolean // 是否匿名
|
||||
likes: number // 点赞数
|
||||
isLiked: boolean // 当前用户是否点赞
|
||||
reply?: string // 商家回复
|
||||
replyTime?: string // 回复时间
|
||||
createTime: string // 评价时间
|
||||
updateTime?: string // 更新时间
|
||||
}
|
||||
|
||||
// 评价查询参数
|
||||
export interface ShopEvaluationParam {
|
||||
page?: number
|
||||
limit?: number
|
||||
goodsId?: number // 按商品查询
|
||||
userId?: number // 按用户查询
|
||||
orderId?: number // 按订单查询
|
||||
minScore?: number // 最低评分
|
||||
maxScore?: number // 最高评分
|
||||
hasImages?: boolean // 是否有图
|
||||
isLiked?: boolean // 是否点赞过
|
||||
sortBy?: string // 排序方式(newest, mostLiked)
|
||||
keywords?: string // 关键词搜索
|
||||
}
|
||||
|
||||
// 创建评价参数
|
||||
export interface CreateEvaluationParams {
|
||||
orderId: number
|
||||
goodsId: number
|
||||
score: number
|
||||
dimensions?: EvaluationDimension[]
|
||||
content: string
|
||||
images?: string[]
|
||||
isAnonymous: boolean
|
||||
}
|
||||
|
||||
// 点赞/取消点赞参数
|
||||
export interface LikeEvaluationParams {
|
||||
evaluationId: number
|
||||
isLiked: boolean
|
||||
}
|
||||
|
||||
// 评价统计
|
||||
export interface EvaluationStats {
|
||||
total: number // 总评价数
|
||||
averageScore: number // 平均评分
|
||||
scoreDistribution: { // 评分分布
|
||||
[key: number]: number
|
||||
}
|
||||
imageCount: number // 有图评价数
|
||||
positiveCount: number // 好评数(4-5星)
|
||||
neutralCount: number // 中评数(3星)
|
||||
negativeCount: number // 差评数(1-2星)
|
||||
}
|
||||
Reference in New Issue
Block a user