门店开通流程

This commit is contained in:
2026-07-03 14:53:21 +08:00
parent c7dc6a2274
commit f2175b83f7
24 changed files with 1451 additions and 186 deletions
+49 -7
View File
@@ -1,9 +1,18 @@
export type StoreDraftForm = {
regionCodes: string[];
cityId: string;
province: string;
city: string;
district: string;
name: string;
phone: string;
district: string;
address: string;
intro: string;
accountPhone: string;
accountName: string;
coverUrl: string;
envPhotoUrls: string[];
contractUrl: string;
bankAccountName: string;
bankAccountNo: string;
bankBranch: string;
@@ -14,27 +23,55 @@ export type StoreDraft = {
form: StoreDraftForm;
};
export const STORE_DRAFT_KEY = 'partner_store_draft_v1';
export const STORE_DRAFT_KEY = 'partner_store_draft_v2';
export const defaultStoreForm = (): StoreDraftForm => ({
regionCodes: [],
cityId: '',
province: '',
city: '',
district: '',
name: '',
phone: '',
district: '金水区',
address: '',
intro: '',
accountPhone: '',
accountName: '',
coverUrl: '',
envPhotoUrls: ['', '', ''],
contractUrl: '',
bankAccountName: '',
bankAccountNo: '',
bankBranch: '',
});
function normalizeStringArray(raw: unknown, length: number): string[] {
if (!Array.isArray(raw)) return Array.from({ length }, () => '');
const items = raw.map((item) => String(item ?? ''));
while (items.length < length) items.push('');
return items.slice(0, length);
}
function normalizeForm(raw: Record<string, unknown>): StoreDraftForm {
const base = defaultStoreForm();
const regionCodes = Array.isArray(raw.regionCodes)
? raw.regionCodes.map((code) => String(code))
: base.regionCodes;
return {
regionCodes,
cityId: String(raw.cityId ?? base.cityId),
province: String(raw.province ?? base.province),
city: String(raw.city ?? base.city),
district: String(raw.district ?? base.district),
name: String(raw.name ?? base.name),
phone: String(raw.phone ?? base.phone),
district: String(raw.district ?? base.district),
address: String(raw.address ?? base.address),
intro: String(raw.intro ?? base.intro),
accountPhone: String(raw.accountPhone ?? base.accountPhone),
accountName: String(raw.accountName ?? base.accountName),
coverUrl: String(raw.coverUrl ?? base.coverUrl),
envPhotoUrls: normalizeStringArray(raw.envPhotoUrls, 3),
contractUrl: String(raw.contractUrl ?? base.contractUrl),
bankAccountName: String(raw.bankAccountName ?? base.bankAccountName),
bankAccountNo: String(raw.bankAccountNo ?? base.bankAccountNo),
bankBranch: String(raw.bankBranch ?? base.bankBranch),
@@ -69,11 +106,14 @@ export function clearStoreDraft() {
const PHONE_RE = /^1\d{10}$/;
const BANK_RE = /^\d{16,19}$/;
export function validateStoreStep1(form: StoreDraftForm): string | null {
export function validateStoreStep1(
form: Pick<StoreDraftForm, 'regionCodes' | 'cityId' | 'name' | 'phone' | 'address' | 'intro'>,
): string | null {
if (!form.regionCodes || form.regionCodes.length < 3) return '请选择省 / 市 / 区县';
if (!form.cityId) return '所选地区未匹配到开城城市,请联系总部配置开城区划';
if (!form.name.trim()) return '请填写门店名称';
if (!form.phone.trim()) return '请填写联系电话';
if (!PHONE_RE.test(form.phone.trim())) return '联系电话须为11位手机号';
if (!form.district.trim()) return '请填写区县';
if (!form.address.trim()) return '请填写详细地址';
if (form.intro.trim()) {
const len = form.intro.trim().length;
@@ -82,7 +122,9 @@ export function validateStoreStep1(form: StoreDraftForm): string | null {
return null;
}
export function validateStoreStep3(form: StoreDraftForm): string | null {
export function validateStoreStep3(
form: Pick<StoreDraftForm, 'bankAccountName' | 'bankAccountNo' | 'bankBranch'>,
): string | null {
if (!form.bankAccountName.trim()) return '请填写户主姓名';
if (!form.bankAccountNo.trim()) return '请填写银行卡号';
if (!BANK_RE.test(form.bankAccountNo.replace(/\s/g, ''))) return '银行卡号须为 16~19 位数字';