|
|
|
@ -83,121 +83,10 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const calculateDistance = (lat1, lon1, lat2, lon2, radius = 6371) => {
|
|
|
|
|
|
|
|
const toRadians = (degrees) => degrees * Math.PI / 180;
|
|
|
|
|
|
|
|
const lat1Rad = toRadians(lat1);
|
|
|
|
|
|
|
|
const lon1Rad = toRadians(lon1);
|
|
|
|
|
|
|
|
const lat2Rad = toRadians(lat2);
|
|
|
|
|
|
|
|
const lon2Rad = toRadians(lon2);
|
|
|
|
|
|
|
|
const dLat = lat2Rad - lat1Rad;
|
|
|
|
|
|
|
|
const dLon = lon2Rad - lon1Rad;
|
|
|
|
|
|
|
|
const a = Math.sin(dLat / 2) ** 2 + Math.sin(dLon / 2) ** 2 * Math.cos(lat1Rad) * Math.cos(lat2Rad);
|
|
|
|
|
|
|
|
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
|
|
|
|
return (radius * c).toFixed(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const lola = ref({
|
|
|
|
|
|
|
|
longitude: 0,
|
|
|
|
|
|
|
|
latitude: 0
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getHospital = () => {
|
|
|
|
|
|
|
|
if ($store.config.hospital.length > 0) {
|
|
|
|
|
|
|
|
if (lola.value.longitude + lola.value.latitude > 0) {
|
|
|
|
|
|
|
|
for (let i = 0; i < $store.config.hospital.length; i++) {
|
|
|
|
|
|
|
|
let long = calculateDistance(
|
|
|
|
|
|
|
|
lola.value.latitude,
|
|
|
|
|
|
|
|
lola.value.longitude,
|
|
|
|
|
|
|
|
$store.config.hospital[i].latitude,
|
|
|
|
|
|
|
|
$store.config.hospital[i].longitude)
|
|
|
|
|
|
|
|
if (long === 'NaN') {
|
|
|
|
|
|
|
|
$store.config.hospital[i].long = 0
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$store.config.hospital[i].long = long
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let list = $store.config.hospital
|
|
|
|
|
|
|
|
list.sort((a, b) => {
|
|
|
|
|
|
|
|
if (a.long === b.long) {
|
|
|
|
|
|
|
|
return a.id - b.id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.long - b.long
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
let hospital_id = $store.save.hospital
|
|
|
|
|
|
|
|
if (!!hospital_id) {
|
|
|
|
|
|
|
|
hospital_id = ''
|
|
|
|
|
|
|
|
for (let i in list) {
|
|
|
|
|
|
|
|
if (list[i].id === hospital_id) {
|
|
|
|
|
|
|
|
hospital_info.value = {
|
|
|
|
|
|
|
|
id: list[i].id,
|
|
|
|
|
|
|
|
name: list[i].name,
|
|
|
|
|
|
|
|
long: list[i].long
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hospital_id = list[i].id
|
|
|
|
|
|
|
|
$store.saveInfo({
|
|
|
|
|
|
|
|
hospital: list[i].id
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hospital_id) {
|
|
|
|
|
|
|
|
hospital_info.value = {
|
|
|
|
|
|
|
|
id: list[0].id,
|
|
|
|
|
|
|
|
name: list[0].name,
|
|
|
|
|
|
|
|
long: list[0].long
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$store.saveInfo({
|
|
|
|
|
|
|
|
hospital: list[0].id
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
hospital_info.value = {
|
|
|
|
|
|
|
|
id: list[0].id,
|
|
|
|
|
|
|
|
name: list[0].name,
|
|
|
|
|
|
|
|
long: list[0].long
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$store.saveInfo({
|
|
|
|
|
|
|
|
hospital: list[0].id
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
hospital_info.value = {
|
|
|
|
|
|
|
|
id: $store.config.hospital[0].id,
|
|
|
|
|
|
|
|
name: $store.config.hospital[0].name,
|
|
|
|
|
|
|
|
long: 0,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hospital_info = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getLong = (time = 0) => {
|
|
|
|
|
|
|
|
uni.getLocation({
|
|
|
|
|
|
|
|
type: 'wgs84',
|
|
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
|
|
lola.value = {
|
|
|
|
|
|
|
|
longitude: res.longitude,
|
|
|
|
|
|
|
|
latitude: res.latitude
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getHospital()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
fail: (e) => {
|
|
|
|
|
|
|
|
lola.value = {
|
|
|
|
|
|
|
|
longitude: 0,
|
|
|
|
|
|
|
|
latitude: 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getHospital()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const user_box_ref = ref(null)
|
|
|
|
const user_box_ref = ref(null)
|
|
|
|
const userBoxRef = (e) => {
|
|
|
|
const userBoxRef = (e) => {
|
|
|
|
if (!user_box_ref.value) {
|
|
|
|
if (!user_box_ref.value) {
|
|
|
|
user_box_ref.value = e
|
|
|
|
user_box_ref.value = e
|
|
|
|
getLong()
|
|
|
|
|
|
|
|
getUserInfo()
|
|
|
|
getUserInfo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -279,28 +168,6 @@
|
|
|
|
return item ? item.value : '';
|
|
|
|
return item ? item.value : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onShow(() => {
|
|
|
|
onShow(() => {
|
|
|
|
uni.getLocation({
|
|
|
|
|
|
|
|
type: 'wgs84',
|
|
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
|
|
lola.value = {
|
|
|
|
|
|
|
|
longitude: res.longitude,
|
|
|
|
|
|
|
|
latitude: res.latitude
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
fail: (e) => {
|
|
|
|
|
|
|
|
console.log(e)
|
|
|
|
|
|
|
|
lola.value = {
|
|
|
|
|
|
|
|
longitude: 0,
|
|
|
|
|
|
|
|
latitude: 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!!user_box_ref.value) {
|
|
|
|
|
|
|
|
getLong()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getUserInfo()
|
|
|
|
getUserInfo()
|
|
|
|
let buyinfo=$store.getBuyInfo()
|
|
|
|
let buyinfo=$store.getBuyInfo()
|
|
|
|
buyinfo.combo_id=''
|
|
|
|
buyinfo.combo_id=''
|
|
|
|
|