更新 VIP 状态接口为 is-taiping-vip,添加获取可选套餐逻辑
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user