以房找人

This commit is contained in:
liuye
2024-08-14 16:18:38 +08:00
parent 43dab0bf8e
commit d46c73777e
4 changed files with 100 additions and 58 deletions

View File

@@ -131,11 +131,10 @@ export default {
retryMapCount: 0, retryMapCount: 0,
building: {}, building: {},
buildPopup: false, buildPopup: false,
// latitude: 30.606355,
latitude: 30.606355, // longitude: 114.429633,
longitude: 114.429633, latitude: '',
// latitude: 23.099994, longitude: '',
// longitude: 113.324520,
_mapContext: null, _mapContext: null,
markList: [], markList: [],
statusBarHeight: uni.getSystemInfoSync().statusBarHeight, statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
@@ -143,13 +142,13 @@ export default {
}, },
computed: {...mapState(['user'])}, computed: {...mapState(['user'])},
mounted() { mounted() {
// uni.getLocation({ uni.getLocation({
// type: 'wgs84', type: 'wgs84',
// success: (res) => { success: (res) => {
// this.latitude = res.latitude this.latitude = res.latitude
// this.longitude = res.longitude this.longitude = res.longitude
// } }
// }); });
this._mapContext = uni.createMapContext("map", this); this._mapContext = uni.createMapContext("map", this);
// 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {}) // 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})
this._mapContext.initMarkerCluster({ this._mapContext.initMarkerCluster({

View File

@@ -18,12 +18,12 @@
<span class="status" :class="'color'+item.locationStatus" <span class="status" :class="'color'+item.locationStatus"
v-text="$dict.getLabel('BuildLocationStatus', item.locationStatus)"/> v-text="$dict.getLabel('BuildLocationStatus', item.locationStatus)"/>
</div> </div>
<!-- <div class="item-btn" v-if="item.locationStatus != 1" @click="toMap(item.id, item.areaId)"> <div class="item-btn" v-if="item.locationStatus != 1" @click="toMap(item.id, item.lat, item.lng)">
<span>去定位</span> <span>去定位</span>
</div> </div>
<div class="item-btn" v-if="item.locationStatus == 1" @click="toMap(item.id, item.areaId)"> <div class="item-btn" v-if="item.locationStatus == 1" @click="toMap(item.id, item.lat, item.lng)">
<span>重新定位</span> <span>重新定位</span>
</div> --> </div>
</div> </div>
<AiEmpty v-if="!list.length"/> <AiEmpty v-if="!list.length"/>
</div> </div>
@@ -92,8 +92,8 @@ export default {
toDetail(id) { toDetail(id) {
uni.navigateTo({url: `./detail?id=${id}`}) uni.navigateTo({url: `./detail?id=${id}`})
}, },
toMap(id, areaId) { toMap(id, lat, lng) {
uni.navigateTo({url: `./map?id=${id}&areaId=${areaId}`}) uni.navigateTo({url: `./map?id=${id}&lat=${lat}&lng=${lng}`})
} }
}, },

View File

@@ -1,10 +1,13 @@
<template> <template>
<div class="map"> <div class="map">
<u-navbar back-icon-color="#000" title="以房找人" title-color="#000" title-width="300" title-size="32"
:title-bold="true" :background="backgroundNavbar" :is-fixed="true" height="44"></u-navbar>
<div class="build-btn"> <div class="build-btn">
<img src="./components/img/model-icon.png" alt="" @click="toDetail"> 楼栋<br/>模型 <img src="./components/img/model-icon.png" alt="" @click="toDetail"> 楼栋<br/>模型
</div> </div>
<div class="map-content"> <div class="map-content">
<!-- <AiTMap v-if="user.areaId" :areaId="user.areaId" :map.sync="map" :lib.sync="lib" :ops="ops" :libraries="['service', 'tools']"></AiTMap> --> <!-- <AiTMap v-if="user.areaId" :areaId="user.areaId" :map.sync="map" :lib.sync="lib" :ops="ops" :libraries="['service', 'tools']"></AiTMap> -->
<map style="width: 100%; height: 100%;" id="map" :show-location="true" :longitude="longitude" :latitude="latitude" :scale="14" @tap="mapClick" :markers="markers"></map>
</div> </div>
<div class="footer"> <div class="footer">
<div class="click" @click="isFlag=true">点击定位</div> <div class="click" @click="isFlag=true">点击定位</div>
@@ -51,6 +54,7 @@
import {mapState} from 'vuex' import {mapState} from 'vuex'
export default { export default {
customNavigation: true,
data() { data() {
return { return {
ops: {}, ops: {},
@@ -59,59 +63,96 @@ export default {
markerLayer: '', markerLayer: '',
isFlag: false, isFlag: false,
latLng: {lat: '', lng: ''}, latLng: {lat: '', lng: ''},
retryTimes: 0 retryTimes: 0,
id: '',
backgroundNavbar: {
background: 'url(https://cdn.sinoecare.com/i/2024/07/12/6690a1309c7d3.png) no-repeat',
backgroundSize: 'cover',
},
markers: [],
longitude: '',
latitude: ''
} }
}, },
computed: {...mapState(['user', ])}, computed: {...mapState(['user', ])},
mounted() {
this.initMap() onLoad(option) {
}, uni.getLocation({
onShow() { type: 'wgs84',
// document.title = "以房找人" success: (res) => {
this.latitude = res.latitude
this.longitude = res.longitude
}
});
this.id = option.id
if(option.lat) {
this.markers = [{
id: 0,
latitude: option.lat,
longitude: option.lat,
iconPath: "https://cdn.sinoecare.com/i/2024/07/18/6698c40bdc9e3.png",
width: 40,
height: 40,
}]
}
// this.initMap()
}, },
methods: { methods: {
initMap() { //初始化地图 // initMap() { //初始化地图
this.$nextTick(() => { // this.$nextTick(() => {
let {lib: TMap, map, retryTimes} = this // let {lib: TMap, map, retryTimes} = this
if (map) { // if (map) {
map.setZoom(15) // map.setZoom(15)
map.on("click", (evt) => { // map.on("click", (evt) => {
if (this.markerLayer) { // if (this.markerLayer) {
this.markerLayer.setMap(null); // this.markerLayer.setMap(null);
} // }
this.markerLayer = new TMap.MultiMarker({ // this.markerLayer = new TMap.MultiMarker({
id: 'marker-layer', // id: 'marker-layer',
map: map // map: map
}); // });
if (this.isFlag) { // if (this.isFlag) {
this.markerLayer.add({ // this.markerLayer.add({
position: evt.latLng // position: evt.latLng
}); // });
this.latLng = { // this.latLng = {
lat: evt.latLng.lat, // lat: evt.latLng.lat,
lng: evt.latLng.lng // lng: evt.latLng.lng
} // }
} // }
}); // });
} else { // } else {
if (retryTimes < 5) // if (retryTimes < 5)
setTimeout(() => { // setTimeout(() => {
this.retryTimes++ // this.retryTimes++
this.initMap() // this.initMap()
}, 1000) // }, 1000)
} // }
}) // })
// },
mapClick(e) {
console.log(e)
if(!this.isFlag) return
this.markers = [{
id: 0,
latitude: e.detail.latitude,
longitude: e.detail.longitude,
iconPath: "https://cdn.sinoecare.com/i/2024/07/18/6698c40bdc9e3.png",
width: 40,
height: 40,
}]
this.latLng = {lat: e.detail.latitude, lng: e.detail.longitude}
}, },
confirm() { confirm() {
if (!this.latLng.lat) { if (!this.latLng.lat) {
return this.$u.toast(`未获取到定位信息,无法定位`) return this.$u.toast(`未获取到定位信息,无法定位`)
} }
let {id} = this.$route.query
this.$instance.post(`/app/appcommunitybuildinginfo/updateLocation`, null, { this.$instance.post(`/app/appcommunitybuildinginfo/updateLocation`, null, {
params: { params: {
id, id: this.id,
lat: this.latLng.lat, lat: this.latLng.lat,
lng: this.latLng.lng, lng: this.latLng.lng,
} }
@@ -126,7 +167,7 @@ export default {
}) })
}, },
toDetail() { toDetail() {
uni.navigateTo({url: `./detail?id=${this.$route.query.id}`}) uni.navigateTo({url: `./detail?id=${this.id}`})
} }
} }
} }

View File

@@ -63,7 +63,8 @@
<div class="file-flex"> <div class="file-flex">
<label class="left"> <label class="left">
<img src="https://cdn.cunwuyun.cn/dvcp/h5/common/appendix.png" alt=""> <img src="https://cdn.cunwuyun.cn/dvcp/h5/common/appendix.png" alt="">
<span>{{item.name}}.{{item.postfix}}</span> <span>{{item.name}}</span>
<!-- .{{item.postfix}} -->
</label> </label>
<span>{{(item.size/1024).toFixed(2)}}KB</span> <span>{{(item.size/1024).toFixed(2)}}KB</span>
</div> </div>
@@ -269,6 +270,7 @@
box-sizing: border-box; box-sizing: border-box;
position: fixed; position: fixed;
left: 32px; left: 32px;
z-index: 3;
.select-content { .select-content {
width: 100%; width: 100%;