Commit ce2e87d6 authored by GuanHua's avatar GuanHua
parents 30203adb 51bb4004
...@@ -99,4 +99,30 @@ ...@@ -99,4 +99,30 @@
} }
} }
}
// 扫码
.qrCodeImage {
text-align: center;
width: 224px;
height: 224px;
margin: 20px auto 42px;
&>img {
display: block;
width: 100%;
height: 100%;
}
}
.scanTips {
display: flex;
justify-content: center;
align-items: center;
color: #6b778c;
margin-bottom: 18px;
.scanIcon {
font-size: 30px;
margin-right: @margin-sm;
}
} }
\ No newline at end of file
...@@ -3,13 +3,14 @@ import { Modal, Steps, Row, Col, Spin, message, Upload, Button, Input } from 'an ...@@ -3,13 +3,14 @@ import { Modal, Steps, Row, Col, Spin, message, Upload, Button, Input } from 'an
import style from './index.less' import style from './index.less'
import { OrderDetailContext } from '../../_public/order/context' import { OrderDetailContext } from '../../_public/order/context'
import cx from 'classnames' import cx from 'classnames'
import { UploadOutlined } from '@ant-design/icons' import { ScanOutlined, UploadOutlined } from '@ant-design/icons'
import { UPLOAD_TYPE } from '@/constants' import { UPLOAD_TYPE } from '@/constants'
import { usePageStatus } from '@/hooks/usePageStatus' import { usePageStatus } from '@/hooks/usePageStatus'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { history } from 'umi' import { history } from 'umi'
import { useHttpRequest } from '@/hooks/useHttpRequest' import { useHttpRequest } from '@/hooks/useHttpRequest'
import { encryptedByAES } from '@/utils/cryptoAes' import { encryptedByAES } from '@/utils/cryptoAes'
import QRCode from 'qrcode'
export interface OrderPayModalProps { export interface OrderPayModalProps {
currentRef: any, currentRef: any,
...@@ -79,7 +80,9 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -79,7 +80,9 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
const [checked, setChecked] = useState<any>({}) const [checked, setChecked] = useState<any>({})
const [current, setCurrent] = useState(0) // 0选择方式 1线下支付方式 2授信支付 3余额支付 4微信支付 5货到付款 1000清除 const [current, setCurrent] = useState(0) // 0选择方式 1线下支付方式 2授信支付 3余额支付 4微信支付 5货到付款 1000清除
const [payStep, setPayStep] = useState(0) // 支付模态框的步骤 0选方式 1下一步的具体操作 2输入支付密码 const [payStep, setPayStep] = useState(0) // 支付模态框的步骤 0选方式 1下一步的具体操作 2输入支付密码
const mobilePayFlag = useRef(0) // 用于判断移动支付类型 4微信
const [code, setCode] = useState('') const [code, setCode] = useState('')
const [qrCodeInfo, setQrCodeInfo] = useState({ generateCharacter: '', qrUrl: '' })
const [number, setNumber] = useState([0,1,2,3,4,5]) const [number, setNumber] = useState([0,1,2,3,4,5])
const { currentRef, confirm } = props const { currentRef, confirm } = props
const [isSpin, setIsSpin] = useState<boolean>(false) const [isSpin, setIsSpin] = useState<boolean>(false)
...@@ -103,6 +106,24 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -103,6 +106,24 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
} }
}, [visible]) }, [visible])
useEffect(() => {
if(qrCodeInfo.generateCharacter){
generateQrCode()
}
}, [qrCodeInfo.generateCharacter])
const generateQrCode = () => {
// 生成二维码
QRCode.toDataURL(qrCodeInfo.generateCharacter).then((url:any) => {
setQrCodeInfo({...qrCodeInfo, qrUrl: url})
// 轮询支付结果
// setOpenTimer(1)
})
.catch((err:any) => {
console.error(err)
})
}
const handleConfirm = () => { const handleConfirm = () => {
console.log(data,'data') console.log(data,'data')
if (current === 0) { if (current === 0) {
...@@ -147,13 +168,15 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -147,13 +168,15 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
console.log('选择了货到付款') console.log('选择了货到付款')
setCurrent(5) setCurrent(5)
setPayStep(1) setPayStep(1)
} } else if(checked.id === 2) {
// else if(checked.id === 2) { console.log('选择了微信支付')
// console.log('选择了微信支付') // 跳转扫码支付
// setCurrent(4) history.push(`/pay?orderId=${btoa(JSON.stringify({ orderId: id, memberId: data.supplyMembersId, memberRoleId: data.supplyMembersRoleId }))}`)
// setPayStep(1) // mobilePayFlag.current = 4
// handleSubmitPay() // setCurrent(4)
// } // setPayStep(1)
// handleSubmitPay()
}
else { else {
message.error('暂只支持线下支付、授信额度支付、余额支付方式、货到付款') message.error('暂只支持线下支付、授信额度支付、余额支付方式、货到付款')
} }
...@@ -232,12 +255,15 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -232,12 +255,15 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
params.payOrderUrls = payOrderUrls.join(',') params.payOrderUrls = payOrderUrls.join(',')
} }
console.log(current, payStep,'666',mobilePayFlag)
const res = await run(params) const res = await run(params)
if (res.code === 1000) { if (res.code === 1000) {
if(current != 4) { if(mobilePayFlag.current !== 4) {
history.goBack() history.goBack()
} else { } else {
console.log(res, '二维码信息') console.log(res, '二维码信息')
setQrCodeInfo({ ...qrCodeInfo, generateCharacter: res.data })
} }
} }
} }
...@@ -433,9 +459,12 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => { ...@@ -433,9 +459,12 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
{ {
current === 4 && current === 4 &&
<div> <div>
<p>微信扫码支付</p> <div className={style.qrCodeImage}>
<div> <img src={qrCodeInfo.qrUrl} alt=""/>
<div className={style.scanTips}>
<ScanOutlined className={style.scanIcon} />
<span>打开 {mobilePayFlag.current === 4 ? '微信' : '支付宝'}App<br />扫码完成支付</span>
</div>
</div> </div>
</div> </div>
} }
......
...@@ -33,17 +33,17 @@ const ReadyConfirmOrderDetail: React.FC = () => { ...@@ -33,17 +33,17 @@ const ReadyConfirmOrderDetail: React.FC = () => {
// 提交表单 // 提交表单
const handleSubmit = useCallback(() => { const handleSubmit = () => {
approvedRef.current.actions.submit().then(async (v) => { approvedRef.current.actions.submit().then(async (v) => {
const params = { const params = {
id: Number(id), id: Number(id),
state: v.values.state, state: v.values.state,
cause: v.values.cause, cause: v.values.cause,
} }
if(v.values.state) { // 通过 if(formContext.data.usingElectronicContracts && v.values.state) { // 使用合同 并且通过
approvedRef.current.setVisible(false) approvedRef.current.setVisible(false)
electronRef.current.setVisible(true) electronRef.current.setVisible(true)
} else { // 不通过 } else {
const result = await run(params) const result = await run(params)
if (result.code === 1000) { if (result.code === 1000) {
...@@ -51,10 +51,8 @@ const ReadyConfirmOrderDetail: React.FC = () => { ...@@ -51,10 +51,8 @@ const ReadyConfirmOrderDetail: React.FC = () => {
history.goBack() history.goBack()
} }
} }
console.log(params, v, 'v', approvedRef.current, electronRef.current)
}) })
}, []) }
return ( return (
<div> <div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment