qa-regulatory-gwj-app/pages/branch-self-report/index/map.vue

80 lines
2.0 KiB
Vue

<template>
<view>
<web-view :src="mapUrl"/>
</view>
</template>
<script>
import {getInspectionReportListManageRecordsDetails} from "../../../api";
import gcoord from '@/common/gcoord.js'
import imgH from "@/static/h.png";
export default {
data() {
return {
CHECKRECORD_ID: '',
mapUrl: '',
}
},
onLoad(event) {
this.CHECKRECORD_ID = event.CHECKRECORD_ID;
this.getData()
},
methods: {
async getData() {
let resData = await getInspectionReportListManageRecordsDetails({
CHECKRECORD_ID: this.CHECKRECORD_ID,
});
const covers = []
for (let i = 0; i < resData.hdList.length; i++) {
if (
!this.isEmpty(resData.hdList[i].LONGITUDE) &&
!this.isEmpty(resData.hdList[i].LATITUDE)
) {
covers.push({
latitude: resData.hdList[i].LATITUDE,
longitude: resData.hdList[i].LONGITUDE,
iconPath: imgH,
});
}
}
uni.getLocation({
type: "GCJ02",
success: (res) => {
const result = gcoord.transform(
[res.longitude, res.latitude],
gcoord.GCJ02,
gcoord.BD09
);
this.mapUrl =
"https://skqhdg.porthebei.com:9004/map/map.html?point=" +
encodeURIComponent(JSON.stringify(covers)) +
"&longitude=" +
result[0] +
"&latitude=" +
result[1];
},
fail: () => {
uni.showToast({
title: "获取位置失败",
icon: "none",
});
},
});
},
isEmpty(value) {
return (
value === undefined ||
value === null ||
value === "undefined" ||
value === "null" ||
(typeof value === "object" && Object.keys(value).length === 0) ||
(typeof value === "string" && value.trim().length === 0)
);
}
}
}
</script>
<style scoped lang="scss"></style>