99 lines
2.4 KiB
Vue
99 lines
2.4 KiB
Vue
<template>
|
|
<view style="height: 100vh;width: 100%;">
|
|
<view class="page-body">
|
|
<view class="page-section page-section-gap">
|
|
<map style="width: 100%; height: 100vh;" :markers="markersArr" :latitude="latitude"
|
|
:longitude="longitude" @markertap="markTap">
|
|
</map>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
id: 0, // 使用 marker点击事件 需要填写id
|
|
title: 'map',
|
|
latitude: 39.909,
|
|
longitude: 116.39742,
|
|
projectSn: "",
|
|
markersArr: [],
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
console.log(666777)
|
|
this.latitude = option.latitude ? option.latitude : '39.909';
|
|
this.longitude = option.longitude ? option.longitude : '116.39742';
|
|
this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
|
|
this.getListData();
|
|
},
|
|
methods: {
|
|
markTap(e) {
|
|
console.log('ccccccc')
|
|
console.log(JSON.stringify(e))
|
|
console.log('ccccccc')
|
|
uni.openLocation({
|
|
// 目标位置的经纬度
|
|
latitude: e.target.latitude,
|
|
longitude: e.target.longitude,
|
|
// 调用成功时的回调函数
|
|
success: function(res) {
|
|
console.log('调用成功:', res)
|
|
},
|
|
// 调用失败时的回调函数
|
|
fail: function(res) {
|
|
console.log('调用失败:', res)
|
|
},
|
|
// 调用完成时的回调函数
|
|
complete: function(res) {
|
|
console.log('调用完成:', res)
|
|
}
|
|
})
|
|
|
|
},
|
|
//获取记录
|
|
getListData() {
|
|
let that = this;
|
|
//获取我整改的巡查记录数量
|
|
this.sendRequest({
|
|
url: 'xmgl/xzEmergencyReliefGoods/list',
|
|
method: 'get',
|
|
data: {
|
|
projectSn: this.projectSn,
|
|
},
|
|
success: res => {
|
|
console.log(res)
|
|
const newResult = res.result.filter(item => item.longitude || item.latitude).map(
|
|
(item, index) => {
|
|
return {
|
|
id: index + 1,
|
|
latitude: item.latitude ? item.latitude : 0,
|
|
longitude: item.longitude ? item.longitude : 0,
|
|
title: item.goodsName,
|
|
label: {
|
|
content: item.goodsName,
|
|
textAlign:"center",
|
|
},
|
|
iconPath: '/static/address-logo1.png',
|
|
}
|
|
});
|
|
|
|
that.markersArr = newResult.concat([{
|
|
id: res.result.length + 2,
|
|
latitude: that.latitude,
|
|
longitude: that.longitude,
|
|
// title: item.goodsName,
|
|
iconPath: '/static/address-logo2.png',
|
|
}])
|
|
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
</style> |