fix;合并修复问题
This commit is contained in:
@@ -9,6 +9,7 @@ import ChinaRegionPicker from '../components/ChinaRegionPicker';
|
||||
import OssUploadField from '../components/OssUploadField';
|
||||
|
||||
import { request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
|
||||
import { resolveRegionBinding } from '../lib/china-region';
|
||||
|
||||
@@ -96,7 +97,10 @@ export default function StoreCreatePage() {
|
||||
|
||||
const [wechatReady, setWechatReady] = useState(false);
|
||||
|
||||
|
||||
function reportFormError(message: string) {
|
||||
setSubmitError(message);
|
||||
toastError(message);
|
||||
}
|
||||
|
||||
const stepFromUrl = Number(params.get('step') || 0);
|
||||
|
||||
@@ -176,7 +180,7 @@ export default function StoreCreatePage() {
|
||||
|
||||
})
|
||||
|
||||
.catch((e) => setSubmitError(e instanceof Error ? e.message : '微信授权失败'));
|
||||
.catch((e) => reportFormError(e instanceof Error ? e.message : '微信授权失败'));
|
||||
|
||||
}, [params, setParams]);
|
||||
|
||||
@@ -194,7 +198,11 @@ export default function StoreCreatePage() {
|
||||
|
||||
})
|
||||
|
||||
.catch((e) => setCitiesError(e instanceof Error ? e.message : '加载开城城市失败'));
|
||||
.catch((e) => {
|
||||
const msg = e instanceof Error ? e.message : '加载开城城市失败';
|
||||
setCitiesError(msg);
|
||||
toastError(msg);
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
@@ -283,11 +291,8 @@ export default function StoreCreatePage() {
|
||||
const msg = validateStoreStep1(form);
|
||||
|
||||
if (msg) {
|
||||
|
||||
setSubmitError(msg);
|
||||
|
||||
reportFormError(msg);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
setCheckingPhone(true);
|
||||
@@ -301,21 +306,13 @@ export default function StoreCreatePage() {
|
||||
const phoneCheck = await checkStorePhoneAvailable(form.phone.trim());
|
||||
|
||||
if (!phoneCheck.available) {
|
||||
|
||||
setFieldErrors({
|
||||
|
||||
phone: phoneCheck.message ?? '该手机号已绑定门店,请更换',
|
||||
|
||||
});
|
||||
|
||||
const phoneMsg = phoneCheck.message ?? '该手机号已绑定门店,请更换';
|
||||
setFieldErrors({ phone: phoneMsg });
|
||||
toastError(phoneMsg);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
||||
setSubmitError(e instanceof Error ? e.message : '手机号校验失败');
|
||||
|
||||
} catch {
|
||||
return;
|
||||
|
||||
} finally {
|
||||
@@ -331,11 +328,8 @@ export default function StoreCreatePage() {
|
||||
const msg = validateStoreStep2(form);
|
||||
|
||||
if (msg) {
|
||||
|
||||
setSubmitError(msg);
|
||||
|
||||
reportFormError(msg);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -351,39 +345,32 @@ export default function StoreCreatePage() {
|
||||
const msg = validateStoreStep3(form);
|
||||
|
||||
if (msg) {
|
||||
|
||||
setSubmitError(msg);
|
||||
|
||||
reportFormError(msg);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const step1Msg = validateStoreStep1(form);
|
||||
|
||||
if (step1Msg) {
|
||||
|
||||
setSubmitError(step1Msg);
|
||||
|
||||
reportFormError(step1Msg);
|
||||
goStep(1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^\d+$/.test(form.cityId.trim())) {
|
||||
reportFormError('所选地区未匹配到开城城市,请重新选择');
|
||||
goStep(1);
|
||||
return;
|
||||
}
|
||||
|
||||
const step2Msg = validateStoreStep2(form);
|
||||
|
||||
if (step2Msg) {
|
||||
|
||||
setSubmitError(step2Msg);
|
||||
|
||||
reportFormError(step2Msg);
|
||||
goStep(2);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
setSubmitting(true);
|
||||
|
||||
setSubmitError('');
|
||||
@@ -451,25 +438,17 @@ export default function StoreCreatePage() {
|
||||
});
|
||||
|
||||
clearStoreDraft();
|
||||
|
||||
toastSuccess('门店录入成功');
|
||||
navigate(`/stores/${result.store.id}`);
|
||||
|
||||
} catch (e) {
|
||||
|
||||
const message = e instanceof Error ? e.message : '提交失败';
|
||||
|
||||
if (isPhoneConflictMessage(message)) {
|
||||
|
||||
setFieldErrors({ phone: message });
|
||||
|
||||
toastError(message);
|
||||
goStep(1);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
setSubmitError(message);
|
||||
|
||||
} finally {
|
||||
|
||||
setSubmitting(false);
|
||||
|
||||
Reference in New Issue
Block a user