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) }