feat(address): 添加地理位置获取功能并优化门店自动分配逻辑

- 集成 getCurrentLngLat 工具函数用于获取用户当前位置
- 在添加地址时自动获取并存储经纬度信息
- 在设置默认地址时更新位置信息
- 实现基于地理位置的门店自动分配算法
- 添加距离计算和多边形区域判断功能
- 优化送水订单的门店和配送员自动匹配逻辑
- 在微信地址导入时集成位置信息获取
- 添加位置权限处理和用户引导机制
This commit is contained in:
2026-02-09 15:09:27 +08:00
parent 94ed969d2d
commit 231723e960
5 changed files with 244 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
import {useEffect} from "react";
import Taro from '@tarojs/taro'
import {addShopUserAddress} from "@/api/shop/shopUserAddress";
import { getCurrentLngLat } from "@/utils/location";
const WxAddress = () => {
/**
@@ -9,7 +10,14 @@ const WxAddress = () => {
*/
const getWeChatAddress = () => {
Taro.chooseAddress()
.then(res => {
.then(async res => {
const loc = await getCurrentLngLat()
if (!loc) {
// Avoid leaving the user on an empty page.
setTimeout(() => Taro.navigateBack(), 300)
return
}
// 格式化微信返回的地址数据为后端所需格式
const addressData = {
name: res.userName,
@@ -20,6 +28,8 @@ const WxAddress = () => {
region: res.countyName,
address: res.detailInfo,
postalCode: res.postalCode,
lng: loc.lng,
lat: loc.lat,
isDefault: false
}
console.log(res, 'addrs..')