You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
7.4 KiB

<template>
<view>
<cpn-navbar title="护理地图" :isBack="true"></cpn-navbar>
<map id="map" :latitude="location.latitude" :longitude="location.longitude" @markertap="markertap"></map>
3 years ago
<u-popup v-model="isShowPopup" mode="bottom" :mask="false" height="auto" :border-radius="40">
<view class="top">
<view class="left">
3 years ago
<view class="name">{{selectMarker.info.customer.name}}</view>
<view class="sex">{{selectMarker.info.customer.sex}}</view>
</view>
3 years ago
<view class="right" v-if="selectMarker.info.status === 1">
<view class="icon icon3"></view>
<view class="text">进行中</view>
</view>
3 years ago
<view class="right" v-if="selectMarker.info.status === 0">
<view class="icon icon1"></view>
<view class="text">待护理</view>
</view>
<view class="right" v-else>
<view class="icon icon2"></view>
<view class="text">已完成</view>
</view>
</view>
<view class="center">
<view class="tel">
<view>
<u-icon name="phone" size="28" color="#1479FF"></u-icon>
</view>
3 years ago
<view class="text">{{selectMarker.info.customer.phone}}</view>
</view>
<view class="address">
<view>
<u-icon name="map" size="28" color="#1479FF"></u-icon>
</view>
3 years ago
<view class="text">{{selectMarker.info.customer_address.address}}</view>
</view>
</view>
<view class="bottom">
<view class="distance">
<view class="distance-icon">
<u-image src="/static/todayNursing/distance.png" height="42" width="42"></u-image>
</view>
3 years ago
<view class="distance-text">{{selectMarker.info.distance}}公里</view>
</view>
3 years ago
<view class="to-there" @click="toThere">
<view class="to-there-text">去那里</view>
<view class="to-there-icon">
<u-image src="/static/todayNursing/to-there.png" height="46" width="46"></u-image>
</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
mapCtx: null,
location: {
latitude: null,
longitude: null,
covers: []
},
3 years ago
iconMap: new Map([
[0, '/static/map/todo.png'],
[1, '/static/map/doing.png'],
[2, '/static/map/done.png'],
]),
isShowPopup: false,
3 years ago
popHeight: '294rpx',
selectMarker: null,
}
},
methods: {
async markertap(e) {
3 years ago
let marker = this.covers[e.detail.markerId]
this.covers[e.detail.markerId].height = 39
this.covers[e.detail.markerId].width = 30
3 years ago
this.covers.map(item => {
if (item.id != marker.id) {
item.width = 20
item.height = 24
}
})
this.mapCtx.addMarkers({
markers: this.covers,
clear: true,
complete: (res) => {}
})
this.selectMarker = marker
this.isShowPopup = true
this.mapCtx.moveToLocation({
longitude: marker.longitude,
latitude: marker.latitude
})
},
async getNowLocation() {
const location = (await uni.getLocation())[1]
this.location.latitude = location.latitude
this.location.longitude = location.longitude
},
updateClusters(clusters) {
let clusterMarkers = []
clusters.forEach(item => {
const {
center,
clusterId,
markerIds
} = item
let clusterObj = {
clusterId,
...center,
width: 20,
height: 24,
iconPath: "/static/map/done.png",
joinCluster: true,
label: { // 定制聚合簇样式
content: markerIds.length + '人',
3 years ago
fontSize: 13,
color: '#36596A',
3 years ago
width: 64,
height: 25,
3 years ago
bgColor: '#FFFFFF',
borderRadius: 5,
textAlign: 'center',
3 years ago
anchorX: -32,
anchorY: 4,
}
}
clusterMarkers.push(clusterObj)
})
this.mapCtx.addMarkers({
markers: clusterMarkers,
clear: false
})
},
3 years ago
async getCovers() {
let res = await this.$u.api.nurseList({
page: 1,
page_size: 999,
date: `${new Date().getFullYear()}-${new Date().getMonth()+1}-${new Date().getDate()}`,
lat: this.location.latitude,
lng: this.location.longitude
})
console.log(res);
this.covers = res.data.map((item, index) => {
return {
id: index,
3 years ago
latitude: Number(item.customer_address.lat),
longitude: Number(item.customer_address.lng),
width: 14,
height: 18,
3 years ago
iconPath: this.iconMap.get(item.status),
joinCluster: true,
label: {
3 years ago
content: item.customer.name,
3 years ago
fontSize: 13,
color: '#36596A',
3 years ago
width: 64,
height: 25,
3 years ago
bgColor: '#FFFFFF',
borderRadius: 5,
textAlign: 'center',
3 years ago
anchorX: -32,
anchorY: 4,
3 years ago
},
info: item
}
3 years ago
})
this.mapCtx.addMarkers({
markers: this.covers,
clear: false,
complete: (res) => {}
})
3 years ago
},
toThere() {
this.$u.throttle(() => {
uni.openLocation({
latitude: this.selectMarker.latitude,
longitude: this.selectMarker.longitude,
3 years ago
name: this.selectMarker.info.customer_address.address
3 years ago
})
})
}
},
computed: {
},
async onReady() {
3 years ago
await this.getNowLocation()
this.mapCtx = uni.createMapContext("map", this)
this.mapCtx.initMarkerCluster({
enableDefaultStyle: false,
zoomOnClick: true,
3 years ago
gridSize: 40
})
this.mapCtx.on("markerClusterCreate", e => {
3 years ago
console.log(e);
this.updateClusters(e.clusters)
})
3 years ago
await this.getCovers()
}
}
</script>
<style scoped lang="scss">
map {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
}
/deep/.u-drawer-bottom {
box-shadow: 2rpx 6rpx 10rpx 10rpx rgba(206, 204, 204, 0.5);
}
.top {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 50rpx;
.left {
display: flex;
align-items: center;
padding-left: 40rpx;
.name {
font-size: 32rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #333333;
}
.sex {
width: 40rpx;
height: 40rpx;
background: #FDECEC;
opacity: 0.5;
font-size: 28rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #36596A;
line-height: 40rpx;
text-align: center;
margin-left: 20rpx;
}
}
.right {
display: flex;
align-items: center;
padding-right: 40rpx;
.icon {
margin-right: 16rpx;
}
}
}
.center {
3 years ago
padding: 18rpx 0 20rpx 40rpx;
.tel {
height: 40rpx;
font-size: 28rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #36596A;
line-height: 40rpx;
display: flex;
.text {
margin-left: 10rpx;
}
}
.address {
font-size: 28rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #36596A;
display: flex;
margin-top: 8rpx;
.text {
margin-left: 10rpx;
}
}
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
3 years ago
padding-bottom: 20rpx;
.distance {
align-items: center;
display: flex;
.distance-icon {
padding-left: 40rpx;
}
.distance-text {
font-size: 24rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #A7AFBC;
padding-left: 20rpx;
}
}
.to-there {
display: flex;
align-items: center;
margin-right: 40rpx;
.to-there-text {
height: 34rpx;
font-size: 24rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #A7AFBC;
line-height: 34rpx;
margin-right: 14rpx;
}
.to-there-icon {
margin-left: 3rpx;
}
}
}
</style>