From ab2ee050def8d64474a52d351f7b601970c0e570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Sat, 22 Nov 2025 11:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96SelectMap=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0IP=E5=AE=9A=E4=BD=8D=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E7=94=A8=E6=88=B7=E4=BD=8D=E7=BD=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=9B=B4=E5=8A=A0=E5=87=86=E7=A1=AE=E5=92=8C=E7=A8=B3?= =?UTF-8?q?=E5=AE=9A=EF=BC=8C=E5=90=8C=E6=97=B6=E8=B0=83=E6=95=B4=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BB=A5=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/selectMap.module.scss | 6 +++- .../MessageEnter/components/selectMap.tsx | 28 +++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.module.scss b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.module.scss index f0a77bb3..b8f65724 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.module.scss +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.module.scss @@ -8,10 +8,13 @@ .searchArea { flex-shrink: 0; position: relative; + z-index: 10000; } .searchInput { width: 100%; + position: relative; + z-index: 10000; } .searchResults { @@ -19,7 +22,7 @@ top: 100%; left: 0; right: 0; - z-index: 1000; + z-index: 10001; background: #fff; border: 1px solid #e8e8e8; border-radius: 4px; @@ -27,6 +30,7 @@ margin-top: 4px; max-height: 300px; overflow-y: auto; + pointer-events: auto; :global(.ant-list-item) { cursor: pointer; diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.tsx index d09316ce..7df7fdfc 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/selectMap.tsx @@ -8,7 +8,7 @@ import styles from "./selectMap.module.scss"; declare global { interface Window { TMap: any; - geolocationRef: any; // 全局IP定位服务引用 + geolocationRef: any; // 全局IP定位服务引用(TMap.service.IPLocation实例) } } @@ -117,8 +117,8 @@ const SelectMap: React.FC = ({ // 创建地理编码服务(用于反向地理编码) geocoderRef.current = new window.TMap.service.Geocoder(); - // 使用腾讯地图内置的定位服务 - window.geolocationRef = window.TMap.service.Geolocation; + // 创建IP定位服务 + window.geolocationRef = new window.TMap.service.IPLocation(); // 创建搜索建议服务 suggestServiceRef.current = new window.TMap.service.Suggestion({ @@ -327,13 +327,13 @@ const SelectMap: React.FC = ({ setIsLocating(true); try { if (window.geolocationRef) { - window.geolocationRef.getLocation({ - timeout: 10000, - convert: true, - success: function (result: any) { + window.geolocationRef + .locate() + .then((result: any) => { setIsLocating(false); - if (result && result.location) { - const { lat, lng } = result.location; + console.log("IP定位结果:", result); + if (result && result.result && result.result.location) { + const { lat, lng } = result.result.location; message.info("已定位到您的大致位置"); initializeUserLocation(lat, lng, false); } else { @@ -342,16 +342,16 @@ const SelectMap: React.FC = ({ // 使用默认位置(北京市) initializeUserLocation(39.908823, 116.39747, true); } - }, - error: function () { + }) + .catch((error: any) => { setIsLocating(false); + console.error("IP定位失败:", error); message.info("无法获取您的位置,已定位到北京"); // 使用默认位置(北京市) initializeUserLocation(39.908823, 116.39747, true); - }, - }); + }); } else { - // 地理编码服务未初始化:使用默认位置 + // IP定位服务未初始化:使用默认位置 setIsLocating(false); message.info("无法获取您的位置,已定位到北京"); // 使用默认位置(北京市)