116 lines
2.9 KiB
Vue
Raw Normal View History

2024-05-21 18:03:30 +08:00
<template>
2024-05-21 20:20:10 +08:00
<view style="height: 100vh;width: 100%;">
2024-08-07 18:26:49 +08:00
<headers class="fixedheader" :showBack="true">
<view class="headerName">
</view>
</headers>
2024-05-21 18:03:30 +08:00
<view class="page-body">
<view class="page-section page-section-gap">
2024-05-22 00:12:45 +08:00
<map style="width: 100%; height: 100vh;" :markers="markersArr" :latitude="latitude"
:longitude="longitude" @markertap="markTap">
2024-05-21 18:03:30 +08:00
</map>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
id: 0, // 使用 marker点击事件 需要填写id
title: 'map',
latitude: 39.909,
longitude: 116.39742,
projectSn: "",
markersArr: [],
2024-05-22 20:51:13 +08:00
alarmPersonName:"",
2024-05-21 18:03:30 +08:00
}
},
onLoad(option) {
2024-05-21 20:20:10 +08:00
console.log(666777)
2024-05-21 18:03:30 +08:00
this.latitude = option.latitude ? option.latitude : '39.909';
this.longitude = option.longitude ? option.longitude : '116.39742';
2024-05-22 20:51:13 +08:00
this.alarmPersonName = option.alarmPersonName ? option.alarmPersonName : '';
2024-05-21 18:03:30 +08:00
this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
2024-05-22 00:12:45 +08:00
this.getListData();
2024-05-21 18:03:30 +08:00
},
methods: {
2024-05-22 00:12:45 +08:00
markTap(e) {
console.log('ccccccc')
console.log(JSON.stringify(e))
console.log('ccccccc')
uni.openLocation({
// 目标位置的经纬度
2024-05-22 20:51:13 +08:00
latitude: parseFloat(e.target.latitude),
longitude: parseFloat(e.target.longitude),
2024-05-22 00:12:45 +08:00
// 调用成功时的回调函数
success: function(res) {
console.log('调用成功:', res)
},
// 调用失败时的回调函数
fail: function(res) {
console.log('调用失败:', res)
},
// 调用完成时的回调函数
complete: function(res) {
console.log('调用完成:', res)
}
})
},
2024-05-21 18:03:30 +08:00
//获取记录
getListData() {
let that = this;
//获取我整改的巡查记录数量
this.sendRequest({
2024-05-22 00:12:45 +08:00
url: 'xmgl/xzEmergencyReliefGoods/list',
2024-05-21 18:03:30 +08:00
method: 'get',
data: {
projectSn: this.projectSn,
},
success: res => {
console.log(res)
2024-05-22 00:12:45 +08:00
const newResult = res.result.filter(item => item.longitude || item.latitude).map(
2024-05-21 18:03:30 +08:00
(item, index) => {
return {
id: index + 1,
latitude: item.latitude ? item.latitude : 0,
longitude: item.longitude ? item.longitude : 0,
2024-05-22 00:12:45 +08:00
title: item.goodsName,
label: {
content: item.goodsName,
2024-05-22 20:51:13 +08:00
textAlign: "center",
2024-05-22 00:12:45 +08:00
},
iconPath: '/static/address-logo1.png',
2024-05-21 18:03:30 +08:00
}
});
2024-05-22 00:12:45 +08:00
that.markersArr = newResult.concat([{
2024-05-22 20:51:13 +08:00
id: -1,
2024-05-22 00:12:45 +08:00
latitude: that.latitude,
longitude: that.longitude,
2024-05-22 20:51:13 +08:00
label: {
content: that.alarmPersonName,
textAlign: "center",
},
2024-05-22 00:12:45 +08:00
// title: item.goodsName,
iconPath: '/static/address-logo2.png',
}])
2024-05-21 18:03:30 +08:00
}
})
},
}
}
</script>
2024-08-07 18:26:49 +08:00
<style lang="scss" scoped>
.fixedheader {
background-color: transparent;
/deep/.headerBox {
background-color: transparent;
color: #fff;
}
}
2024-05-21 18:03:30 +08:00
</style>