更新 VIP 状态接口为 is-taiping-vip,添加获取可选套餐逻辑

This commit is contained in:
yuchenglong
2025-11-25 10:04:25 +08:00
parent 1c50b7be73
commit 4cd4e844f5
5 changed files with 116 additions and 45 deletions

View File

@@ -163,9 +163,12 @@ export async function getPatientInfo(
export async function getVipStatus( export async function getVipStatus(
id_no: string id_no: string
): Promise<ApiResponse<VipResult>> { ): Promise<ApiResponse<VipResult>> {
const response = await axiosInstance.post<ApiResponse<VipResult>>("is-vip", { const response = await axiosInstance.post<ApiResponse<VipResult>>(
"is-taiping-vip",
{
id_no, id_no,
}); }
);
return response.data; return response.data;
} }

View File

@@ -6,11 +6,15 @@ import avatar from "../../assets/avatar.png";
import semicircle from "../../assets/semicircle.png"; import semicircle from "../../assets/semicircle.png";
import BackButton from "../../components/BackButton"; import BackButton from "../../components/BackButton";
import ConfirmButton from "../../components/ConfirmButton"; import ConfirmButton from "../../components/ConfirmButton";
import { getPatientInfo, getVipStatus, PatientInfo } from "../../api/hisApi"; import {
getPatientInfo,
getVipStatus,
getOptionalItemList,
PatientInfo,
} from "../../api/hisApi";
const U2: React.FC = () => { const U2: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
// 不再通过路由传参,直接从 localStorage 读取上次保存的身份证号
const idCardNo = localStorage.getItem("lastIdCardNo"); const idCardNo = localStorage.getItem("lastIdCardNo");
const [patientInfo, setPatientInfo] = useState<PatientInfo | null>(null); const [patientInfo, setPatientInfo] = useState<PatientInfo | null>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -38,7 +42,7 @@ const U2: React.FC = () => {
} }
}, [idCardNo]); }, [idCardNo]);
// 获取 VIP 状态,避免重复请求(用 ref 保护) // 获取 VIP 状态,避免重复请求
useEffect(() => { useEffect(() => {
if (!idCardNo) return; if (!idCardNo) return;
if (vipCalledRef.current) return; if (vipCalledRef.current) return;
@@ -63,19 +67,46 @@ const U2: React.FC = () => {
}; };
const handleConfirm = () => { const handleConfirm = () => {
if (!idCardNo) {
alert("未获取到身份证号,请重新刷卡");
navigate("/");
return;
}
// 判断是否为 VIP 客户0 否1 是) // 判断是否为 VIP 客户0 否1 是)
if (isVip === 1) { if (isVip === 1) {
navigate("/u3"); navigate("/u3");
return; return;
} else { }
// 是否套餐待定
const isPackageUndecided = false; // 这里可以替换为实际的判断逻辑 // 调用接口判断是否有可选套餐
getOptionalItemList(idCardNo)
.then((res) => {
if (res.Status === 200) {
const isPackageUndecided =
res.Data?.packageInfo?.is_optional_package === 1;
if (isPackageUndecided) { if (isPackageUndecided) {
navigate("/u4"); navigate("/u4", { state: { optionalData: res.Data } });
} else {
// 如果没有可选套餐,检查是否有错误消息需要提示
if (!res.Data?.packageInfo && res.Message) {
alert(res.Message);
} else { } else {
navigate("/u5"); navigate("/u5");
} }
} }
} else {
if (res.Message) {
alert(res.Message);
} else {
navigate("/u5");
}
}
})
.catch((err) => {
console.error("getOptionalItemList error", err);
navigate("/u5");
});
}; };
return ( return (

View File

@@ -2,6 +2,7 @@ import React from "react";
import "./u3.css"; import "./u3.css";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import DecorLine from "../../components/DecorLine"; import DecorLine from "../../components/DecorLine";
import { getOptionalItemList } from "../../api/hisApi";
import BackButton from "../../components/BackButton"; import BackButton from "../../components/BackButton";
import ConfirmButton from "../../components/ConfirmButton"; import ConfirmButton from "../../components/ConfirmButton";
@@ -16,13 +17,40 @@ const U3: React.FC = () => {
}; };
const handleConfirm = () => { const handleConfirm = () => {
// 是否套餐待定 // 根据本地身份证号检查是否有可选套餐
const isPackageUndecided = true; const idCardNo = localStorage.getItem("lastIdCardNo");
if (isPackageUndecided) { if (!idCardNo) {
navigate("/u4"); // 没有身份证号,直接跳转到下一步
navigate("/u5");
return;
}
// 调用接口判断是否有可选套餐
getOptionalItemList(idCardNo)
.then((res) => {
if (res.Status === 200) {
if (res.Data?.packageInfo?.is_optional_package === 1) {
navigate("/u4", { state: { optionalData: res.Data } });
} else {
// 如果没有可选套餐,检查是否有错误消息需要提示
if (!res.Data?.packageInfo && res.Message) {
alert(res.Message);
} else { } else {
navigate("/u5"); navigate("/u5");
} }
}
} else {
if (res.Message) {
alert(res.Message);
} else {
navigate("/u5");
}
}
})
.catch((err) => {
console.error("getOptionalItemList error", err);
navigate("/u5");
});
}; };
return ( return (

View File

@@ -61,6 +61,9 @@
flex-direction: column; flex-direction: column;
gap: 30px; gap: 30px;
cursor: pointer; cursor: pointer;
position: relative;
justify-content: center;
align-items: center;
} }
.u4-card:hover { .u4-card:hover {
@@ -76,6 +79,8 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 12px;
justify-content: center;
width: 100%;
} }
.u4-radio { .u4-radio {
@@ -83,12 +88,22 @@
height: 34px; height: 34px;
display: block; display: block;
object-fit: contain; object-fit: contain;
position: absolute;
top: 40px;
left: 40px;
} }
.u4-card-title { .u4-card-title {
font-size: 36px; font-size: 34px;
color: rgba(0, 45, 93, 0.95); color: rgba(0, 45, 93, 0.95);
font-weight: 700; font-weight: 700;
text-align: center;
white-space: normal;
word-break: break-word;
overflow-wrap: break-word;
line-height: 1.4;
margin-top: 8px;
margin-bottom: 8px;
} }
.u4-card-body { .u4-card-body {

View File

@@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import "./u4.css"; import "./u4.css";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useLocation } from "react-router-dom";
import DecorLine from "../../components/DecorLine"; import DecorLine from "../../components/DecorLine";
import LongButton from "../../components/LongButton"; import LongButton from "../../components/LongButton";
import radio0 from "../../assets/radio-0.png"; import radio0 from "../../assets/radio-0.png";
@@ -14,25 +15,29 @@ interface testType {
const U4: React.FC = () => { const U4: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation();
const optionalData = (location.state as any)?.optionalData;
const [test, setTest] = React.useState<testType[]>([]); const [test, setTest] = React.useState<testType[]>([]);
const handleConfirm = () => { const handleConfirm = () => {
navigate("/UI6"); navigate("/UI6");
}; };
React.useEffect(() => { React.useEffect(() => {
setTest([ if (
{ optionalData &&
id: 1, optionalData.listOptionalItem &&
title: "乳腺 B 超", optionalData.listOptionalItem.length
desc: "适合 40 岁", ) {
taboo: "无特别限制", const items = optionalData.listOptionalItem.map((it: any) => ({
}, id: it.combination_code,
{ title: it.combination_name,
id: 2, desc: "",
title: "乳腺钼靶", taboo: "",
desc: "适合40岁以上", }));
taboo: "孕期、哺乳期", setTest(items);
}, } else {
]); alert("未获取到可选套餐信息,无需选择套餐");
navigate("/UI6");
}
}, []); }, []);
const [selectedId, setSelectedId] = React.useState<number | null>(1); const [selectedId, setSelectedId] = React.useState<number | null>(1);
@@ -61,17 +66,6 @@ const U4: React.FC = () => {
/> />
<div className="u4-card-title">{t.title}</div> <div className="u4-card-title">{t.title}</div>
</div> </div>
<div className="u4-card-body">
<div className="u4-detail-row">
<div className="u4-detail-bar" />
<div className="u4-detail-text">{t.desc}</div>
</div>
<div className="u4-detail-row">
<div className="u4-detail-bar" />
<div className="u4-detail-text">{t.taboo}</div>
</div>
</div>
</div> </div>
))} ))}
</div> </div>