对接售后退款申请

This commit is contained in:
2022-06-24 19:54:01 +08:00
parent 9503d35dbb
commit 3d349d405a
14 changed files with 134 additions and 66 deletions
@@ -1,43 +1,76 @@
import Popup from "@/components/popup";
import TextareaEnhance from "@/components/textareaEnhance";
import { ScrollView, Text, View } from "@tarojs/components";
import { memo, useCallback, useState } from "react";
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 { alert } from "@/common/common";
type Param = {
show?: true|false,
onClose?: () => void
onClose?: () => void,
orderId?: number
}
export default memo(({show, onClose}:Param) => {
export default memo(({show, onClose, orderId}:Param) => {
const getOtherReason = useCallback(() => {
//提交的数据
const submitData = useRef({
return_explain: 1,
sale_order_id: 0,
reason_describe: ''
})
}, [])
const onSubmit = (val) => {
useEffect(() => {
if(orderId)
submitData.current.sale_order_id = orderId
}, [orderId])
//申请退款
const {fetchData} = ApplyRefundApi()
const getApplyRefund = async () => {
let res = await fetchData(submitData.current)
if(!submitData.current.return_explain) return alert.error('请选择说明原因')
if(res.success) {
alert.error('申请成功')
} else {
alert.error('申请失败')
}
onClose?.()
}
//获取说明数据
const [list, setList] = useState<any[]>([])
//备注
const getOtherReason = useCallback((val) => {
submitData.current.reason_describe = val
}, [])
//显示说明
const [showReason, setShowReason] = useState(false)
const closeReason = useCallback(() => {
setShowReason(false)
}, [])
const onShowReason = () => {
setShowReason(true)
//提交
const onSubmit = () => {
getApplyRefund()
}
return (
<>
<Popup show={show} title="申请退款" onClose={onClose} >
<View className={styles.apply_after_sales_con}>
<View className={styles.returnSaleInput_item}>
<View className={styles.title}>退款说明</View>
<View className={styles.select} onClick={() => onShowReason()}>
<View className={styles.select} onClick={() => setShowReason(true)}>
<Text>请选择</Text>
<Text className={classnames(styles.miconfont, 'iconfont icon-a-moreback')}></Text>
</View>
@@ -51,7 +84,7 @@ export default memo(({show, onClose}:Param) => {
</View>
</View>
</Popup>
<ReasonPopup show={showReason} onClose={closeReason} />
<ReasonPopup show={showReason} onClose={closeReason} list={list} title="退款说明"/>
</>
)
})
@@ -22,6 +22,9 @@
.reason_item{
margin-bottom: 36px;
}
.select_item {
color: #007AFF;
}
}
}
}
@@ -1,34 +1,27 @@
import Popup from "@/components/popup";
import { ScrollView, Text, View } from "@tarojs/components";
import { memo, useMemo } from "react";
import classnames from "classnames";
import styles from './index.module.scss'
//原因选择
type ReasonInfoParam = {
show?: boolean,
onClose?: () => void,
show?: boolean, //显示
onClose?: () => void, //关闭
title?: string, //标题
list?: {id:number, name:string, typle?:number}[], //数据列表
onSelect?: (val: object) => void, //选择
defaultValue?: number, //默认选中
}
export default memo(({show = false, onClose}: ReasonInfoParam) => {
export default memo(({show = false, onClose, title = '', list= [], onSelect, defaultValue}: ReasonInfoParam) => {
return (
<Popup showIconButton={false} show={show} title="退款说明" onClose={onClose} >
<Popup showIconButton={false} show={show} title={title} onClose={onClose} >
<View className={styles.reason_return_con}>
<View className={styles.reason_title}><Text>退款说明</Text></View>
<View className={styles.reason_title}><Text>{title}</Text></View>
<ScrollView scrollY className={styles.reason_scroll}>
<View className={styles.reason_list}>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
<View className={styles.reason_item}>完好无损带原标签</View>
{list.map(item => <View onClick={() => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name}</View> )}
</View>
</ScrollView>
</View>
+3 -3
View File
@@ -19,13 +19,13 @@ export default ({onBlur, onSave, defaultValue = ''}:Param) => {
getDesc(defaultValue)
}, [defaultValue])
const getDesc = useCallback((value) => {
const getDesc = (value) => {
let res = value
if(value.length > descData.count) {
res = value.slice(0, descData.count)
}
setDescData({...descData, number:res.length, value: res})
},[])
}
const setSave = () => {
onSave?.(descData.value)
@@ -34,7 +34,7 @@ export default ({onBlur, onSave, defaultValue = ''}:Param) => {
<View className={styles.order_popup}>
<View className={styles.order_popup_title}>编辑备注</View>
<View className={styles.order_popup_input}>
<Textarea placeholder="请添加备注" maxlength={descData.count} cursorSpacing={100} onInput={(e) => getDesc(e.detail.value)} onBlur={(e) => onBlur?.(e)}></Textarea>
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={(e) => getDesc(e.detail.value)} onBlur={(e) => onBlur?.(e)}></Textarea>
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
</View>
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>