nurseWeChatAppletUI/pages/site/site.vue

236 lines
5.9 KiB
Vue
Raw Normal View History

<template>
<view class="app">
<view class="nursetation" @tap='detailed()'>
<text class="what">什么是护理站</text>
<u-icon class="icon" name="arrow-right"></u-icon>
</view>
<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">距离您{{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: [],
}
},
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() {
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseTypeCode).then(res => {
if (res.total > 0) {
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}`
})
},
detailed() {
uni.navigateTo({
url: `/pages/detail/detail`
})
},
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()
},
},
2022-12-06 10:08:19 +08:00
onShow() {},
onLoad() {
var that = this
try {
const value = uni.getStorageSync('patientId');
if (value) {
getPatientInfo(value).then(res => {
if (res.code == 200) {
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 {
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 {
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 {
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;
}
});
}
} catch (e) {}
},
}
</script>
<style lang="scss">
@import './site.scss'
</style>