|
|
|
|
@ -1,10 +1,10 @@
@@ -1,10 +1,10 @@
|
|
|
|
|
/** |
|
|
|
|
* 订单详情页(商品消费详情) |
|
|
|
|
*/ |
|
|
|
|
import { View, Text, Button } from '@tarojs/components' |
|
|
|
|
import { View, Text, Button, Textarea } from '@tarojs/components' |
|
|
|
|
import { useState } from 'react' |
|
|
|
|
import Taro, { useLoad } from '@tarojs/taro' |
|
|
|
|
import { Image } from '@taroify/core' |
|
|
|
|
import { Image, Popup } from '@taroify/core' |
|
|
|
|
import './index.scss' |
|
|
|
|
|
|
|
|
|
// 商品信息接口
|
|
|
|
|
@ -35,6 +35,9 @@ interface OrderDetail {
@@ -35,6 +35,9 @@ interface OrderDetail {
|
|
|
|
|
|
|
|
|
|
const OrderDetail = () => { |
|
|
|
|
const [pageType, setPageType] = useState<'unpaid' | 'paid'>('unpaid') |
|
|
|
|
const [refundPopupOpen, setRefundPopupOpen] = useState(false) |
|
|
|
|
const [currentRefundGoods, setCurrentRefundGoods] = useState<GoodsItem | null>(null) |
|
|
|
|
const [refundReason, setRefundReason] = useState('') |
|
|
|
|
|
|
|
|
|
// 模拟订单详情数据
|
|
|
|
|
const [orderDetail] = useState<OrderDetail>({ |
|
|
|
|
@ -81,10 +84,44 @@ const OrderDetail = () => {
@@ -81,10 +84,44 @@ const OrderDetail = () => {
|
|
|
|
|
// 申请退款
|
|
|
|
|
const handleRefund = (goodsId: string) => { |
|
|
|
|
console.log('申请退款', goodsId) |
|
|
|
|
// 查找商品
|
|
|
|
|
const goods = orderDetail.goods.find(item => item.id === goodsId) |
|
|
|
|
if (goods) { |
|
|
|
|
setCurrentRefundGoods(goods) |
|
|
|
|
setRefundReason('') |
|
|
|
|
setRefundPopupOpen(true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 提交退款申请
|
|
|
|
|
const handleSubmitRefund = () => { |
|
|
|
|
if (!refundReason.trim()) { |
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '请输入退款原因', |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('提交退款申请', { |
|
|
|
|
goodsId: currentRefundGoods?.id, |
|
|
|
|
reason: refundReason |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
Taro.showToast({ |
|
|
|
|
title: '申请退款', |
|
|
|
|
icon: 'none' |
|
|
|
|
title: '退款申请已提交', |
|
|
|
|
icon: 'success' |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
setRefundPopupOpen(false) |
|
|
|
|
setRefundReason('') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 取消退款
|
|
|
|
|
const handleCancelRefund = () => { |
|
|
|
|
setRefundPopupOpen(false) |
|
|
|
|
setRefundReason('') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 立即支付
|
|
|
|
|
@ -192,6 +229,54 @@ const OrderDetail = () => {
@@ -192,6 +229,54 @@ const OrderDetail = () => {
|
|
|
|
|
</Button> |
|
|
|
|
</View> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
{/* 退款申请弹窗 */} |
|
|
|
|
<Popup |
|
|
|
|
open={refundPopupOpen} |
|
|
|
|
placement="bottom" |
|
|
|
|
rounded |
|
|
|
|
onClose={handleCancelRefund} |
|
|
|
|
> |
|
|
|
|
<View className="refund_popup"> |
|
|
|
|
{/* 标题栏 */} |
|
|
|
|
<View className="popup_header"> |
|
|
|
|
<Text className="cancel_btn" onClick={handleCancelRefund}>取消</Text> |
|
|
|
|
<Text className="popup_title">申请退款</Text> |
|
|
|
|
<Text className="submit_btn" onClick={handleSubmitRefund}>提交</Text> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
{/* 商品信息 */} |
|
|
|
|
{currentRefundGoods && ( |
|
|
|
|
<View className="popup_goods_info"> |
|
|
|
|
<Image |
|
|
|
|
className="popup_goods_image" |
|
|
|
|
src={currentRefundGoods.image} |
|
|
|
|
mode="aspectFill" |
|
|
|
|
width={160} |
|
|
|
|
height={160} |
|
|
|
|
/> |
|
|
|
|
<View className="popup_goods_detail"> |
|
|
|
|
<Text className="popup_goods_name">{currentRefundGoods.name}</Text> |
|
|
|
|
<Text className="popup_goods_price">¥ {currentRefundGoods.price.toFixed(2)}</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
{/* 退款原因 */} |
|
|
|
|
<View className="refund_reason_section"> |
|
|
|
|
<Text className="reason_label">退款原因:</Text> |
|
|
|
|
<Textarea |
|
|
|
|
className="reason_input" |
|
|
|
|
placeholder="请输入退款原因" |
|
|
|
|
placeholderClass="reason_placeholder" |
|
|
|
|
value={refundReason} |
|
|
|
|
onInput={(e) => setRefundReason(e.detail.value)} |
|
|
|
|
maxlength={200} |
|
|
|
|
autoHeight |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</Popup> |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|