更新 VIP 状态接口为 is-taiping-vip,添加获取可选套餐逻辑
This commit is contained in:
@@ -163,9 +163,12 @@ export async function getPatientInfo(
|
||||
export async function getVipStatus(
|
||||
id_no: string
|
||||
): Promise<ApiResponse<VipResult>> {
|
||||
const response = await axiosInstance.post<ApiResponse<VipResult>>("is-vip", {
|
||||
id_no,
|
||||
});
|
||||
const response = await axiosInstance.post<ApiResponse<VipResult>>(
|
||||
"is-taiping-vip",
|
||||
{
|
||||
id_no,
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,15 @@ import avatar from "../../assets/avatar.png";
|
||||
import semicircle from "../../assets/semicircle.png";
|
||||
import BackButton from "../../components/BackButton";
|
||||
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 navigate = useNavigate();
|
||||
// 不再通过路由传参,直接从 localStorage 读取上次保存的身份证号
|
||||
const idCardNo = localStorage.getItem("lastIdCardNo");
|
||||
const [patientInfo, setPatientInfo] = useState<PatientInfo | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -38,7 +42,7 @@ const U2: React.FC = () => {
|
||||
}
|
||||
}, [idCardNo]);
|
||||
|
||||
// 获取 VIP 状态,避免重复请求(用 ref 保护)
|
||||
// 获取 VIP 状态,避免重复请求
|
||||
useEffect(() => {
|
||||
if (!idCardNo) return;
|
||||
if (vipCalledRef.current) return;
|
||||
@@ -63,19 +67,46 @@ const U2: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleConfirm = () => {
|
||||
if (!idCardNo) {
|
||||
alert("未获取到身份证号,请重新刷卡");
|
||||
navigate("/");
|
||||
return;
|
||||
}
|
||||
|
||||
// 判断是否为 VIP 客户(0 否,1 是)
|
||||
if (isVip === 1) {
|
||||
navigate("/u3");
|
||||
return;
|
||||
} else {
|
||||
// 是否套餐待定
|
||||
const isPackageUndecided = false; // 这里可以替换为实际的判断逻辑
|
||||
if (isPackageUndecided) {
|
||||
navigate("/u4");
|
||||
} else {
|
||||
navigate("/u5");
|
||||
}
|
||||
}
|
||||
|
||||
// 调用接口判断是否有可选套餐
|
||||
getOptionalItemList(idCardNo)
|
||||
.then((res) => {
|
||||
if (res.Status === 200) {
|
||||
const isPackageUndecided =
|
||||
res.Data?.packageInfo?.is_optional_package === 1;
|
||||
if (isPackageUndecided) {
|
||||
navigate("/u4", { state: { optionalData: res.Data } });
|
||||
} else {
|
||||
// 如果没有可选套餐,检查是否有错误消息需要提示
|
||||
if (!res.Data?.packageInfo && res.Message) {
|
||||
alert(res.Message);
|
||||
} else {
|
||||
navigate("/u5");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (res.Message) {
|
||||
alert(res.Message);
|
||||
} else {
|
||||
navigate("/u5");
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("getOptionalItemList error", err);
|
||||
navigate("/u5");
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,6 +2,7 @@ import React from "react";
|
||||
import "./u3.css";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import DecorLine from "../../components/DecorLine";
|
||||
import { getOptionalItemList } from "../../api/hisApi";
|
||||
|
||||
import BackButton from "../../components/BackButton";
|
||||
import ConfirmButton from "../../components/ConfirmButton";
|
||||
@@ -16,13 +17,40 @@ const U3: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleConfirm = () => {
|
||||
// 是否套餐待定
|
||||
const isPackageUndecided = true;
|
||||
if (isPackageUndecided) {
|
||||
navigate("/u4");
|
||||
} else {
|
||||
// 根据本地身份证号检查是否有可选套餐
|
||||
const idCardNo = localStorage.getItem("lastIdCardNo");
|
||||
if (!idCardNo) {
|
||||
// 没有身份证号,直接跳转到下一步
|
||||
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 {
|
||||
navigate("/u5");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (res.Message) {
|
||||
alert(res.Message);
|
||||
} else {
|
||||
navigate("/u5");
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("getOptionalItemList error", err);
|
||||
navigate("/u5");
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
flex-direction: column;
|
||||
gap: 30px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.u4-card:hover {
|
||||
@@ -76,6 +79,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.u4-radio {
|
||||
@@ -83,12 +88,22 @@
|
||||
height: 34px;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.u4-card-title {
|
||||
font-size: 36px;
|
||||
font-size: 34px;
|
||||
color: rgba(0, 45, 93, 0.95);
|
||||
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 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from "react";
|
||||
import "./u4.css";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import DecorLine from "../../components/DecorLine";
|
||||
import LongButton from "../../components/LongButton";
|
||||
import radio0 from "../../assets/radio-0.png";
|
||||
@@ -14,25 +15,29 @@ interface testType {
|
||||
|
||||
const U4: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const optionalData = (location.state as any)?.optionalData;
|
||||
const [test, setTest] = React.useState<testType[]>([]);
|
||||
const handleConfirm = () => {
|
||||
navigate("/UI6");
|
||||
};
|
||||
React.useEffect(() => {
|
||||
setTest([
|
||||
{
|
||||
id: 1,
|
||||
title: "乳腺 B 超",
|
||||
desc: "适合 40 岁",
|
||||
taboo: "无特别限制",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "乳腺钼靶",
|
||||
desc: "适合40岁以上",
|
||||
taboo: "孕期、哺乳期",
|
||||
},
|
||||
]);
|
||||
if (
|
||||
optionalData &&
|
||||
optionalData.listOptionalItem &&
|
||||
optionalData.listOptionalItem.length
|
||||
) {
|
||||
const items = optionalData.listOptionalItem.map((it: any) => ({
|
||||
id: it.combination_code,
|
||||
title: it.combination_name,
|
||||
desc: "",
|
||||
taboo: "",
|
||||
}));
|
||||
setTest(items);
|
||||
} else {
|
||||
alert("未获取到可选套餐信息,无需选择套餐");
|
||||
navigate("/UI6");
|
||||
}
|
||||
}, []);
|
||||
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>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user