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

45 lines
1.6 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 { ShopGoodsFavorite, ShopGoodsFavoriteParam } from './model'
/**
* 解包 API 响应
* request 工具默认 returnRaw=true返回完整 {code, message, data} 包装
* 此函数提取内层 data 字段,兼容 data 为 null/undefined 的情况
*/
function unwrap<T>(res: any): T {
if (res && typeof res === 'object' && 'data' in res) {
return res.data as T
}
return res as T
}
// 添加收藏
export async function addShopGoodsFavorite(data: { goodsId: number }) {
const res = await request.post('/shop/goods/favorite/add', data)
return unwrap<boolean>(res)
}
// 取消收藏
export async function removeShopGoodsFavorite(data: { goodsId: number }) {
const res = await request.post('/shop/goods/favorite/remove', data)
return unwrap<boolean>(res)
}
// 查询收藏状态(返回 booleantrue=已收藏, false=未收藏)
export async function getShopGoodsFavoriteStatus(params: { goodsId: number }) {
const res = await request.get('/shop/goods/favorite/status', params)
return !!unwrap<boolean>(res) // 确保返回纯布尔值
}
// 收藏列表
export async function listShopGoodsFavorite(params: ShopGoodsFavoriteParam) {
const res = await request.get('/shop/goods/favorite/list', params)
return unwrap<ShopGoodsFavorite[]>(res) || []
}
// 收藏列表(分页)
export async function pageShopGoodsFavorite(params: ShopGoodsFavoriteParam) {
const res = await request.get('/shop/goods/favorite/page', params)
return unwrap<{ list: ShopGoodsFavorite[]; total: number }>(res) || { list: [], total: 0 }
}