From 049b2396c3364a8d6948886cce10e175c7bbdaa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 25 Feb 2026 12:42:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(address):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=9C=B0=E7=90=86=E4=BD=8D=E7=BD=AE=E8=8E=B7=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E4=BC=98=E5=8C=96=E9=BB=98=E8=AE=A4=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 getCurrentLngLat 工具函数的导入和使用 - 简化 onDefault 函数中的默认地址检查逻辑 - 移除地址更新时的经纬度参数传递 - 优化 selectAddress 函数中的导航回退逻辑 - 使用 safeNavigateBack 替代直接的 navigateBack 操作 - 添加回退失败时的页面重载机制 --- src/user/address/index.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/user/address/index.tsx b/src/user/address/index.tsx index 2cb6cfc..3ea67eb 100644 --- a/src/user/address/index.tsx +++ b/src/user/address/index.tsx @@ -7,7 +7,6 @@ import {ShopUserAddress} from "@/api/shop/shopUserAddress/model"; import {listShopUserAddress, removeShopUserAddress, updateShopUserAddress} from "@/api/shop/shopUserAddress"; import FixedButton from "@/components/FixedButton"; import dayjs from "dayjs"; -import { getCurrentLngLat } from "@/utils/location"; const Address = () => { const [list, setList] = useState([]) @@ -72,8 +71,7 @@ const Address = () => { } const onDefault = async (item: ShopUserAddress) => { - const loc = await getCurrentLngLat() - if (!loc) return + if (item.isDefault) return if (address) { await updateShopUserAddress({ @@ -84,8 +82,6 @@ const Address = () => { await updateShopUserAddress({ ...item, isDefault: true, - lng: loc.lng, - lat: loc.lat, }) Taro.showToast({ title: '设置成功', @@ -108,8 +104,11 @@ const Address = () => { } const selectAddress = async (item: ShopUserAddress) => { - const loc = await getCurrentLngLat() - if (!loc) return + if (item.isDefault) { + const backed = await safeNavigateBack() + if (!backed) reload() + return + } if (address) { await updateShopUserAddress({ @@ -120,11 +119,10 @@ const Address = () => { await updateShopUserAddress({ ...item, isDefault: true, - lng: loc.lng, - lat: loc.lat, }) - setTimeout(() => { - Taro.navigateBack() + setTimeout(async () => { + const backed = await safeNavigateBack() + if (!backed) reload() }, 500) }