v4.0.18版本提交

This commit is contained in:
2026-09-08 10:07:34 +08:00
parent 4bdb09068c
commit 23ba639e9b
46 changed files with 1922 additions and 162 deletions
+19 -13
View File
@@ -17,19 +17,25 @@ export function storeStarCount(rating?: number | string | null): number {
return Math.min(5, Math.max(1, Math.round(n)));
}
/** 省市区县 + 详细地址 拼接;空则回退占位文案 */
export function fullStoreAddress(
store: {
province?: string | null;
cityName?: string | null;
city?: string | null;
district?: string | null;
address?: string | null;
},
fallback = '地址待完善',
): string {
const city = store.cityName || store.city || '';
const text = `${store.province || ''}${city}${store.district || ''}${store.address || ''}`.trim();
export type StoreAddressParts = {
province?: string | null;
cityName?: string | null;
city?: string | null;
district?: string | null;
address?: string | null;
};
function addressPart(value: unknown): string {
return typeof value === 'string' ? value.trim() : '';
}
/** 省 + 市 + 区 + 详细地址原样拼接;详细地址已含省市区时不去重 */
export function fullStoreAddress(store: StoreAddressParts, fallback = '地址待完善'): string {
const province = addressPart(store.province);
const city = addressPart(store.cityName) || addressPart(store.city);
const district = addressPart(store.district);
const detail = addressPart(store.address);
const text = `${province}${city}${district}${detail}`;
return text || fallback;
}
@@ -21,6 +21,7 @@ import { toMoneyNumber } from '../../lib/money';
import { maskPhone, toDialablePhone } from '../../lib/phone';
import { track } from '../../lib/analytics';
import {
fullStoreAddress,
storeCategoryTags,
storeStarCount,
type StoreCategoryTreeNode,
@@ -115,8 +116,7 @@ function envPhotoUrls(store: Store) {
}
function fullAddress(store: Store) {
const city = store.cityName || store.city || '';
return `${store.province || ''}${city}${store.district || ''}${store.address || ''}`.trim();
return fullStoreAddress(store, '');
}
function pickStoreId(raw?: string | null) {
@@ -447,8 +447,7 @@ export default function StoreDetailPage() {
<View className="store-detail-row">
<Text className="store-detail-meta store-detail-meta--flex">
{store.district ? `${store.district} · ` : ''}
{store.address || '地址待完善'}
{fullStoreAddress(store)}
</Text>
<Text className="store-detail-action" onClick={openMap}>
@@ -177,6 +177,7 @@
flex: 1;
min-width: 0;
margin-bottom: 0;
word-break: break-word;
}
.store-detail-row {