电子商城测试版v3
This commit is contained in:
@@ -5,7 +5,7 @@ import { memo, useCallback, useEffect, useRef, useState } from "react";
|
||||
import ReasonPopup from "../reasonPopup";
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { ApplyRefundApi } from "@/api/salesAfterOrder";
|
||||
import { ApplyRefundApi, RefundExplainApi } from "@/api/salesAfterOrder";
|
||||
import { alert } from "@/common/common";
|
||||
|
||||
type Param = {
|
||||
@@ -17,21 +17,24 @@ export default memo(({show, onClose, orderId}:Param) => {
|
||||
|
||||
//提交的数据
|
||||
const submitData = useRef({
|
||||
return_explain: 1,
|
||||
return_explain: 0,
|
||||
sale_order_id: 0,
|
||||
reason_describe: ''
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if(orderId)
|
||||
if(orderId) {
|
||||
submitData.current.sale_order_id = orderId
|
||||
refundExplain()
|
||||
}
|
||||
|
||||
}, [orderId])
|
||||
|
||||
//申请退款
|
||||
const {fetchData} = ApplyRefundApi()
|
||||
const getApplyRefund = async () => {
|
||||
let res = await fetchData(submitData.current)
|
||||
if(!submitData.current.return_explain) return alert.error('请选择说明原因')
|
||||
let res = await fetchData(submitData.current)
|
||||
if(res.success) {
|
||||
alert.error('申请成功')
|
||||
} else {
|
||||
@@ -42,6 +45,17 @@ export default memo(({show, onClose, orderId}:Param) => {
|
||||
|
||||
//获取说明数据
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const {fetchData: refundExplainFetchdata} = RefundExplainApi()
|
||||
const refundExplain = async () => {
|
||||
let res = await refundExplainFetchdata()
|
||||
setList(res.data.list)
|
||||
}
|
||||
const [reason, setReason] = useState({id:0, name:''})
|
||||
const reasonSelect = useCallback((e) => {
|
||||
setReason({...reason, name:e.name, id:e.id})
|
||||
submitData.current.return_explain = e.id
|
||||
closeReason()
|
||||
}, [])
|
||||
|
||||
|
||||
//备注
|
||||
@@ -71,8 +85,6 @@ export default memo(({show, onClose, orderId}:Param) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popup show={show} title="申请退款" onClose={onClose} >
|
||||
@@ -80,7 +92,7 @@ export default memo(({show, onClose, orderId}:Param) => {
|
||||
<View className={styles.returnSaleInput_item}>
|
||||
<View className={styles.title}>退款说明</View>
|
||||
<View className={styles.select} onClick={() => setShowReason(true)}>
|
||||
<Text>请选择</Text>
|
||||
<Text>{reason.name||'请选择'}</Text>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-a-moreback')}></Text>
|
||||
</View>
|
||||
</View>
|
||||
@@ -93,7 +105,7 @@ export default memo(({show, onClose, orderId}:Param) => {
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
<ReasonPopup show={showReason} onClose={closeReason} list={list} title="退款说明"/>
|
||||
<ReasonPopup defaultValue={reason.id} show={showReason} onClose={closeReason} list={list} title="退款说明" onSelect={reasonSelect}/>
|
||||
</>
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user