This commit is contained in:
BianLzhaoMin 2025-10-28 10:18:47 +08:00
parent 8f5c71255c
commit e448165457
6 changed files with 37 additions and 46 deletions

View File

@ -1 +1,2 @@
VITE_API_BASE_URL = http://192.168.1.175:58080 # VITE_API_BASE_URL = http://192.168.1.175:58080
VITE_API_BASE_URL = http://192.168.0.133:58080

View File

@ -25,16 +25,12 @@ const getProjectList = async () => {
const handleWebViewMessage = (event) => { const handleWebViewMessage = (event) => {
getProjectModelListApi({ projectId: event.detail.data[0].projectInfo.proId }).then((res) => { getProjectModelListApi({ projectId: event.detail.data[0].projectInfo.proId }).then((res) => {
if (res?.data?.length > 0) { if (res?.data?.length > 0) {
const modelInfoList = {
modelInfoList: res.data,
projectId: event.detail.data[0].projectInfo.proId,
token: memberStore.token,
}
const ctx = uni.requireNativePlugin('bonus-textodule') const ctx = uni.requireNativePlugin('bonus-textodule')
ctx.openNativePage( ctx.openNativePage(
{ {
modelInfoList: modelInfoList, modelInfoList: res.data,
projectId: event.detail.data[0].projectInfo.proId,
token: memberStore.token,
}, },
(result) => {}, (result) => {},
) )

View File

@ -7,7 +7,7 @@
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script> <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
<script type="text/javascript" <script type="text/javascript"
src="https://api.map.baidu.com/api?v=3.0&&type=webgl&ak=cClgLBaLgGUdQDilX9dGvieL"></script> src="https://api.map.baidu.com/api?v=3.0&&type=webgl&ak=iqyZkSZPurf61MhFV7hesbDukHdMBEEb"></script>
<title>百度地图</title> <title>百度地图</title>
<style> <style>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,48 +31,35 @@
<script type="text/javascript"> <script type="text/javascript">
document.addEventListener('UniAppJSBridgeReady', function () { document.addEventListener('UniAppJSBridgeReady', function () {
// // 1. 初始化地图 // // 1. 初始化地图
// const map = new BMapGL.Map('map-container') // 创建地图实例
// let point = new BMapGL.Point(117.13805, 31.8734) // 创建点坐标
// map.centerAndZoom(point, 12) // 初始化地图,设置中心点坐标和地图级别
// map.enableScrollWheelZoom(true) // 启用滚轮放大缩小
function getUrlParams() { function getUrlParams() {
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
return { const projectInfo = JSON.parse(params.get('projectInfo'))
lat: parseFloat(params.get('lat')) || 31.8734, // 默认值 return projectInfo
lng: parseFloat(params.get('lng')) || 117.13805, // 默认值
proName: decodeURIComponent(params.get('proName')) || '-', // 默认值
chargePerson: decodeURIComponent(params.get('chargePerson')) || '-', // 默认值
location: decodeURIComponent(params.get('location')) || '-' // 默认值
};
} }
const { lat, lng, proName, chargePerson, location } = getUrlParams() const projectInfo = getUrlParams()
const proInfo = {
lat,
lng,
proName,
chargePerson,
location
}
initMap(projectInfo)
initMap(proInfo)
function initMap(proInfo) { function initMap(proInfo) {
const map = new BMapGL.Map('map-container') // 创建地图实例 const map = new BMapGL.Map('map-container') // 创建地图实例
let point = new BMapGL.Point(proInfo.lng, proInfo.lat) // 创建点坐标 let point = new BMapGL.Point(proInfo[0].lng, proInfo[0].lat) // 创建点坐标
map.centerAndZoom(point, 12) // 初始化地图,设置中心点坐标和地图级别 map.centerAndZoom(point, 12) // 初始化地图,设置中心点坐标和地图级别
map.enableScrollWheelZoom(true) // 启用滚轮放大缩小 map.enableScrollWheelZoom(true) // 启用滚轮放大缩小
projectInfo.forEach(item => {
handleProjectInfoOnMap(map, item)
})
handleProjectInfoOnMap(map, proInfo) // handleProjectInfoOnMap(map, proInfo)
} }
function handleProjectInfoOnMap(map, projectInfo) { function handleProjectInfoOnMap(map, projectInfo) {
// 示例1: 如果项目信息包含经纬度,移动地图到该位置 // 示例1: 如果项目信息包含经纬度,移动地图到该位置
if (projectInfo.lng && projectInfo.lat) { if (projectInfo.lng && projectInfo.lat) {
const projectPoint = new BMapGL.Point(projectInfo.lng, projectInfo.lat); const projectPoint = new BMapGL.Point(projectInfo.lng, projectInfo.lat);
map.centerAndZoom(projectPoint, 15); // 移动并放大到项目位置 map.centerAndZoom(projectPoint, 15); // 移动并放大到项目位置
const icon = new BMapGL.Icon('./image/location.png', new BMapGL.Size(36, 36), { const icon = new BMapGL.Icon('./image/location.png', new BMapGL.Size(36, 36), {
@ -86,11 +73,11 @@
map.addOverlay(marker) map.addOverlay(marker)
const infoWindow = new BMapGL.InfoWindow(` // const infoWindow = new BMapGL.InfoWindow(`
<h3 style="color: #002db6; margin: 0 0 10px 0; font-size: 18px;">${projectInfo.proName}</h3> // <h3 style="color: #002db6; margin: 0 0 10px 0; font-size: 18px;">${projectInfo.proName}</h3>
<p>负责人: ${projectInfo.chargePerson}</p> // <p>负责人: ${projectInfo.chargePerson}</p>
<p>所在地: ${projectInfo.location}</p> // <p>所在地: ${projectInfo.location}</p>
`); // `);
const label = new BMapGL.Label(projectInfo.proName, { const label = new BMapGL.Label(projectInfo.proName, {
position: projectPoint, position: projectPoint,
@ -113,12 +100,20 @@
map.addOverlay(label) map.addOverlay(label)
marker.addEventListener('click', function () { marker.addEventListener('click', function () {
map.openInfoWindow(infoWindow, projectPoint); // map.openInfoWindow(infoWindow, projectPoint);
// 向父组件传参然后跳转相关页面
uni.postMessage({
data: {
action: 'navigateToProject',
projectInfo: projectInfo
}
});
}); });
} }
} }
}) })