|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { Radio, Row, Col, Tooltip, Flex, Form, Input, Button, InputNumber, Select, message } from 'antd'
|
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
|
import { Radio, Row, Col, Tooltip, Flex, App, Typography, Form, Input, Button, InputNumber, Select, message } from 'antd'
|
|
|
|
|
import { useState, useEffect, useCallback } from 'react'
|
|
|
|
|
import HtmlPreview from './HtmlPreview'
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
|
|
import useConversationStore from '@/stores/ConversationStore'
|
|
|
|
@ -7,6 +7,8 @@ import { useOrderStore } from '@/stores/OrderStore'
|
|
|
|
|
import { InfoCircleOutlined } from '@ant-design/icons'
|
|
|
|
|
|
|
|
|
|
function GeneratePayment() {
|
|
|
|
|
|
|
|
|
|
const { notification } = App.useApp()
|
|
|
|
|
const [messageApi, contextHolder] = message.useMessage()
|
|
|
|
|
|
|
|
|
|
const [generateForm] = Form.useForm()
|
|
|
|
@ -18,15 +20,21 @@ function GeneratePayment() {
|
|
|
|
|
const [isHtmlLoading, setHtmlLoading] = useState(false)
|
|
|
|
|
const [generatedObject, setGeneratedObject] = useState('')
|
|
|
|
|
|
|
|
|
|
const handleGenerate = () => {
|
|
|
|
|
const handleGenerate = useCallback(() => {
|
|
|
|
|
setHtmlLoading(true)
|
|
|
|
|
generatePayment(generateForm.getFieldsValue())
|
|
|
|
|
.then((result) => {
|
|
|
|
|
setGeneratedObject(result)
|
|
|
|
|
})
|
|
|
|
|
.catch((ex) => console.info(ex))
|
|
|
|
|
.catch((ex) =>
|
|
|
|
|
notification.error({
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
}))
|
|
|
|
|
.finally(() => setHtmlLoading(false))
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentOrder) {
|
|
|
|
@ -162,9 +170,7 @@ function GeneratePayment() {
|
|
|
|
|
<Button
|
|
|
|
|
type='primary'
|
|
|
|
|
loading={isHtmlLoading}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleGenerate()
|
|
|
|
|
}}>
|
|
|
|
|
onClick={handleGenerate}>
|
|
|
|
|
生成
|
|
|
|
|
</Button>
|
|
|
|
|
</Flex>
|
|
|
|
@ -173,19 +179,19 @@ function GeneratePayment() {
|
|
|
|
|
<Col span={6}>
|
|
|
|
|
<Flex gap='small' vertical>
|
|
|
|
|
<Flex gap='small'>
|
|
|
|
|
<span>支付按钮</span>
|
|
|
|
|
<Tooltip placement='topLeft' title='发送邮件使用'>
|
|
|
|
|
<InfoCircleOutlined />
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<span>支付按钮</span>
|
|
|
|
|
</Flex>
|
|
|
|
|
<HtmlPreview value={generatedObject.payhtml} loading={isHtmlLoading} onCopied={() => messageApi.success('已复制')} />
|
|
|
|
|
<Flex gap='small'>
|
|
|
|
|
<span>支付链接</span>
|
|
|
|
|
<Tooltip placement='topLeft' title='发送 WhatsApp 使用'>
|
|
|
|
|
<InfoCircleOutlined />
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<span>支付链接</span>
|
|
|
|
|
</Flex>
|
|
|
|
|
<Input readOnly value={generatedObject.paylink} />
|
|
|
|
|
<Typography.Text>{generatedObject.paylink}</Typography.Text>
|
|
|
|
|
</Flex>
|
|
|
|
|
</Col>
|
|
|
|
|
{contextHolder}
|
|
|
|
|