Files
dvcp_v2_wxcp_app/library/apps/AppBuilding/components/searchMap.vue

599 lines
16 KiB
Vue
Raw Normal View History

2021-12-16 11:18:39 +08:00
<template>
<div class="searchMap">
<div class="grid-input">
2021-12-24 22:34:18 +08:00
<img src="./img/back-icon.png" alt="" class="back-icon" v-if="name && show" @click="show=false">
<img src="./img/search-icon.png" alt="" class="search-icon" v-else>
2021-12-23 13:56:06 +08:00
<input type="text" class="input" placeholder="请输入姓名、房屋信息" v-model="name" maxlength="10" confirm-type="search"
@confirm="search"/>
2021-12-20 15:45:56 +08:00
<div class="clear-btn">
2021-12-24 22:34:18 +08:00
<img src="./img/del-icon.png" alt="" class="del-icon" v-if="name" @click="clear">
2021-12-20 15:45:56 +08:00
</div>
<span class="search-btn" @click="search">搜索</span>
2021-12-16 11:18:39 +08:00
</div>
2021-12-23 20:02:26 +08:00
<div class="search-list" v-if="show">
2021-12-16 11:18:39 +08:00
<div class="title border">
2021-12-24 22:34:18 +08:00
<img src="./img/search-icon.png" alt="" class="search-icon">{{ name }}
2021-12-16 11:18:39 +08:00
</div>
2021-12-23 20:02:26 +08:00
<div class="item border" v-for="(item, index) in buildList" :key="index" @click="getBuildingInfo(item)">
2021-12-24 22:34:18 +08:00
<img src="./img/user-icon.png" alt="" class="search-icon user-icon">
2021-12-16 11:18:39 +08:00
<div class="item-content">
2021-12-21 16:40:02 +08:00
<h3>{{ item.residentName }}</h3>
<p>{{ item.areaName || '' }}{{ item.createAddress }}</p>
2021-12-16 11:18:39 +08:00
</div>
</div>
</div>
2021-12-17 17:31:12 +08:00
<div class="build-btn" @click="toList()">
2021-12-24 22:34:18 +08:00
<img src="./img/build-icon.png" alt=""> 楼栋<br/>列表
2021-12-16 11:18:39 +08:00
</div>
<div class="map-content">
2021-12-27 10:07:15 +08:00
<AiTMap :map.sync="map" :lib.sync="lib" :ops="ops" :libraries="['service', 'tools']"/>
2021-12-16 11:18:39 +08:00
</div>
2021-12-20 15:45:56 +08:00
<u-popup v-model="showPop" mode="bottom" border-radius="14">
2021-12-21 16:40:02 +08:00
<div class="popup">
2021-12-20 15:45:56 +08:00
<div class="bg"></div>
2021-12-21 16:40:02 +08:00
<div class="title">{{ detailInfo.house.createAddress || '' }}</div>
2021-12-23 19:44:05 +08:00
<p class="address">{{ detailInfo.community.address || '' }}</p>
2021-12-20 15:45:56 +08:00
<div class="info-flex">
<span class="label">所属社区</span>
2021-12-21 16:40:02 +08:00
<span class="value">{{ detailInfo.build.areaName }}</span>
2021-12-20 15:45:56 +08:00
</div>
<div class="info-flex">
<span class="label">所属小区</span>
2021-12-21 16:40:02 +08:00
<span class="value">{{ detailInfo.build.communityName }}</span>
2021-12-20 15:45:56 +08:00
</div>
<div class="info-flex">
<span class="label">房屋类型</span>
2021-12-21 16:40:02 +08:00
<span class="value">{{ $dict.getLabel('communityBuildingType', detailInfo.house.buildingType) }}</span>
2021-12-20 15:45:56 +08:00
</div>
<div class="info-flex">
<span class="label">所属网格</span>
<span class="value" v-if="detailInfo.gird">{{ detailInfo.gird.girdName || '' }}</span>
2021-12-20 15:45:56 +08:00
</div>
<div class="info-flex">
<span class="label">网格管理员</span>
<span class="value" v-if="detailInfo.gird">{{ detailInfo.gird.girdMemberNames || '' }}</span>
2021-12-20 15:45:56 +08:00
</div>
<div class="info-flex">
<span class="label">楼栋长</span>
2021-12-21 16:40:02 +08:00
<span
class="value">{{ detailInfo.build.managerName || '' }}&nbsp;&nbsp;{{
detailInfo.build.managerPhone || ''
}}
<img :src="$cdn + 'common/phone.png'" alt="" @click="callPhone(detailInfo.build.managerPhone)"
class="phone-icon" v-if="detailInfo.build.managerPhone">
2021-12-20 15:45:56 +08:00
</span>
</div>
</div>
2021-12-24 13:56:15 +08:00
<div class="popup-btn" @click="toDetail(detailInfo.build.id)">查看楼栋模型</div>
2021-12-20 15:45:56 +08:00
</u-popup>
2021-12-23 15:17:41 +08:00
<u-popup v-model="buildPopup" mode="bottom" border-radius="14">
<div class="popup">
<div class="bg"/>
<div class="title">{{ building.createAddress || '' }}</div>
<div class="info-flex">
<span class="label">所属社区</span>
<span class="value">{{ building.areaName }}</span>
</div>
<div class="info-flex">
<span class="label">所属小区</span>
<span class="value">{{ building.communityName }}</span>
</div>
<div class="info-flex">
<span class="label">房屋类型</span>
<span class="value">{{ $dict.getLabel('communityBuildingType', building.buildingType) }}</span>
</div>
<div class="info-flex">
<span class="label">所属网格</span>
2021-12-24 16:22:58 +08:00
<span class="value" v-text="building.girdName||''"/>
2021-12-23 15:17:41 +08:00
</div>
<div class="info-flex">
<span class="label">网格管理员</span>
2021-12-24 16:22:58 +08:00
<span class="value" v-text="building.girdMemberNames||''"/>
2021-12-23 15:17:41 +08:00
</div>
<div class="info-flex">
<span class="label">楼栋长</span>
<span
2021-12-23 16:42:14 +08:00
class="value">{{ building.managerName || '' }}&nbsp;&nbsp;{{ building.managerPhone || '' }}
2021-12-23 15:17:41 +08:00
<img :src="$cdn + 'common/phone.png'" alt="" @click="callPhone(detailInfo.build.managerPhone)"
class="phone-icon" v-if="detailInfo.build.managerPhone">
</span>
</div>
</div>
2021-12-24 12:05:40 +08:00
<div class="popup-btn" @click="toDetail(building.id)">查看楼栋模型</div>
2021-12-23 15:17:41 +08:00
</u-popup>
2021-12-16 11:18:39 +08:00
</div>
</template>
<script>
2021-12-21 16:40:02 +08:00
import {mapState} from 'vuex'
2021-12-16 11:18:39 +08:00
2021-12-21 16:40:02 +08:00
export default {
2022-03-15 14:47:59 +08:00
name: "searchMap",
2021-12-16 11:18:39 +08:00
data() {
return {
ops: {},
2021-12-21 16:40:02 +08:00
lib: null,
2021-12-16 11:18:39 +08:00
map: null,
markerArr: [],
show: false,
2021-12-20 15:45:56 +08:00
value: '',
ClusterBubble: null,
name: '',
buildList: [],
detailInfo: {
house: {},
2021-12-23 20:02:26 +08:00
build: {},
community: {},
gird: {}
2021-12-20 15:45:56 +08:00
},
2021-12-21 16:40:02 +08:00
showPop: false,
2021-12-23 15:17:41 +08:00
retryMapCount: 0,
building: {},
buildPopup: false
2021-12-16 11:18:39 +08:00
}
},
2022-07-20 12:07:23 +08:00
computed: {...mapState(['user', 'wxwork'])},
2021-12-16 11:18:39 +08:00
mounted() {
2021-12-27 10:07:15 +08:00
this.getCommunityList().then(points => {
2021-12-21 16:40:02 +08:00
this.getMarkerCluster(points)
})
2021-12-24 15:27:36 +08:00
},
onShow() {
document.title = "以房找人"
2021-12-21 16:40:02 +08:00
},
created() {
this.$dict.load("communityBuildingType")
2021-12-16 11:18:39 +08:00
},
methods: {
2021-12-20 15:45:56 +08:00
getCommunityList() {
2021-12-21 16:40:02 +08:00
return this.$http.post('/app/appcommunitybuildinginfo/listByBuilding', null, {
2021-12-20 15:45:56 +08:00
params: {
current: 1,
size: 1000000,
areaId: this.user.areaId
}
}).then(res => {
2021-12-21 16:40:02 +08:00
if (res?.data) {
2021-12-20 15:45:56 +08:00
this.buildList = res.data
2021-12-21 16:40:02 +08:00
return res.data.map(item => {
2021-12-20 15:45:56 +08:00
return {
2021-12-21 16:40:02 +08:00
...item,
2021-12-20 15:45:56 +08:00
lnglat: [item.lng, item.lat],
buildingNumber: item.name || item.buildingNumber,
2021-12-21 16:40:02 +08:00
communityName: item.name || item.communityName,
2021-12-20 15:45:56 +08:00
}
})
}
})
},
2021-12-23 13:56:06 +08:00
getMarkerCluster(points, count = 0) {
let {lib: TMap, map} = this
2021-12-21 16:40:02 +08:00
if (map) {
2022-03-15 14:47:59 +08:00
class ClusterBubble extends TMap.DOMOverlay {
constructor(options) {
super(options);
}
onInit(options) {
this.content = options.content;
this.position = options.position;
this.customClass = options.customClass
};
onDestroy() {
this.dom.removeEventListener('click', this.onClick);
this.removeAllListeners();
}
createDOM() {
let dom = document.createElement('div');
dom.classList.add(this.customClass || 'marker');
dom.innerText = this.content;
// 监听点击事件实现zoomOnClick
this.onClick = this.onClick.bind(this);
// pc端注册click事件移动端注册touchend事件
dom.addEventListener('click', this.onClick);
dom.addEventListener('touchend', this.onClick);
return dom;
};
updateDOM() {
if (!this.map) {
return;
}
// 经纬度坐标转容器像素坐标
let pixel = this.map.projectToContainer(this.position);
// 使文本框中心点对齐经纬度坐标点
let left = pixel.getX() - this.dom.clientWidth / 2 + 'px';
let top = pixel.getY() - this.dom.clientHeight / 2 + 'px';
this.dom.style.transform = `translate(${left}, ${top})`;
this.emit('dom_updated');
};
onClick() {
this.emit('click');
}
}
2022-07-20 12:07:23 +08:00
this.wxwork.config.latlng && map.setCenter(this.wxwork.config.latlng)
2021-12-21 16:40:02 +08:00
let MarkerCluster = new TMap.MarkerCluster({
map, gridSize: 60,
enableDefaultStyle: false, // 关闭默认样式
geometries: points?.map(e => ({
position: new TMap.LatLng(e.lat, e.lng),
2021-12-23 15:17:41 +08:00
content: `${e.createAddress} | ${e.houseNum}`,
properties: {...e}
2021-12-21 16:40:02 +08:00
})) || [],
zoomOnClick: true
2021-12-20 15:45:56 +08:00
})
2022-03-15 14:47:59 +08:00
let markers = [], cls = []
2021-12-21 16:40:02 +08:00
MarkerCluster.on('cluster_changed', () => {
if (markers.length) {
markers.forEach(function (item) {
item.destroy();
})
markers = [];
}
2022-03-15 14:47:59 +08:00
cls.forEach(e => e.destroy())
cls = []
2021-12-21 16:40:02 +08:00
let clusters = MarkerCluster.getClusters()
clusters.forEach((item) => {
2022-01-05 22:20:06 +08:00
if (item.geometries?.length > 1) {
2021-12-21 16:40:02 +08:00
//聚合样式
2022-03-15 14:47:59 +08:00
let clusterBubble = new ClusterBubble({
map,
2021-12-21 16:40:02 +08:00
position: item.center,
2022-03-15 14:47:59 +08:00
content: item.geometries.length,
customClass: 'cluster'
2021-12-21 16:40:02 +08:00
})
2022-03-15 14:47:59 +08:00
clusterBubble.on('click', () => {
map.fitBounds(item.bounds);
});
cls.push(clusterBubble)
2021-12-21 16:40:02 +08:00
} else {
//点标记样式
let {content} = item.geometries?.[0] || {},
overlay = new ClusterBubble({map, position: item.center, content})
overlay.on('click', () => {
2022-10-26 14:54:40 +08:00
// this.building = item.geometries?.[0]?.properties || {}
if(item.geometries[0].properties.id) {
this.$http.post(`/app/appcommunitybuildinginfo/queryBuildingInfo?buildingId=${item.geometries[0].properties.id}`).then(res => {
this.building = res.data
this.buildPopup = true
})
}
2021-12-21 16:40:02 +08:00
})
markers.push(overlay)
}
});
2021-12-20 15:45:56 +08:00
})
2021-12-21 16:40:02 +08:00
return Promise.resolve()
} else {
2021-12-23 13:56:06 +08:00
if (count < 5) {
2021-12-21 16:40:02 +08:00
setTimeout(() => {
2021-12-23 13:56:06 +08:00
return this.getMarkerCluster(points, ++count)
2021-12-21 16:40:02 +08:00
}, 1000)
} else Promise.reject("加载失败")
}
2021-12-20 15:45:56 +08:00
},
clear() {
this.name = ''
},
search() {
this.buildList = []
this.$http.post('/app/appcommunityhouseinfo/queryHouseByName', null, {
params: {
current: 1,
size: 20,
areaId: this.user.areaId,
name: this.name
}
}).then(res => {
if (res.code == 0 && res.data.length) {
this.show = true
this.buildList = res.data
// const points = res.data.map(item => {
// return {
// lnglat: [item.lng, item.lat],
// id: item.id,
// corpId: item.corpId,
// areaName: item.areaName,
// buildingNumber: item.residentName || item.buildingNumber,
// communityName: item.residentName || item.communityName,
// }
// })
// this.getMarkerCluster(points)
2021-12-21 16:40:02 +08:00
} else {
2021-12-20 15:45:56 +08:00
this.show = false
this.$u.toast('未搜索到结果,请换个关键字重试!')
}
})
},
2021-12-23 13:56:06 +08:00
getBuildingInfo(item) {
2021-12-21 16:40:02 +08:00
this.$http.post(`/app/appcommunityhouseinfo/queryDetailByIdWithBuilding?buildId=${item.buildingId}&houseId=${item.id}`).then(res => {
if (res.code == 0) {
console.log(res)
2021-12-21 16:40:02 +08:00
this.show = false
2021-12-20 15:45:56 +08:00
this.detailInfo = res.data
this.showPop = true
2021-12-20 15:45:56 +08:00
}
2021-12-16 11:18:39 +08:00
})
},
2021-12-17 17:31:12 +08:00
toList() {
2021-12-23 16:42:14 +08:00
uni.navigateTo({url: './list'})
2021-12-20 15:45:56 +08:00
},
callPhone(phone) {
2021-12-21 16:40:02 +08:00
uni.makePhoneCall({phoneNumber: phone})
2021-12-20 15:45:56 +08:00
},
toDetail(id) {
2021-12-23 16:42:14 +08:00
uni.navigateTo({url: `./detail?id=${id}`})
}
2021-12-16 11:18:39 +08:00
}
}
</script>
<style lang="scss" scoped>
.searchMap {
2021-12-21 16:40:02 +08:00
height: 100vh;
.grid-input {
2021-12-22 18:23:54 +08:00
width: calc(100% - 64px);
2021-12-16 11:18:39 +08:00
height: 88px;
background: #FFF;
2021-12-21 16:40:02 +08:00
box-shadow: 0 4px 8px 0 rgba(192, 185, 185, 0.5);
2021-12-16 11:18:39 +08:00
border-radius: 16px;
position: fixed;
top: 24px;
2021-12-24 10:07:38 +08:00
left: 50%;
transform: translateX(-50%);
2021-12-20 15:45:56 +08:00
z-index: 99999;
2021-12-16 11:18:39 +08:00
padding: 16px 20px;
box-sizing: border-box;
2021-12-21 16:40:02 +08:00
.search-icon {
2021-12-16 11:18:39 +08:00
width: 48px;
height: 48px;
margin-right: 16px;
}
2021-12-21 16:40:02 +08:00
.input {
2021-12-16 11:18:39 +08:00
display: inline-block;
padding: 8px 0;
height: 32px;
line-height: 32px;
2021-12-22 18:23:54 +08:00
width: calc(100% - 220px);
2021-12-16 11:18:39 +08:00
font-size: 28px;
font-family: MicrosoftYaHei;
color: #666;
}
2021-12-21 16:40:02 +08:00
.back-icon {
2021-12-16 11:18:39 +08:00
width: 16px;
height: 32px;
margin-right: 24px;
vertical-align: super;
}
2021-12-21 16:40:02 +08:00
.clear-btn {
2021-12-20 15:45:56 +08:00
display: inline-block;
width: 32px;
height: 32px;
margin-right: 30px;
}
2021-12-21 16:40:02 +08:00
.del-icon {
2021-12-16 11:18:39 +08:00
width: 32px;
height: 32px;
vertical-align: super;
}
2021-12-21 16:40:02 +08:00
.search-btn {
2021-12-16 11:18:39 +08:00
display: inline-block;
width: 80px;
height: 32px;
line-height: 32px;
text-align: right;
font-size: 28px;
font-family: MicrosoftYaHei;
color: #1365DD;
border-left: 1px solid #DEDFE0;
vertical-align: top;
margin-top: 12px;
}
}
2021-12-21 16:40:02 +08:00
.search-list {
2021-12-16 11:18:39 +08:00
position: fixed;
width: 100%;
2021-12-23 19:47:01 +08:00
height: calc(100% - 130px);
2021-12-20 15:45:56 +08:00
overflow-y: scroll;
2021-12-16 11:18:39 +08:00
top: 128px;
left: 0;
box-sizing: border-box;
2021-12-20 15:45:56 +08:00
z-index: 99999;
2021-12-21 16:40:02 +08:00
.search-icon {
2021-12-16 11:18:39 +08:00
width: 36px;
height: 36px;
margin-right: 16px;
vertical-align: sub;
}
2021-12-21 16:40:02 +08:00
.title {
2021-12-16 11:18:39 +08:00
height: 82px;
line-height: 82px;
font-size: 26px;
font-family: MicrosoftYaHeiSemibold;
color: #1365DD;
2021-12-23 20:02:26 +08:00
padding-left: 44px;
background-color: #fff;
2021-12-16 11:18:39 +08:00
}
2021-12-21 16:40:02 +08:00
.item {
2021-12-23 20:02:26 +08:00
padding: 22px 44px 24px 44px;
background-color: #fff;
2021-12-16 11:18:39 +08:00
}
2021-12-21 16:40:02 +08:00
.item-content {
2021-12-16 11:18:39 +08:00
display: inline-block;
width: 610px;
color: #333;
2021-12-21 16:40:02 +08:00
h3 {
2021-12-16 11:18:39 +08:00
font-size: 28px;
font-family: MicrosoftYaHeiSemibold;
line-height: 32px;
margin-bottom: 8px;
}
2021-12-21 16:40:02 +08:00
p {
2021-12-16 11:18:39 +08:00
width: 100%;
font-size: 24px;
font-family: MicrosoftYaHei;
line-height: 32px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
2021-12-21 16:40:02 +08:00
.user-icon {
2021-12-16 11:18:39 +08:00
vertical-align: top;
}
2021-12-21 16:40:02 +08:00
.border {
2021-12-16 11:18:39 +08:00
border-bottom: 1px solid #DEDFE1;
}
}
2021-12-21 16:40:02 +08:00
.build-btn {
2021-12-16 11:18:39 +08:00
width: 80px;
height: 160px;
background: #FFF;
2021-12-21 16:40:02 +08:00
box-shadow: 0 4px 8px 0 rgba(138, 138, 138, 0.5);
2021-12-16 11:18:39 +08:00
border-radius: 8px;
position: fixed;
bottom: 136px;
right: 24px;
2021-12-20 09:35:52 +08:00
z-index: 99999;
2021-12-16 11:18:39 +08:00
padding: 16px 16px 0;
box-sizing: border-box;
font-size: 24px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #666;
line-height: 30px;
2021-12-21 16:40:02 +08:00
img {
2021-12-16 11:18:39 +08:00
width: 48px;
height: 48px;
margin-bottom: 8px;
}
}
2021-12-21 16:40:02 +08:00
.map-content {
2021-12-16 11:18:39 +08:00
width: 100%;
height: 100%;
}
2021-12-21 16:40:02 +08:00
.popup {
2021-12-16 11:18:39 +08:00
padding: 0 32px 16px;
2021-12-21 16:40:02 +08:00
.bg {
2021-12-16 11:18:39 +08:00
width: 64px;
height: 10px;
background: #CCC;
border-radius: 6px;
margin: 32px 0 32px 344px;
}
2021-12-21 16:40:02 +08:00
.title {
2021-12-16 11:18:39 +08:00
font-size: 36px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
line-height: 50px;
margin-bottom: 24px;
}
2021-12-21 16:40:02 +08:00
.info-flex {
2021-12-16 11:18:39 +08:00
padding: 26px 0 30px 0;
width: 100%;
border-bottom: 1px solid #D8DDE6;
line-height: 40px;
font-size: 28px;
2021-12-21 16:40:02 +08:00
.label {
2021-12-16 11:18:39 +08:00
display: inline-block;
width: 160px;
font-weight: 800;
color: #333;
}
2021-12-21 16:40:02 +08:00
.value {
2021-12-16 11:18:39 +08:00
color: #666;
font-size: 26px;
2021-12-21 16:40:02 +08:00
.phone-icon {
2021-12-16 11:18:39 +08:00
width: 40px;
height: 40px;
vertical-align: sub;
margin-left: 16px;
}
}
}
}
2021-12-21 16:40:02 +08:00
.popup-btn {
2021-12-20 15:45:56 +08:00
width: 100%;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
height: 112px;
line-height: 112px;
text-align: center;
background: #1365DD;
color: #FFF;
}
2021-12-21 16:40:02 +08:00
::v-deep.marker {
color: #fff;
background: #5088FF;
padding: 0 32px;
width: fit-content;
height: 56px;
border-radius: 52px;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
&:before {
content: " ";
display: block;
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
transform: translate(-50%, 100%);
border: 12px solid transparent;
border-top-color: #5088FF;
}
}
2022-03-15 14:47:59 +08:00
::v-deep.cluster {
color: #fff;
border-radius: 50%;
height: 120px;
width: 120px;
background: radial-gradient(circle, #5088ff 50%, rgba(#5088ff, .4) 100%);
display: flex;
align-items: center;
justify-content: center;
}
2021-12-16 11:18:39 +08:00
}
2021-12-21 16:40:02 +08:00
</style>