From 1b4514e3d0ffc7e74a3734a21c6ead347352b97e Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Tue, 6 Dec 2022 14:42:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ID1000749):=E3=80=90Bug?= =?UTF-8?q?=E8=BD=AC=E9=9C=80=E6=B1=82=E3=80=91=E6=96=B0=E7=89=88=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=95=86=E5=9F=8E=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E2=80=9C=E5=BE=85=E4=BB=98=E6=AC=BE=E2=80=9D=E5=8F=8A=E4=BB=A5?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E7=8A=B6=E6=80=81=E9=83=BD=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=80=E5=94=AE=E7=A0=81=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BottomBtns/index.tsx | 17 +- src/components/SaleCodeList/index.module.scss | 21 + src/components/SaleCodeList/index.tsx | 172 ++++++ src/pages/orderDetails/index.tsx | 518 +++++++++--------- 4 files changed, 472 insertions(+), 256 deletions(-) create mode 100644 src/components/SaleCodeList/index.module.scss create mode 100644 src/components/SaleCodeList/index.tsx diff --git a/src/components/BottomBtns/index.tsx b/src/components/BottomBtns/index.tsx index 2bc8316..aa72ee2 100644 --- a/src/components/BottomBtns/index.tsx +++ b/src/components/BottomBtns/index.tsx @@ -17,9 +17,11 @@ interface prosObj { showTuiGoods?: boolean handApplyGoods?: () => void handApplyMoney?: () => void + handShowCodeList?: () => void showDetail?: boolean goodsObj?: any } + const BottomBtns = (props: prosObj, ref) => { const { obj = { @@ -36,6 +38,7 @@ const BottomBtns = (props: prosObj, ref) => { handSureGoods, handApplyGoods, handApplyMoney, + handShowCodeList, showDetail = false, goodsObj = {}, } = props @@ -142,6 +145,15 @@ const BottomBtns = (props: prosObj, ref) => { else { return false } }, [obj]) + // 判断是否显示码单 + // 订单状态:待付款、待发货、待提货、待收货、已收货、已完成 + const showCodeList = useMemo(() => { + if (obj.status == 3 || obj.status == 8 || obj.status == 11 || obj.status == 9 || obj.status == 4) { + return true + } + else { return false } + }, [obj]) + // 多的不显示别的按钮 // const currentNums = useRef({ nums: 0 }) const itemNums = useMemo(() => { @@ -158,6 +170,7 @@ const BottomBtns = (props: prosObj, ref) => { if (showBuy) { nums = nums + 1 } + return nums }, [obj]) @@ -176,6 +189,9 @@ const BottomBtns = (props: prosObj, ref) => { (showTuikuan && showDetail && itemNums < 4) && handApplyMoney?.()}>申请退款 } + { + (showCodeList && showDetail) && handShowCodeList?.()}>销售码单 + } { showTake && showTuiGoods && handSureGoods?.()}>确认收货 } @@ -188,7 +204,6 @@ const BottomBtns = (props: prosObj, ref) => { { canBuy && toPay?.(e)}>去付款 } - ) } diff --git a/src/components/SaleCodeList/index.module.scss b/src/components/SaleCodeList/index.module.scss new file mode 100644 index 0000000..6fd23f9 --- /dev/null +++ b/src/components/SaleCodeList/index.module.scss @@ -0,0 +1,21 @@ +.popupBox { + .scroStyle { + height: 900px; + } + + .sure { + // margin-top: 35px; + margin-left: 40px; + margin-right: 40px; + // width: 670px; + height: 80px; + background: #337FFF; + border-radius: 44px; + font-size: 28px; + font-family: PingFangSC-Medium, PingFang SC; + font-weight: 500; + color: #FFFFFF; + text-align: center; + line-height: 80px; + } +} \ No newline at end of file diff --git a/src/components/SaleCodeList/index.tsx b/src/components/SaleCodeList/index.tsx new file mode 100644 index 0000000..30f8ef9 --- /dev/null +++ b/src/components/SaleCodeList/index.tsx @@ -0,0 +1,172 @@ +import { ScrollView, View, Image } from '@tarojs/components' +import { memo, useCallback, useEffect, useMemo, useState, useRef } from 'react' +import styles from './index.module.scss' +import classnames from 'classnames' +// import BottomBtns from '@/components/BottomBtns' +import { formatPriceDiv } from '@/common/format' +import Taro from '@tarojs/taro' +import Popup from '@/components/popup' +import useCheckAuthorize from '@/use/useCheckAuthorize' +import { alert } from '@/common/common' +import { GetPayCode } from "@/api/order" +import { formatWeightDiv, formatDateTime } from '@/common/format' +import { PAY_H5_CODE_URL } from '@/common/constant' +interface Props { + obj: any, + // picUrl?: string, + showPopup: boolean, + popupClose: () => void +} + +export default memo((props: Props) => { + + const { fetchData: payFetch } = GetPayCode() + const [PicUrl, setPicUrl] = useState('') + useEffect(() => { + //判断进来的是否是空对象,减少性能问题 + var length = Object.keys(props.obj); + if (length.length > 0) getPic() + }, [props.obj]) + + const getPic = async () => { + Taro.showLoading({ + title: '请稍等...', + mask: true + }) + const list: any = []; + props.obj.product_list?.forEach((item) => { + item.product_colors.forEach((it) => { + list.push({ + product_code: item.code, + product_name: item.name, + product_color_code: it.code, + product_color_name: it.name, + num: it.roll.toString(), + weight: formatWeightDiv(it.label_weight).toString(), + deduction_weight: formatWeightDiv(it.deductions_weight).toString(), + settle_weight: formatWeightDiv(it.settle_weight).toString(), + deduction_amount: (it.deductions_amount / 100).toString(), + sale_price: (it.sale_price / 100).toString(), + total_price: (it.estimate_amount / 100).toString(), + length: (it.length / 100).toString(), + weight_error: formatWeightDiv(it.settle_weight_error).toString(), + }); + }); + }); + const query = { + list: list, + title: "面料销售电子确认单", + show_qrcode: true, + show_barcode: true, + show_wait_pay_amount: true, + order_type: props.obj.sale_mode_name, + shipment_mode: props.obj.shipment_mode_name, + company: props.obj.title_purchaser_name, + sale_user: props.obj.sale_user_name, + order_created_time: formatDateTime(props.obj.create_time), + order_no: props.obj.order_no, + target_user_name: props.obj.target_user_name, + target_address: props.obj.address_detail, + target_description: props.obj.remark, + pay_account: props.obj.transfer_remittance_account, + bank_account_name: props.obj.account_name, + bank_name: props.obj.bank_of_deposit, + pay_type: props.obj.settle_mode_name, + client: props.obj.purchaser_name, + phone: props.obj.target_user_phone, + order_total_length: (props.obj.total_number / 100).toString(), + order_total_price: ( + props.obj.bill_total_sale_price / 100 + ).toString(), + total_weight_error_discount: ( + props.obj.total_weight_error_discount / 100 + ).toString(), + order_total_num: props.obj.total_number.toString(), + qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${props.obj.order_no}`, + order_total_weight: (props.obj.total_weight / 1000).toString(), + estimate_amount: (props.obj.estimate_amount / 100).toString(), + total_sale_price: (props.obj.total_sale_price / 100).toString(), + show_total_sale_price: true, + show_total_weight_error_discount: true, + actual_amount: (props.obj.actual_amount / 100).toString(), + wait_pay_amount: (props.obj.wait_pay_amount / 100).toString(), + order_total_weight_error: ( + props.obj.total_weight_error / 1000 + ).toString(), + }; + const res = await payFetch(query) + if (res.data) { + setPicUrl(res.data.base64) + Taro.hideLoading() + } + } + + const fileData = useRef({ + filePath: '', + base64: '', + }) + + //预览图片 + const showImage = () => { + const time = new Date().valueOf() + const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || [] + let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + fileData.current.filePath = filePath + fileData.current.base64 = bodyData + const save = Taro.getFileSystemManager() + save.writeFile({ + filePath: fileData.current.filePath, + data: fileData.current.base64, + encoding: 'base64', + }) + Taro.previewImage({ + current: fileData.current.filePath, // 当前显示 + urls: [fileData.current.filePath], // 需要预览的图片http链接列表 + }) + } + + //检查是否开启保存图片权限 + const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' }) + const saveImageCheck = async () => { + const res = await check() + res && saveImage() + } + + //保存图片 + const saveImage = () => { + const time = new Date().valueOf() + const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || [] + let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format + fileData.current.filePath = filePath + fileData.current.base64 = bodyData + const save = Taro.getFileSystemManager() + save.writeFile({ + filePath: fileData.current.filePath, + data: fileData.current.base64, + encoding: 'base64', + }) + alert.loading('正在保存图片') + Taro.saveImageToPhotosAlbum({ + filePath: fileData.current.filePath, + success: function () { + alert.success('图片保存成功') + }, + fail: function (err) { + console.log('err::', err) + }, + }) + } + + return ( + props.popupClose?.()}> + + + + showImage()}> + + + saveImageCheck()}>保存图片 + + + ) +}) \ No newline at end of file diff --git a/src/pages/orderDetails/index.tsx b/src/pages/orderDetails/index.tsx index 6de53c1..770c117 100644 --- a/src/pages/orderDetails/index.tsx +++ b/src/pages/orderDetails/index.tsx @@ -16,22 +16,23 @@ import BottomBtns from '@/components/BottomBtns' import { debounce } from '@/common/util' import { GetPayCode, - MpSaleOrder, - MpSaleOrderAddress, - MpSaleOrderCancel, - MpSaleOrderPut, - MpSaleOrderReceive, - MpSaleOrderShipmentMode, - MpShoppingCartProductColorList, - OrderPaymentOrderPaymentMethodInfo, - OrderPaymentOrderPaymentSubmission, - OrderPaymentPreCollectOrderOrderPaymentMethodInfo, - OrderPaymentPreCollectOrderOrderPaymentSubmission, + mpsaleOrder, + mpsaleOrderaddress, + mpsaleOrdercancel, + mpsaleOrderput, + mpsaleOrderreceive, + mpsaleOrdershipmentMode, + mpshoppingCartproductColorlist, + orderPaymentorderPaymentMethodInfo, + orderPaymentorderPaymentSubmission, + orderPaymentpreCollectOrderorderPaymentMethodInfo, + orderPaymentpreCollectOrderorderPaymentSubmission, } from '@/api/order' import { alert, goLink } from '@/common/common' import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format' import IconFont from '@/components/iconfont/iconfont' import { PAY_H5_CODE_URL } from '@/common/constant' +import SaleCodeList from '@/components/SaleCodeList' // 卡片盒子元素 interface Obs { @@ -120,61 +121,18 @@ const OrderDetails = () => { // useEffect(() => { // getDetail() // }, []) + useDidShow(() => { + getDetail() + }) + // 页面下拉刷新 + usePullDownRefresh(() => { + getDetail() + }) // 收货方法,1:自提,2物流 const [receivingStatus, setReceivingStatus] = useState(null) // 切换自提或者物流 - const { fetchData: selectFetch } = MpSaleOrderShipmentMode() - // 订单信息文字数组 - const [orderMsg, setOrderMsg] = useState([ - { - leftTitle: '订单编号:', - rightTitle: '------', - showBtn: true, - }, - { - leftTitle: '创建时间:', - rightTitle: '------', - }, - { - leftTitle: '发货时间:', - rightTitle: '------', - }, - { - leftTitle: '业务员:', - rightTitle: '------', - }, - ]) - const { fetchData: infoFetch } = MpSaleOrder() - const [infoObj, setInfoObj] = useState({}) - // 获取订单详情 - const getDetail = async() => { - Taro.showLoading({ - title: '加载中...', - mask: true, - }) - const res = await infoFetch({ id: router.params.id }) - setInfoObj(res.data) - orderMsg.forEach((it) => { - if (it.leftTitle === '订单编号:') { - it.rightTitle = res.data.order_no - } - if (it.leftTitle === '创建时间:') { - it.rightTitle = formatDateTime(res.data.create_time) - } - if (it.leftTitle === '发货时间:') { - it.rightTitle = formatDateTime(res.data.delivery_time) - } - if (it.leftTitle === '业务员:') { - it.rightTitle = res.data.sale_user_name - } - }) - setOrderMsg([...orderMsg]) - setReceivingStatus(res.data.shipment_mode) - // 小程序提供的api,通知页面停止下拉刷新效果 - Taro.stopPullDownRefresh() - Taro.hideLoading() - } + const { fetchData: selectFetch } = mpsaleOrdershipmentMode() const onReceivingStatus = debounce(async(e, value) => { if (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 3 || infoObj.status === 11) { alert.error('不允许更改') @@ -217,6 +175,36 @@ const OrderDetails = () => { } }, 300) + const { fetchData: infoFetch } = mpsaleOrder() + const [infoObj, setInfoObj] = useState({}) + // 获取订单详情 + const getDetail = async() => { + Taro.showLoading({ + title: '加载中...', + mask: true, + }) + const res = await infoFetch({ id: router.params.id }) + setInfoObj(res.data) + orderMsg.map((it) => { + if (it.leftTitle === '订单编号:') { + it.rightTitle = res.data.order_no + } + if (it.leftTitle === '创建时间:') { + it.rightTitle = formatDateTime(res.data.create_time) + } + if (it.leftTitle === '发货时间:') { + it.rightTitle = formatDateTime(res.data.delivery_time) + } + if (it.leftTitle === '业务员:') { + it.rightTitle = res.data.sale_user_name + } + }) + setOrderMsg([...orderMsg]) + setReceivingStatus(res.data.shipment_mode) + // 小程序提供的api,通知页面停止下拉刷新效果 + Taro.stopPullDownRefresh() + Taro.hideLoading() + } // 复制功能 const clipboardData = () => { Taro.setClipboardData({ @@ -233,10 +221,30 @@ const OrderDetails = () => { // useEffect(() => { // setReceivingStatus(receivingStatus) // }, [receivingStatus]) + // 订单信息文字数组 + const [orderMsg, setOrderMsg] = useState([ + { + leftTitle: '订单编号:', + rightTitle: '------', + showBtn: true, + }, + { + leftTitle: '创建时间:', + rightTitle: '------', + }, + { + leftTitle: '发货时间:', + rightTitle: '------', + }, + { + leftTitle: '业务员:', + rightTitle: '------', + }, + ]) // 备注操作 const [showDesc, setShowDesc] = useState(false) - const { fetchData: remarkFetch } = MpSaleOrderPut() + const { fetchData: remarkFetch } = mpsaleOrderput() const getRemark = async() => { const res = await remarkFetch({ remark: infoObj.remark, id: Number(router.params.id) }) if (res.msg === 'success') { @@ -258,7 +266,7 @@ const OrderDetails = () => { getDetail() }, []) - const { fetchData: cancelFetch } = MpSaleOrderCancel() + const { fetchData: cancelFetch } = mpsaleOrdercancel() // 取消订单 const cancle = async(e, item) => { e.stopPropagation() @@ -291,7 +299,7 @@ const OrderDetails = () => { }) } // 再次购买 - const { fetchData: buyFetch } = MpShoppingCartProductColorList() + const { fetchData: buyFetch } = mpshoppingCartproductColorlist() const nextBuy = async(e, item) => { e.stopPropagation() Taro.showLoading({ @@ -329,8 +337,8 @@ const OrderDetails = () => { } } // 去支付逻辑 - const { fetchData: infoOneFetch } = OrderPaymentOrderPaymentMethodInfo() - const { fetchData: infoTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentMethodInfo() + const { fetchData: infoOneFetch } = orderPaymentorderPaymentMethodInfo() + const { fetchData: infoTwoFetch } = orderPaymentpreCollectOrderorderPaymentMethodInfo() const [payList, setPayList] = useState([ { id: 2, @@ -365,142 +373,6 @@ const OrderDetails = () => { name: '扫码支付', }, ]) - - useDidShow(() => { - getDetail() - }) - // 页面下拉刷新 - usePullDownRefresh(() => { - getDetail() - }) - - // 扫码支付 - const [showSide, setShowSide] = useState(true) - const [title, setTitle] = useState('') - const [picUrl, setPicUrl] = useState('') - const { fetchData: payFetch } = GetPayCode() - const handScanpay = async() => { - const list: any = [] - infoObj.product_list.forEach((item) => { - item.product_colors.forEach((it) => { - list.push({ - product_code: item.code, - product_name: item.name, - product_color_code: it.product_color_code, - product_color_name: it.product_color_name, - num: it.roll.toString(), - weight: formatWeightDiv(it.actual_weight).toString(), - sale_price: (it.sale_price / 100).toString(), - total_price: - it.total_sale_price !== 0 - ? (it.total_sale_price / 100).toString() - : (it.estimate_amount / 100).toString(), - length: (it.length / 100).toString(), - weight_error: formatWeightDiv(it.weight_error).toString(), - }) - }) - }) - const query = { - list, - title: '面料销售电子确认单', - show_qrcode: true, - show_barcode: true, - order_type: infoObj.sale_mode_name, - shipment_mode: infoObj.shipment_mode_name, - company: infoObj.title_purchaser_name, - sale_user: infoObj.sale_user_name, - order_created_time: formatDateTime(infoObj.create_time), - order_no: infoObj.order_no, - target_user_name: infoObj.target_user_name, - target_address: infoObj.address_detail, - target_description: infoObj.remark, - pay_account: infoObj.transfer_remittance_account, - bank_account_name: infoObj.account_name, - bank_name: infoObj.bank_of_deposit, - pay_type: infoObj.settle_mode_name, - client: infoObj.purchaser_name, - phone: infoObj.target_user_phone, - order_total_length: (infoObj.total_number / 100).toString(), - order_total_price: ( - infoObj.bill_total_sale_price / 100 - ).toString(), - total_weight_error_discount: ( - infoObj.total_weight_error_discount / 100 - ).toString(), - order_total_num: infoObj.total_number.toString(), - qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${infoObj.order_no}`, - order_total_weight: (infoObj.total_weight / 1000).toString(), - estimate_amount: (infoObj.estimate_amount / 100).toString(), - total_sale_price: (infoObj.total_sale_price / 100).toString(), - actual_amount: (infoObj.actual_amount / 100).toString(), - wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(), - order_total_weight_error: ( - infoObj.total_weight_error / 1000 - ).toString(), - show_sale_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_total_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_estimate_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_total_sale_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_total_weight_error_discount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_actual_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - show_wait_pay_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)), - } - const res = await payFetch(query) - if (res.data) { - console.log(res.data.base64) - setShowSide(false) - setTitle('查看销售码单') - setPicUrl(res.data.base64) - } - } - - // 确认交易 - const { fetchData: payOneFetch } = OrderPaymentOrderPaymentSubmission() - const { fetchData: payTwoFetch } = OrderPaymentPreCollectOrderOrderPaymentSubmission() - - // 显示支付 - const [showPay, setShowPay] = useState(false) - // 显示线下汇款 - const [showOffline, setShowOffine] = useState(false) - // 选择地址 - const handSelect = (obj) => { - if (receivingStatus === 1 || (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 11 || infoObj.status === 3)) { - alert.error('不允许更改') - return false - } - Taro.navigateTo({ - url: `/pages/addressManager/index?orderId=${obj.id}&purchaser_id=${obj.purchaser_id}`, - }) - } - - // 申请退货 - const handApplyGood = () => { - if (infoObj.av_return_product.length == 0) { - return alert.error('暂无货物退') - } - else { - Taro.navigateTo({ - url: `/pages/applyGoods/index?orderId=${infoObj.id}`, - }) - setShowMore(false) - } - } - - // 申请退款 - const handApplyMoney = () => { - // 三种类型的 待收货,已收货后申请退货退款,需要选择质量/非质量问题 - if (infoObj?.status == 8 || infoObj?.status == 9) { - Taro.navigateTo({ - url: `/pages/applyGoods/index?orderId=${infoObj.id}`, - }) - } - else { - Taro.navigateTo({ - url: `/pages/applyMoney/index?orderId=${infoObj.id}`, - }) - } - setShowMore(false) - } const toPay = async(e, item) => { e.stopPropagation() @@ -583,43 +455,102 @@ const OrderDetails = () => { setTitle('待支付款项') setShowPay(true) } - // 确认收货 - const { fetchData: receveFetch } = MpSaleOrderReceive() - const handSureGoods = async() => { - Taro.showModal({ - content: '确认收货吗?', - confirmText: '确认', - cancelText: '取消', - async success(res) { - if (res.confirm) { - Taro.showLoading({ - title: '请稍等...', - mask: true, - }) - const res = await receveFetch({ sale_order_id: Number(infoObj.id) }) - if (res?.msg === 'success') { - Taro.showToast({ - title: '成功', - }) - Taro.hideLoading() - setShowMore(false) - getDetail() - } - else { - Taro.hideLoading() - Taro.showToast({ - title: res?.msg, - icon: 'error', - }) - } - } - }, + + // 选择支付方式 + const clickItem = (item) => { + if (item.name === '扫码支付') { handScanpay() } + if (item.name === '线下汇款') { setShowOffine(true) } + payList.map((it) => { + if (item.id === it.id) { + it.checked = true + } + else { + it.checked = false + } + return it }) + setPayList([...payList]) } - const onChange = (e) => { - setInfoObj(val => ({ ...val, remark: e })) + // 扫码支付 + const [showSide, setShowSide] = useState(true) + const [title, setTitle] = useState('') + const [picUrl, setPicUrl] = useState('') + const { fetchData: payFetch } = GetPayCode() + const handScanpay = async() => { + const list: any = [] + infoObj.product_list.forEach((item) => { + item.product_colors.forEach((it) => { + list.push({ + product_code: item.code, + product_name: item.name, + product_color_code: it.product_color_code, + product_color_name: it.product_color_name, + num: it.roll.toString(), + weight: formatWeightDiv(it.actual_weight).toString(), + sale_price: (it.sale_price / 100).toString(), + total_price: + it.total_sale_price !== 0 + ? (it.total_sale_price / 100).toString() + : (it.estimate_amount / 100).toString(), + length: (it.length / 100).toString(), + weight_error: formatWeightDiv(it.weight_error).toString(), + }) + }) + }) + const query = { + list, + title: '面料销售电子确认单', + show_qrcode: true, + show_barcode: true, + show_wait_pay_amount: true, + order_type: infoObj.sale_mode_name, + shipment_mode: infoObj.shipment_mode_name, + company: infoObj.title_purchaser_name, + sale_user: infoObj.sale_user_name, + order_created_time: formatDateTime(infoObj.create_time), + order_no: infoObj.order_no, + target_user_name: infoObj.target_user_name, + target_address: infoObj.address_detail, + target_description: infoObj.remark, + pay_account: infoObj.transfer_remittance_account, + bank_account_name: infoObj.account_name, + bank_name: infoObj.bank_of_deposit, + pay_type: infoObj.settle_mode_name, + client: infoObj.purchaser_name, + phone: infoObj.target_user_phone, + order_total_length: (infoObj.total_number / 100).toString(), + order_total_price: ( + infoObj.bill_total_sale_price / 100 + ).toString(), + total_weight_error_discount: ( + infoObj.total_weight_error_discount / 100 + ).toString(), + order_total_num: infoObj.total_number.toString(), + qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${infoObj.order_no}`, + order_total_weight: (infoObj.total_weight / 1000).toString(), + estimate_amount: (infoObj.estimate_amount / 100).toString(), + total_sale_price: (infoObj.total_sale_price / 100).toString(), + show_total_sale_price: true, + show_total_weight_error_discount: true, + actual_amount: (infoObj.actual_amount / 100).toString(), + wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(), + order_total_weight_error: ( + infoObj.total_weight_error / 1000 + ).toString(), + } + const res = await payFetch(query) + if (res.data) { + console.log(res.data.base64) + setShowSide(false) + setTitle('查看销售码单') + setPicUrl(res.data.base64) + } } + + // 确认交易 + const { fetchData: payOneFetch } = orderPaymentorderPaymentSubmission() + const { fetchData: payTwoFetch } = orderPaymentpreCollectOrderorderPaymentSubmission() const handsurePay = (obj) => { let arr: any = [] // if (obj.status !== 10) { @@ -666,6 +597,89 @@ const OrderDetails = () => { // } } + + // 显示支付 + const [showPay, setShowPay] = useState(false) + // 显示线下汇款 + const [showOffline, setShowOffine] = useState(false) + // 选择地址 + const handSelect = (obj) => { + if (receivingStatus === 1 || (infoObj.status === 8 || infoObj.status === 9 || infoObj.status === 4 || infoObj.status === 5 || infoObj.status === 11 || infoObj.status === 3)) { + alert.error('不允许更改') + return false + } + Taro.navigateTo({ + url: `/pages/addressManager/index?orderId=${obj.id}&purchaser_id=${obj.purchaser_id}`, + }) + } + + // 申请退货 + const handApplyGood = () => { + if (infoObj.av_return_product.length == 0) { + return alert.error('暂无货物退') + } + else { + Taro.navigateTo({ + url: `/pages/applyGoods/index?orderId=${infoObj.id}`, + }) + setShowMore(false) + } + } + + // 申请退款 + const handApplyMoney = () => { + // 三种类型的 待收货,已收货后申请退货退款,需要选择质量/非质量问题 + if (infoObj?.status == 8 || infoObj?.status == 9) { + Taro.navigateTo({ + url: `/pages/applyGoods/index?orderId=${infoObj.id}`, + }) + } + else { + Taro.navigateTo({ + url: `/pages/applyMoney/index?orderId=${infoObj.id}`, + }) + } + setShowMore(false) + } + + // 确认收货 + const { fetchData: receveFetch } = mpsaleOrderreceive() + const handSureGoods = async() => { + Taro.showModal({ + content: '确认收货吗?', + confirmText: '确认', + cancelText: '取消', + async success(res) { + if (res.confirm) { + Taro.showLoading({ + title: '请稍等...', + mask: true, + }) + const res = await receveFetch({ sale_order_id: Number(infoObj.id) }) + if (res?.msg === 'success') { + Taro.showToast({ + title: '成功', + }) + Taro.hideLoading() + setShowMore(false) + getDetail() + } + else { + Taro.hideLoading() + Taro.showToast({ + title: res?.msg, + icon: 'error', + }) + } + } + }, + }) + } + + const onChange = (e) => { + setInfoObj(val => ({ ...val, remark: e })) + } + useEffect(() => { setInfoObj(infoObj) }, [infoObj]) @@ -701,21 +715,13 @@ const OrderDetails = () => { return '合计金额' } }, [infoObj]) - // 选择支付方式 - const clickItem = (item) => { - if (item.name === '扫码支付') { handScanpay() } - if (item.name === '线下汇款') { setShowOffine(true) } - payList.map((it) => { - if (item.id === it.id) { - it.checked = true - } - else { - it.checked = false - } - return it - }) - setPayList([...payList]) + + const [showCodeList, setshowCodeList] = useState(false) + // 展示码单 + const handShowCodeList = () => { + setshowCodeList(true) } + return ( {(infoObj?.status != 10 && )} @@ -728,7 +734,7 @@ const OrderDetails = () => { receivingStatus={receivingStatus} onReceivingStatus={(e, value) => onReceivingStatus(e, value)} > - { {infoObj.purchaser_name} {infoObj.purchaser_phone} - + {infoObj.total_fabrics} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'} - + {payFont} @@ -775,7 +781,7 @@ const OrderDetails = () => { } - + { orderMsg.map((item, index) => { return ( @@ -793,7 +799,7 @@ const OrderDetails = () => { }) } - + setShowDesc(showRemarkFont != '')}> {infoObj.remark === '' ? '暂无' : infoObj.remark} @@ -842,6 +848,7 @@ const OrderDetails = () => { cancle={e => cancle?.(e, infoObj)} nextBuy={e => nextBuy?.(e, infoObj)} toPay={e => toPay?.(e, infoObj)} + handShowCodeList={() => handShowCodeList?.()} handSureGoods={() => handSureGoods?.()} handApplyGoods={() => handApplyGood?.()} handApplyMoney={() => handApplyMoney?.()} @@ -859,6 +866,7 @@ const OrderDetails = () => { picUrl={picUrl} > setShowOffine(false)} offlineInfo={infoObj}> + setshowCodeList(false)}> ) }