nurseWeChatAppletUI/pages/site/site.vue
2023-02-13 16:07:06 +08:00

261 lines
6.7 KiB
Vue

<template>
<view class="app">
<view class="map" style="height:35vh;">
<map style="width:100%; height:100%" scale="17" :latitude="latitude" :longitude="longitude"
:markers="markers"></map>
</view>
<view class="conNew">
<view class="addressContent" v-for="(item,index) in nursestationlist" :key="index">
<view class="lists" @tap='godetails(item)'>
<view class="nurse">{{item.nurseStationName}}</view>
<view class="distance"
v-show="homeLatitudeLongitude.homeLatitude&&homeLatitudeLongitude.homeLongitude">
距离您{{item.distance}}KM</view>
<image class="background" :src="item.stationPictureUrl" mode=""></image>
<view class="understand">
点击了解
</view>
</view>
</view>
</view>
<view class="masks" style="" v-if="mask">
<view class="mask">
<view class="picture">
<image src="../../static/locatinsmall.png"></image>
</view>
<view class="text">
请打开系统定位
</view>
<view class="btns">
<view class="bt" @tap='cancel()'>取消</view>
<view class="btn" @tap='getlocation()'>确定</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
nearbyList,
getPatientInfo
} from '@/api/site/site.js';
import baseurl from '@/api/baseurl.js'
export default {
data() {
return {
nursestationlist: [],
mask: false,
pageNum: 1,
pageSize: 10,
total: 0,
//map地图所需
id: 0, // 使用 marker点击事件 需要填写id
latitude: 39.90374,
longitude: 116.397827,
markers: [],
homeLatitudeLongitude: null,
}
},
methods: {
getlocation(value) {
var that = this
uni.openSetting({
success(res) {
if (res.authSetting['scope.userLocation']) {
// uni.getLocation({
// type: 'wgs84',
// success: function(res) {
// that.latitude = res.latitude
// that.longitude = res.longitude
// that.markers.push({
// id: 3,
// latitude: res.Latitude,
// longitude: res.Longitude,
// width: 20,
// height: 25,
// iconPath: "../../static/locatinsmall.png"
// })
// that.mask = false
// }
// });
}
}
});
},
requestinfo() {
this.pageNum = 1;
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode).then(res => {
if (res.total > 0) {
uni.removeStorageSync('Refresh');
res.rows.forEach(e => {
e.stationPictureUrl = baseurl + e.stationPictureUrl
})
this.nursestationlist = res.rows
this.mask = false
this.total = res.total
}
})
},
godetails(item) {
uni.navigateTo({
url: `/pages/nursestation/nursestation?nurseStationId=${item.nurseStationId}`
})
},
cancel() {
this.mask = false
uni.switchTab({
url: '/pages/homepage/homepage',
})
},
},
onReachBottom() {
if (this.nursestationlist.length >= this.total) {} else {
this.pageNum++;
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode, this.iptVal)
.then(res => {
res.rows.forEach(e => {
e.stationPictureUrl = baseurl + e.stationPictureUrl
this.nursestationlist.push(e)
})
})
}
},
onPullDownRefresh() { //下拉刷新
this.pageNum = 1;
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode, this.iptVal)
.then(res => {
res.rows.forEach(e => {
e.stationPictureUrl = baseurl + e.stationPictureUrl
})
this.nursestationlist = res.rows
})
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
watch: {
iptVal() {
// this.requestinfo()
},
},
onShow() {
var that = this
const value = uni.getStorageSync('patientId');
if (value) {
getPatientInfo(value).then(res => {
if (res.code == 200) {
this.homeLatitudeLongitude = res.data
if (res.data.homeLatitude && res.data.homeLongitude) {
that.latitude = res.data.homeLatitude
that.longitude = res.data.homeLongitude
that.markers.push({
id: 3,
latitude: res.data.homeLatitude,
longitude: res.data.homeLongitude,
width: 20,
height: 25,
iconPath: "../../static/locatinsmall.png"
})
that.requestinfo();
} else {
that.latitude = that.latitude
that.longitude = that.longitude
that.requestinfo();
// uni.getLocation({
// type: 'wgs84',
// success: function(resp) {
// that.latitude = resp.latitude
// that.longitude = resp.longitude
// that.markers.push({
// id: 3,
// latitude: resp.latitude,
// longitude: resp.longitude,
// width: 20,
// height: 25,
// iconPath: "../../static/locatinsmall.png"
// })
// that.requestinfo();
// },
// fail(err) {
// that.mask = true;
// }
// });
}
} else if (res.code == 9999) {
} else {
that.latitude = that.latitude
that.longitude = that.longitude
that.requestinfo();
// that.markers.push({
// uni.getLocation({
// type: 'wgs84',
// success: function(resh) {
// that.latitude = resh.latitude
// that.longitude = resh.longitude
// that.markers.push({
// id: 3,
// latitude: resh.latitude,
// longitude: resh.longitude,
// width: 20,
// height: 25,
// iconPath: "../../static/locatinsmall.png"
// })
// that.requestinfo();
// },
// fail(err) {
// that.mask = true;
// }
// });
}
})
} else {
that.latitude = that.latitude
that.longitude = that.longitude
that.requestinfo();
// uni.getLocation({
// type: 'wgs84',
// success: function(res) {
// that.latitude = res.latitude
// that.longitude = res.longitude
// that.markers.push({
// id: 3,
// latitude: res.latitude,
// longitude: res.longitude,
// width: 20,
// height: 25,
// iconPath: "../../static/locatinsmall.png"
// })
// that.requestinfo();
// },
// fail(err) {
// that.mask = true;
// }
// });
}
},
onLoad() {},
//1.分享给朋友
onShareAppMessage(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
title: '泉医到家',
path: url,
}
},
//2.分享到朋友圈
onShareTimeline(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
title: '泉医到家',
path: url,
}
},
}
</script>
<style lang="scss">
@import './site.scss'
</style>