export const STORE_ADDRESS_FALLBACK = '地址待完善'; export type StoreAddressParts = { province?: string | null; cityName?: string | null; city?: string | null; district?: string | null; address?: string | null; }; function textPart(value: unknown): string { return typeof value === 'string' ? value.trim() : ''; } /** * 门店展示地址:省 + 市 + 区 + 详细地址,按字段原样拼接。 * 省/市/区来自下拉选择,详细地址来自自由输入;即使详细地址已含省市区也不得去重。 */ export function formatStoreDisplayAddress( store: StoreAddressParts, fallback = STORE_ADDRESS_FALLBACK, ): string { const province = textPart(store.province); const city = textPart(store.cityName) || textPart(store.city); const district = textPart(store.district); const detail = textPart(store.address); const text = `${province}${city}${district}${detail}`; return text || fallback; }