添加is-vip
This commit is contained in:
@@ -6,7 +6,7 @@ import avatar from "../../assets/avatar.png";
|
||||
import semicircle from "../../assets/semicircle.png";
|
||||
import BackButton from "../../components/BackButton";
|
||||
import ConfirmButton from "../../components/ConfirmButton";
|
||||
import { getPatientInfo, PatientInfo } from "../../api/hisApi";
|
||||
import { getPatientInfo, getVipStatus, PatientInfo } from "../../api/hisApi";
|
||||
|
||||
const U2: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
@@ -14,6 +14,8 @@ const U2: React.FC = () => {
|
||||
const idCardNo = localStorage.getItem("lastIdCardNo");
|
||||
const [patientInfo, setPatientInfo] = useState<PatientInfo | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVip, setIsVip] = useState<number | null>(null);
|
||||
const vipCalledRef = React.useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (idCardNo) {
|
||||
@@ -36,14 +38,33 @@ const U2: React.FC = () => {
|
||||
}
|
||||
}, [idCardNo]);
|
||||
|
||||
// 获取 VIP 状态,避免重复请求(用 ref 保护)
|
||||
useEffect(() => {
|
||||
if (!idCardNo) return;
|
||||
if (vipCalledRef.current) return;
|
||||
vipCalledRef.current = true;
|
||||
getVipStatus(idCardNo)
|
||||
.then((res) => {
|
||||
if (res.Status === 200) {
|
||||
setIsVip(res.Data?.is_vip ?? 0);
|
||||
} else {
|
||||
console.warn("获取 VIP 状态失败:", res.Message);
|
||||
setIsVip(0);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("getVipStatus error", err);
|
||||
setIsVip(0);
|
||||
});
|
||||
}, [idCardNo]);
|
||||
|
||||
const handleBack = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
|
||||
const handleConfirm = () => {
|
||||
//判断是否为太平VIP客户
|
||||
const isVIP = true; // 这里可以替换为实际的判断逻辑
|
||||
if (isVIP) {
|
||||
// 判断是否为 VIP 客户(0 否,1 是)
|
||||
if (isVip === 1) {
|
||||
navigate("/u3");
|
||||
return;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user