forked from gxwebsoft/mp-10550
fix(order): 修改订单确认页面的商品名称显示问题
- 将商品名称替换为固定文本“时里院子市集” - 确保配送类型和买家备注正确传递 - 优化注释说明,确保 couponId 类型正确处理
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
export const ENV_CONFIG = {
|
||||
// 开发环境
|
||||
development: {
|
||||
API_BASE_URL: 'https://cms-api.websoft.top/api',
|
||||
API_BASE_URL: 'http://127.0.0.1:9200/api',
|
||||
// API_BASE_URL: 'https://cms-api.websoft.top/api',
|
||||
APP_NAME: '开发环境',
|
||||
DEBUG: 'true',
|
||||
},
|
||||
|
||||
@@ -117,7 +117,7 @@ export const STATUS_COLOR_MAP = {
|
||||
// 申请售后
|
||||
export const applyAfterSale = async (params: AfterSaleApplyParams): Promise<AfterSaleDetailResponse> => {
|
||||
try {
|
||||
const response = await request({
|
||||
const response = await request<AfterSaleDetailResponse>({
|
||||
url: '/api/after-sale/apply',
|
||||
method: 'POST',
|
||||
data: params
|
||||
@@ -136,7 +136,7 @@ export const getAfterSaleDetail = async (params: {
|
||||
afterSaleId?: string
|
||||
}): Promise<AfterSaleDetailResponse> => {
|
||||
try {
|
||||
const response = await request({
|
||||
const response = await request<AfterSaleDetailResponse>({
|
||||
url: '/api/after-sale/detail',
|
||||
method: 'GET',
|
||||
data: params
|
||||
@@ -154,7 +154,7 @@ export const getAfterSaleDetail = async (params: {
|
||||
// 查询售后列表
|
||||
export const getAfterSaleList = async (params: AfterSaleListParams): Promise<AfterSaleListResponse> => {
|
||||
try {
|
||||
const response = await request({
|
||||
const response = await request<AfterSaleListResponse>({
|
||||
url: '/api/after-sale/list',
|
||||
method: 'GET',
|
||||
data: params
|
||||
@@ -170,7 +170,7 @@ export const getAfterSaleList = async (params: AfterSaleListParams): Promise<Aft
|
||||
// 撤销售后申请
|
||||
export const cancelAfterSale = async (afterSaleId: string): Promise<{ success: boolean; message?: string }> => {
|
||||
try {
|
||||
const response = await request({
|
||||
const response = await request<{ success: boolean; message?: string }>({
|
||||
url: '/api/after-sale/cancel',
|
||||
method: 'POST',
|
||||
data: { afterSaleId }
|
||||
@@ -312,11 +312,9 @@ export const getAfterSaleSteps = (type: AfterSaleType, status: AfterSaleStatus)
|
||||
|
||||
// 根据类型调整步骤
|
||||
if (type === 'return' || type === 'exchange') {
|
||||
baseSteps.splice(2, 1,
|
||||
{ title: '寄回商品', description: '请将商品寄回指定地址' },
|
||||
{ title: '处理中', description: '收到商品,正在处理' }
|
||||
)
|
||||
baseSteps.splice(2, 0, { title: '等待收货', description: '等待用户寄回商品' })
|
||||
baseSteps.splice(3, 0, { title: '确认收货', description: '商家确认收到退回商品' })
|
||||
}
|
||||
|
||||
return baseSteps
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,33 @@ const OrderDetail = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 申请退款
|
||||
const handleApplyRefund = async () => {
|
||||
if (order) {
|
||||
try {
|
||||
// 更新订单状态为"退款申请中"
|
||||
await updateShopOrder({
|
||||
orderId: order.orderId,
|
||||
orderStatus: 4 // 退款申请中
|
||||
});
|
||||
|
||||
// 更新本地状态
|
||||
setOrder(prev => prev ? {...prev, orderStatus: 4} : null);
|
||||
|
||||
// 跳转到退款申请页面
|
||||
Taro.navigateTo({
|
||||
url: `/user/order/refund/index?orderId=${order.orderId}&orderNo=${order.orderNo}`
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('更新订单状态失败:', error);
|
||||
Taro.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getOrderStatusText = (order: ShopOrder) => {
|
||||
// 优先检查订单状态
|
||||
if (order.orderStatus === 2) return '已取消';
|
||||
@@ -162,7 +189,7 @@ const OrderDetail = () => {
|
||||
<Space>
|
||||
{!order.payStatus && <Button onClick={() => console.log('取消订单')}>取消订单</Button>}
|
||||
{!order.payStatus && <Button type="primary" onClick={() => console.log('立即支付')}>立即支付</Button>}
|
||||
{order.orderStatus === 1 && <Button onClick={() => console.log('申请退款')}>申请退款</Button>}
|
||||
{order.orderStatus === 1 && <Button onClick={handleApplyRefund}>申请退款</Button>}
|
||||
{order.deliveryStatus === 20 &&
|
||||
<Button type="primary" onClick={() => console.log('确认收货')}>确认收货</Button>}
|
||||
</Space>
|
||||
|
||||
@@ -316,11 +316,30 @@ function OrderList(props: OrderListProps) {
|
||||
};
|
||||
|
||||
// 申请退款 (待发货状态)
|
||||
const applyRefund = (order: ShopOrder) => {
|
||||
// 跳转到退款申请页面
|
||||
Taro.navigateTo({
|
||||
url: `/user/order/refund/index?orderId=${order.orderId}&orderNo=${order.orderNo}`
|
||||
});
|
||||
const applyRefund = async (order: ShopOrder) => {
|
||||
try {
|
||||
// 更新订单状态为"退款申请中"
|
||||
await updateShopOrder({
|
||||
orderId: order.orderId,
|
||||
orderStatus: 4 // 退款申请中
|
||||
});
|
||||
|
||||
// 更新本地状态
|
||||
setDataSource(prev => prev.map(item =>
|
||||
item.orderId === order.orderId ? {...item, orderStatus: 4} : item
|
||||
));
|
||||
|
||||
// 跳转到退款申请页面
|
||||
Taro.navigateTo({
|
||||
url: `/user/order/refund/index?orderId=${order.orderId}&orderNo=${order.orderNo}`
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('更新订单状态失败:', error);
|
||||
Taro.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 查看物流 (待收货状态)
|
||||
@@ -738,12 +757,12 @@ function OrderList(props: OrderListProps) {
|
||||
)}
|
||||
|
||||
{/* 待发货状态:显示申请退款 */}
|
||||
{/*{item.payStatus && item.deliveryStatus === 10 && item.orderStatus !== 2 && item.orderStatus !== 4 && (*/}
|
||||
{/* <Button size={'small'} onClick={(e) => {*/}
|
||||
{/* e.stopPropagation();*/}
|
||||
{/* applyRefund(item);*/}
|
||||
{/* }}>申请退款</Button>*/}
|
||||
{/*)}*/}
|
||||
{item.payStatus && item.deliveryStatus === 10 && item.orderStatus !== 2 && item.orderStatus !== 4 && (
|
||||
<Button size={'small'} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
applyRefund(item);
|
||||
}}>申请退款</Button>
|
||||
)}
|
||||
|
||||
{/* 待收货状态:显示查看物流和确认收货 */}
|
||||
{item.deliveryStatus === 20 && item.orderStatus !== 2 && (
|
||||
@@ -770,10 +789,10 @@ function OrderList(props: OrderListProps) {
|
||||
{/* e.stopPropagation();*/}
|
||||
{/* evaluateGoods(item);*/}
|
||||
{/*}}>评价商品</Button>*/}
|
||||
{/*<Button size={'small'} onClick={(e) => {*/}
|
||||
{/* e.stopPropagation();*/}
|
||||
{/* applyRefund(item);*/}
|
||||
{/*}}>申请退款</Button>*/}
|
||||
<Button size={'small'} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
applyRefund(item);
|
||||
}}>申请退款</Button>
|
||||
</Space>
|
||||
)}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
Empty,
|
||||
InputNumber
|
||||
} from '@nutui/nutui-react-taro'
|
||||
import { applyAfterSale } from '@/api/afterSale'
|
||||
import { updateShopOrder } from '@/api/shop/shopOrder'
|
||||
import './index.scss'
|
||||
|
||||
// 订单商品信息
|
||||
@@ -232,23 +234,55 @@ const RefundPage: React.FC = () => {
|
||||
|
||||
setSubmitting(true)
|
||||
|
||||
// 模拟API调用
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
// 构造请求参数
|
||||
const params = {
|
||||
orderId: orderId || '',
|
||||
type: 'refund' as const,
|
||||
reason: refundApp.refundReason,
|
||||
description: refundApp.refundDescription,
|
||||
amount: refundApp.refundAmount,
|
||||
contactPhone: refundApp.contactPhone,
|
||||
evidenceImages: refundApp.evidenceImages,
|
||||
goodsItems: refundApp.refundGoods.filter(item => item.refundNum > 0).map(item => ({
|
||||
goodsId: item.goodsId,
|
||||
quantity: item.refundNum
|
||||
}))
|
||||
}
|
||||
|
||||
Taro.showToast({
|
||||
title: '退款申请提交成功',
|
||||
icon: 'success'
|
||||
})
|
||||
// 调用API提交退款申请
|
||||
const result = await applyAfterSale(params)
|
||||
|
||||
if (result.success) {
|
||||
// 更新订单状态为"退款申请中"
|
||||
if (orderId) {
|
||||
try {
|
||||
await updateShopOrder({
|
||||
orderId: parseInt(orderId),
|
||||
orderStatus: 4 // 退款申请中
|
||||
})
|
||||
} catch (updateError) {
|
||||
console.error('更新订单状态失败:', updateError)
|
||||
// 即使更新订单状态失败,也继续执行后续操作
|
||||
}
|
||||
}
|
||||
|
||||
// 延迟返回上一页
|
||||
setTimeout(() => {
|
||||
Taro.navigateBack()
|
||||
}, 1500)
|
||||
Taro.showToast({
|
||||
title: '退款申请提交成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 延迟返回上一页
|
||||
setTimeout(() => {
|
||||
Taro.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(result.message || '提交失败')
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('提交退款申请失败:', error)
|
||||
Taro.showToast({
|
||||
title: '提交失败,请重试',
|
||||
title: error instanceof Error ? error.message : '提交失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
@@ -420,4 +454,4 @@ const RefundPage: React.FC = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export default RefundPage
|
||||
export default RefundPage
|
||||
Reference in New Issue
Block a user