This commit is contained in:
parent
8f5c71255c
commit
e448165457
|
|
@ -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
|
||||
|
|
@ -25,16 +25,12 @@ const getProjectList = async () => {
|
|||
const handleWebViewMessage = (event) => {
|
||||
getProjectModelListApi({ projectId: event.detail.data[0].projectInfo.proId }).then((res) => {
|
||||
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')
|
||||
ctx.openNativePage(
|
||||
{
|
||||
modelInfoList: modelInfoList,
|
||||
modelInfoList: res.data,
|
||||
projectId: event.detail.data[0].projectInfo.proId,
|
||||
token: memberStore.token,
|
||||
},
|
||||
(result) => {},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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://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>
|
||||
<style>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -31,48 +31,35 @@
|
|||
<script type="text/javascript">
|
||||
document.addEventListener('UniAppJSBridgeReady', function () {
|
||||
// // 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() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return {
|
||||
lat: parseFloat(params.get('lat')) || 31.8734, // 默认值
|
||||
lng: parseFloat(params.get('lng')) || 117.13805, // 默认值
|
||||
proName: decodeURIComponent(params.get('proName')) || '-', // 默认值
|
||||
chargePerson: decodeURIComponent(params.get('chargePerson')) || '-', // 默认值
|
||||
location: decodeURIComponent(params.get('location')) || '-' // 默认值
|
||||
};
|
||||
const projectInfo = JSON.parse(params.get('projectInfo'))
|
||||
return projectInfo
|
||||
|
||||
}
|
||||
|
||||
const { lat, lng, proName, chargePerson, location } = getUrlParams()
|
||||
const proInfo = {
|
||||
lat,
|
||||
lng,
|
||||
proName,
|
||||
chargePerson,
|
||||
location
|
||||
}
|
||||
const projectInfo = getUrlParams()
|
||||
|
||||
|
||||
|
||||
initMap(proInfo)
|
||||
initMap(projectInfo)
|
||||
|
||||
function initMap(proInfo) {
|
||||
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.enableScrollWheelZoom(true) // 启用滚轮放大缩小
|
||||
projectInfo.forEach(item => {
|
||||
handleProjectInfoOnMap(map, item)
|
||||
})
|
||||
|
||||
handleProjectInfoOnMap(map, proInfo)
|
||||
// handleProjectInfoOnMap(map, proInfo)
|
||||
}
|
||||
|
||||
function handleProjectInfoOnMap(map, projectInfo) {
|
||||
// 示例1: 如果项目信息包含经纬度,移动地图到该位置
|
||||
if (projectInfo.lng && projectInfo.lat) {
|
||||
|
||||
|
||||
const projectPoint = new BMapGL.Point(projectInfo.lng, projectInfo.lat);
|
||||
map.centerAndZoom(projectPoint, 15); // 移动并放大到项目位置
|
||||
const icon = new BMapGL.Icon('./image/location.png', new BMapGL.Size(36, 36), {
|
||||
|
|
@ -86,11 +73,11 @@
|
|||
map.addOverlay(marker)
|
||||
|
||||
|
||||
const infoWindow = new BMapGL.InfoWindow(`
|
||||
<h3 style="color: #002db6; margin: 0 0 10px 0; font-size: 18px;">${projectInfo.proName}</h3>
|
||||
<p>负责人: ${projectInfo.chargePerson}</p>
|
||||
<p>所在地: ${projectInfo.location}</p>
|
||||
`);
|
||||
// const infoWindow = new BMapGL.InfoWindow(`
|
||||
// <h3 style="color: #002db6; margin: 0 0 10px 0; font-size: 18px;">${projectInfo.proName}</h3>
|
||||
// <p>负责人: ${projectInfo.chargePerson}</p>
|
||||
// <p>所在地: ${projectInfo.location}</p>
|
||||
// `);
|
||||
|
||||
const label = new BMapGL.Label(projectInfo.proName, {
|
||||
position: projectPoint,
|
||||
|
|
@ -113,12 +100,20 @@
|
|||
|
||||
map.addOverlay(label)
|
||||
marker.addEventListener('click', function () {
|
||||
map.openInfoWindow(infoWindow, projectPoint);
|
||||
// map.openInfoWindow(infoWindow, projectPoint);
|
||||
|
||||
|
||||
// 向父组件传参然后跳转相关页面
|
||||
uni.postMessage({
|
||||
data: {
|
||||
action: 'navigateToProject',
|
||||
projectInfo: projectInfo
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue