import React, { FC, useEffect, useState } from "react"; import { withRouter, RouteComponentProps } from "react-router-dom"; import { Typography, Button, Checkbox, message } from "antd"; import { CodeInput } from "@/components/CustComponents"; import { ConfirmParams } from "@/api/service/PurchaseService"; import MainLayout from "@/layout"; import Api from "@/api"; import "./index.scss"; import { HTTP_STATUS } from "@/shared/common/constants"; type P = RouteComponentProps & {}; const { Paragraph, Text, Title } = Typography; const PaymentConfirm: FC
= props => {
const [contextId, setContextId] = useState("");
const [code, setCode] = useState("");
const [entity, setEntity] = useState(null);
const [agreement, setAgreement] = useState(false);
useEffect(() => {
const { state } = props.location;
if (state && state.contextId) {
const contextId = state.contextId;
setContextId(contextId);
console.log({ contextId });
Api.purchase
.getConfirmParams({ contextId: encodeURIComponent(contextId) })
.then(r => {
console.log({ r });
setEntity(r.data);
});
}
}, []);
const handelChange = e => {
setCode(e.target.value);
};
const onCancel = () => {
props.history.goBack();
};
const onSubmit = () => {
if (contextId && code) {
const params = {
contextId,
verifyCode: code
};
console.log({ params });
Api.purchase.confirm(params).then(r => {
console.log(r);
if (HTTP_STATUS.SUCCESSS === r.code) {
message.success("订单确认成功");
props.history.push("/order");
} else {
message.error(r.message);
}
});
} else {
message.error("请输入验证码");
}
};
return (