This commit is contained in:
lyp 2025-06-23 17:59:26 +08:00
parent 3b9c88dfc9
commit 67a5103a2c
4 changed files with 174 additions and 69 deletions

View File

@ -204,5 +204,9 @@ export const updateTrademarkApplicant = (trademarkUserId:any,params:any) => aiSh
// 提交申请人
export const submitTrademarkApplicant = (trademarkId:any,params:any) => aiShopRequest.post(`/aishop/api/trademark/save3/${trademarkId}`,params)
// 第四步
// 订单支付
export const orderPay = (trademarkId:any) => aiShopRequest.post(`/aishop/api/trademark/save4/${trademarkId}`)
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -247,6 +247,8 @@ export default function TrademarkAiEdit() {
}}>
<EditThree
// key={editProcess}
editThreeData={editThreeData}
setEditThreeData={setEditThreeData}
trademarkId={trademarkId}
setEditProcess={setEditProcess}></EditThree>
</div>
@ -255,6 +257,7 @@ export default function TrademarkAiEdit() {
}}>
<EditFour
// key={editProcess}
trademarkId={trademarkId}
setEditProcess={setEditProcess}></EditFour>
</div>
<div style={{

View File

@ -1,6 +1,9 @@
import { useState } from 'react'
import { useState, useContext } from 'react'
import './edit-four.css'
import { Button, Table, Modal } from 'antd'
import { Button, Table, Modal, message, Spin } from 'antd'
import { orderPay } from '../../../../request/api'
// import { GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts";
import { GlobalDispatchContext, reloadUser } from "../../../../context/GlobalContext";
import type { TableProps } from 'antd';
interface DataType {
id: string;
@ -12,7 +15,43 @@ interface DataType {
price: string; //单价
num: string; //数量
}
import useMessage from "antd/es/message/useMessage";
export default function EditFour(props: any) {
const globalDispatchContext = useContext(GlobalDispatchContext);
const [messageApi, contextHolder] = useMessage();
const [payLodaing, setPayLodaing] = useState(false)
const postOrderPay = async () => {
try {
setModal(false)
setPayLodaing(true)
const res = await orderPay(props.trademarkId)
console.log(res);
reloadUser(messageApi, globalDispatchContext).then(() => {
message.success('付款成功');
});
setPayLodaing(false)
} catch (error: any) {
setModal(false)
setPayLodaing(false)
if (error.response) {
const data = error.response.data;
messageApi.open({
type: 'error',
content: data.msg ? data.msg : `${data.path}(${data.status})`,
});
} else {
console.error(error)
}
} finally {
setPayLodaing(false)
setModal(false)
}
}
const columns: TableProps<DataType>['columns'] = [
{
align: 'center',
@ -106,76 +145,89 @@ export default function EditFour(props: any) {
};
return (
<div className='editOneTwo'>
<div className='topLine'></div>
<div className='editFourBox' style={{
height: height,
// background: 'pink'
}}>
<div className='editFourTop'>
<div className='editFourTopL'></div>
<div className='editFourTopR'>
<span>数量 : 2</span>
<span style={{
marginLeft: '10px',
}}><span style={{
color: 'red',
}}>630.66</span></span>
<Spin tip="正在付款,请稍后..." size="small" spinning={payLodaing}>
<div className='editOneTwo'>
{contextHolder}
<div className='topLine'></div>
<div className='editFourBox' style={{
height: height,
// background: 'pink'
}}>
<div className='editFourTop'>
<div className='editFourTopL'></div>
<div className='editFourTopR'>
<span>数量 : 2</span>
<span style={{
marginLeft: '10px',
}}><span style={{
color: 'red',
}}>630.66</span></span>
</div>
</div>
</div>
<Table<DataType> columns={columns}
// 取消自带分页
pagination={false}
dataSource={data}
rowKey='id'
<Table<DataType> columns={columns}
// 取消自带分页
pagination={false}
dataSource={data}
rowKey='id'
/>
</div>
<div className='topLine'></div>
<div style={{
marginTop: '8px',
display: 'flex',
justifyContent: 'flex-end',
}}>
<Button
style={{
width: '100px',
height: '40px',
borderRadius: '5px',
}}
onClick={() => {
props.setEditProcess(3)
}}
></Button>
<Button
type='primary'
style={{
width: '100px',
height: '40px',
borderRadius: '5px',
marginLeft: '10px',
}}
onClick={() => {
handleSubmit()
}}
></Button>
</div>
<Modal title="提示"
centered
destroyOnClose={true}
open={modal}
onCancel={() => { setModal(false) }}
okText='确定'
cancelText='取消'
onOk={() => {
// setModal(false)
// props.setEditProcess(5)
postOrderPay()
}}
okButtonProps={{
disabled: payLodaing
}}
// 设置取消按钮属性payLodaing 为 true 时禁用
cancelButtonProps={{
disabled: payLodaing
}}
>
999,
</Modal>
</div>
<div className='topLine'></div>
<div style={{
marginTop: '8px',
display: 'flex',
justifyContent: 'flex-end',
}}>
<Button
style={{
width: '100px',
height: '40px',
borderRadius: '5px',
}}
onClick={() => {
props.setEditProcess(3)
}}
></Button>
<Button
type='primary'
style={{
width: '100px',
height: '40px',
borderRadius: '5px',
marginLeft: '10px',
}}
onClick={() => {
handleSubmit()
}}
></Button>
</div>
<Modal title="提示"
centered
destroyOnClose={true}
open={modal}
onCancel={() => { setModal(false) }}
okText='确定'
cancelText='取消'
onOk={()=>{
setModal(false)
props.setEditProcess(5)
}}
>
999
</Modal>
</div>
</Spin>
)
}

View File

@ -30,6 +30,7 @@ import useMessage from "antd/es/message/useMessage";
const { Search } = Input;
export default function EditThree(props: any) {
// 申请人信息
// const [applicantData, setApplicantData] = useState({
// name: '',
// trademarkUserId: '',
@ -151,6 +152,15 @@ export default function EditThree(props: any) {
trademarkUserId: '',
name: '',
});
useEffect(() => {
if (props.editThreeData.trademarkUserId) {
setConfirmSelectPeopleData({
trademarkUserId: props.editThreeData.trademarkUserId,
name: props.editThreeData.name,
})
}
}, [props.editThreeData])
const [disabled, setDisabled] = useState(false)
const [showBtn, setShowBtn] = useState(true)
const columns: TableColumnsType<any> = [
@ -624,7 +634,40 @@ export default function EditThree(props: any) {
}
const [subLoading, setSubLoading] = useState(false)
function deepCompareObjects(obj1: any, obj2: any): boolean {
// 若两个值严格相等,直接返回 true
if (obj1 === obj2) {
return true;
}
// 若其中一个值为 null 或不是对象类型,返回 false
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
return false;
}
// 获取两个对象的键数组
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
// 若键的数量不同,返回 false
if (keys1.length !== keys2.length) {
return false;
}
// 遍历键,递归比较对应的值
for (const key of keys1) {
if (!keys2.includes(key) || !deepCompareObjects(obj1[key], obj2[key])) {
return false;
}
}
return true;
}
const handleSubmit = async () => {
if (deepCompareObjects(confirmSelectPeopleData, props.editThreeData)) {
props.setEditProcess(4);
return;
}
// formA.submit();
// props.setEditProcess(4);
// console.log(confirmSelectPeopleData);
@ -637,7 +680,10 @@ export default function EditThree(props: any) {
})
setSubLoading(false)
props.setEditProcess(4);
props.setEditThreeData({
trademarkUserId: confirmSelectPeopleData.trademarkUserId,
name: confirmSelectPeopleData.name,
})
} catch (error: any) {
setSubLoading(false)
if (error.response) {