修改湖畔社区页面显示数据的逻辑

This commit is contained in:
赵毅 2025-10-17 09:18:49 +08:00
parent 71332e070a
commit e4a21804b0

View File

@ -124,9 +124,9 @@ export default {
return item;
});
// 过滤出距离1km以内的数据
// 过滤出距离1km以内的数据,确保距离为0的值也能被正确保留
processedList = processedList.filter(item =>
item.distanceValue && item.distanceValue <= 1
item.distanceValue !== undefined && item.distanceValue !== null && item.distanceValue <= 1
);
// 调用腾讯地图API获取附近1km的小区(包含图片信息)
@ -179,10 +179,10 @@ export default {
mergedList = uniqueByField(mergedList, 'community_id');
}
// 根据距离排序
// 根据距离排序,确保距离为0的值也能正确排序
mergedList.sort((a, b) => {
const distanceA = a.distanceValue || Infinity;
const distanceB = b.distanceValue || Infinity;
const distanceA = a.distanceValue !== undefined && a.distanceValue !== null ? a.distanceValue : Infinity;
const distanceB = b.distanceValue !== undefined && b.distanceValue !== null ? b.distanceValue : Infinity;
return distanceA - distanceB;
});