From 3d349d405a27fcc36abf9cc7417b2cb4357beae8 Mon Sep 17 00:00:00 2001 From: czm <2192718639@qq.com> Date: Fri, 24 Jun 2022 19:54:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=94=AE=E5=90=8E=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/salesAfterOrder.ts | 12 +++- src/components/afterOrderBtns/index.tsx | 36 ++++++------ src/components/orderBtns/index.tsx | 25 ++++++++ src/pages/applyAfterSales/index copy.tsx | 1 - src/pages/details/index.tsx | 4 +- .../order/components/applyRefund/index.tsx | 57 +++++++++++++++---- .../components/reasonPopup/index.module.scss | 3 + .../order/components/reasonPopup/index.tsx | 31 ++++------ src/pages/order/components/remark/index.tsx | 6 +- src/pages/order/index.tsx | 2 +- .../orderList/components/order/index.tsx | 4 +- src/pages/salesAfter/index.tsx | 16 ++++-- .../salesAfterList/components/order/index.tsx | 2 +- src/pages/salesAfterList/index.tsx | 1 - 14 files changed, 134 insertions(+), 66 deletions(-) diff --git a/src/api/salesAfterOrder.ts b/src/api/salesAfterOrder.ts index ac66c62..9104042 100644 --- a/src/api/salesAfterOrder.ts +++ b/src/api/salesAfterOrder.ts @@ -79,4 +79,14 @@ export const GetSaleOrderListApi = () => { url: `/v1/mall/enum/returnExplain`, method: "get", }) -} \ No newline at end of file +} + +/** + * 申请退款 + */ + export const ApplyRefundApi = () => { + return useRequest({ + url: `/v1/mall/returnApplyOrder`, + method: "post", + }) +} diff --git a/src/components/afterOrderBtns/index.tsx b/src/components/afterOrderBtns/index.tsx index 6750838..2a4a560 100644 --- a/src/components/afterOrderBtns/index.tsx +++ b/src/components/afterOrderBtns/index.tsx @@ -15,28 +15,26 @@ type Param = { sale_mode: number //订单类型 type: number //1退货,2退款 }, - onClick?: (val: number) => void //点击后触发的事件,返回订单状态 + onClick?: (val: number) => void, //点击后触发的事件,返回订单状态 + onBtnNull?: () => void //所有按钮都为空 } -export default memo(({orderInfo, onClick}:Param) => { +export default memo(({orderInfo, onClick, onBtnNull}:Param) => { //售后订单状态 const { ReturnStageApplying, ReturnStageWaitCheck, - ReturnStageChecked, ReturnStageReturned, - ReturnStageCancel, ReturnStageQualityCheckPendingRefund, ReturnStageServiceOrderPendingRefund, - ReturnStageRejected } = AFTER_ORDER_STATUS //订单类型 - const { - SaLeModeBulk, - SaleModeLengthCut, - SaLeModeWeightCut, - } = SALE_MODE + // const { + // SaLeModeBulk, + // SaleModeLengthCut, + // SaLeModeWeightCut, + // } = SALE_MODE //售后按钮按售后状态归类, value是该订单状态,可能该按钮会出现 const orderBtnsList = useRef([ @@ -50,11 +48,11 @@ export default memo(({orderInfo, onClick}:Param) => { value: [ReturnStageWaitCheck.value], label: '退货物流' }, - { - id: 3, - value: [ReturnStageChecked.value, ReturnStageQualityCheckPendingRefund.value], - label: '查看物流' - }, + // { + // id: 3, + // value: [ReturnStageChecked.value, ReturnStageQualityCheckPendingRefund.value], + // label: '查看物流' + // }, { id: 4, value: [ReturnStageQualityCheckPendingRefund.value, ReturnStageServiceOrderPendingRefund.value, ReturnStageReturned.value], @@ -86,7 +84,6 @@ export default memo(({orderInfo, onClick}:Param) => { //判断是否显示该按钮 const orderBtnsShow = (item) => { if(!orderInfo) return false - if(item.id == 1) { //取消退货 return (orderInfo.type == 1)&&item.value.includes(orderInfo.stage) @@ -94,9 +91,14 @@ export default memo(({orderInfo, onClick}:Param) => { //取消退款 return (orderInfo.type == 2)&&item.value.includes(orderInfo.stage) } else { - return item.value.includes(orderInfo.stage) + if(item.value.includes(orderInfo.stage)) { + return true + } else { + onBtnNull?.() + } } + } //显示的按钮数组 diff --git a/src/components/orderBtns/index.tsx b/src/components/orderBtns/index.tsx index 871f2a2..756083f 100644 --- a/src/components/orderBtns/index.tsx +++ b/src/components/orderBtns/index.tsx @@ -7,6 +7,7 @@ import {useRef, memo, useState, useMemo } from "react" import classnames from "classnames"; import styles from './index.module.scss' import { AddShoppingCartApi } from "@/api/shopCart" +import { ApplyRefundApi } from "@/api/salesAfterOrder" type Param = { orderInfo: { @@ -133,6 +134,8 @@ export default memo(({orderInfo, onClick}:Param) => { receiveOrder() } else if(val == 5) { goLink('/pages/applyAfterSales/index',{id:orderInfo?.orderId}) + } else if(val == 8) { + applyRefund() } else { onClick?.(val) } @@ -181,6 +184,28 @@ export default memo(({orderInfo, onClick}:Param) => { }) } + //退款 + const {fetchData: fetchDataApplyRefund} = ApplyRefundApi() + const applyRefund = async () => { + Taro.showModal({ + title: '确定退款?', + success: async function async (res) { + if(res.confirm) { + let res = await fetchDataApplyRefund({sale_order_id: orderInfo?.orderId}) + if(res.success) { + alert.success('申请成功') + } else { + alert.error('申请失败') + } + onClick?.(8) + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + + } + //显示更多按钮 const [showMore, setShowMore] = useState(false) diff --git a/src/pages/applyAfterSales/index copy.tsx b/src/pages/applyAfterSales/index copy.tsx index 0314289..32cb3b4 100644 --- a/src/pages/applyAfterSales/index copy.tsx +++ b/src/pages/applyAfterSales/index copy.tsx @@ -67,7 +67,6 @@ export default () => { unit: orderDetail.sale_mode == 0?'条':'m', //单位 list: orderDetail.product_list, status: orderDetail.status, //订单状态 - }) } diff --git a/src/pages/details/index.tsx b/src/pages/details/index.tsx index 3d289d7..87903c5 100644 --- a/src/pages/details/index.tsx +++ b/src/pages/details/index.tsx @@ -192,9 +192,9 @@ export default (props:Params) => { { (!userInfo.adminUserInfo?.is_authorize_phone)&& - 开始下单 + 选购商品 - || placeOrder('to_order')}>开始下单 + || placeOrder('to_order')}>选购商品 } diff --git a/src/pages/order/components/applyRefund/index.tsx b/src/pages/order/components/applyRefund/index.tsx index 481d03f..456075b 100644 --- a/src/pages/order/components/applyRefund/index.tsx +++ b/src/pages/order/components/applyRefund/index.tsx @@ -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([]) + + + //备注 + 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 ( <> 退款说明 - onShowReason()}> + setShowReason(true)}> 请选择 @@ -51,7 +84,7 @@ export default memo(({show, onClose}:Param) => { - + ) }) \ No newline at end of file diff --git a/src/pages/order/components/reasonPopup/index.module.scss b/src/pages/order/components/reasonPopup/index.module.scss index eba26cd..2d0f899 100644 --- a/src/pages/order/components/reasonPopup/index.module.scss +++ b/src/pages/order/components/reasonPopup/index.module.scss @@ -22,6 +22,9 @@ .reason_item{ margin-bottom: 36px; } + .select_item { + color: #007AFF; + } } } } \ No newline at end of file diff --git a/src/pages/order/components/reasonPopup/index.tsx b/src/pages/order/components/reasonPopup/index.tsx index 1230787..0ed990c 100644 --- a/src/pages/order/components/reasonPopup/index.tsx +++ b/src/pages/order/components/reasonPopup/index.tsx @@ -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 ( - + - 退款说明 + {title} - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 - 完好无损带原标签 + {list.map(item => onSelect?.(item)} key={item.id} className={classnames(styles.reason_item, item.id == defaultValue&&styles.select_item)}>{item.name} )} diff --git a/src/pages/order/components/remark/index.tsx b/src/pages/order/components/remark/index.tsx index 11d870f..8fdd21a 100644 --- a/src/pages/order/components/remark/index.tsx +++ b/src/pages/order/components/remark/index.tsx @@ -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) => { 编辑备注 - + {descData.number}/{descData.count} setSave()}>保存 diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index 4714383..5868c32 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -282,7 +282,7 @@ import styles from './index.module.scss' getRemark(e)} defaultValue={orderDetail?.remark}/> - + setShowCart(false)}/> diff --git a/src/pages/orderList/components/order/index.tsx b/src/pages/orderList/components/order/index.tsx index 811e8ab..5dbb13c 100644 --- a/src/pages/orderList/components/order/index.tsx +++ b/src/pages/orderList/components/order/index.tsx @@ -85,8 +85,8 @@ export default memo(({value, onClickBtn}: Param) => { - - {value?.product_list[0].product_colors[0].code} + + {value?.product_list[0].product_colors[0].code} {value?.product_list[0].product_colors.map((itemColor, index) => { diff --git a/src/pages/salesAfter/index.tsx b/src/pages/salesAfter/index.tsx index 2796f66..1c318e1 100644 --- a/src/pages/salesAfter/index.tsx +++ b/src/pages/salesAfter/index.tsx @@ -5,7 +5,7 @@ import { import { GetOrderPayApi } from "@/api/orderPay"; import { SaleOrderOrderDetailApi } from "@/api/salesAfterOrder"; import { alert, goLink } from "@/common/common"; -import { ORDER_STATUS } from "@/common/enum"; +import { AFTER_ORDER_STATUS, ORDER_STATUS } from "@/common/enum"; import { formatDateTime, formatImgUrl, formatPriceDiv } from "@/common/fotmat"; import AfterOrderBtns from "@/components/afterOrderBtns"; import OrderBtns from "@/components/orderBtns"; @@ -95,8 +95,10 @@ import styles from './index.module.scss' } }, [orderDetail]) - //订单状态枚举 - const {SaleOrderStatusCancel} = ORDER_STATUS + //售后订单状态枚举 + const { + + } = AFTER_ORDER_STATUS //物流显示 const [logisticsShow, setLogisticsShow] = useState(false) @@ -122,15 +124,17 @@ import styles from './index.module.scss' //显示生气记录 const [applyRecord, setApplyRecord] = useState(false) + //货 + return ( - {(orderDetail?.status != SaleOrderStatusCancel.value)&& - - } + + + setApplyRecord(false)}/> diff --git a/src/pages/salesAfterList/components/order/index.tsx b/src/pages/salesAfterList/components/order/index.tsx index 7dd2ac9..749d956 100644 --- a/src/pages/salesAfterList/components/order/index.tsx +++ b/src/pages/salesAfterList/components/order/index.tsx @@ -109,7 +109,7 @@ export default memo(({value, onClickBtn}: Param) => { 订单号:{value?.order_no} - + ) }) diff --git a/src/pages/salesAfterList/index.tsx b/src/pages/salesAfterList/index.tsx index 9c4f25e..bd52d1c 100644 --- a/src/pages/salesAfterList/index.tsx +++ b/src/pages/salesAfterList/index.tsx @@ -107,7 +107,6 @@ export default () => { const [logisticsShow, setLogisticsShow] = useState(false) const onCloseLogistics = useCallback(() => setLogisticsShow(false), []) - return (