From 8c09b60ae25853aeaecc426ce1f4ce9cc83794f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E4=BB=9488?= <> Date: Wed, 8 Jul 2026 22:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉定位 --- h5/common/Top.vue | 44 ----------- h5/pages/main/index/index.vue | 133 ---------------------------------- 2 files changed, 177 deletions(-) diff --git a/h5/common/Top.vue b/h5/common/Top.vue index 29ed02f..90d3d17 100644 --- a/h5/common/Top.vue +++ b/h5/common/Top.vue @@ -50,7 +50,6 @@ uni.hideLoading() $response(response, () => { info.value=response.data - getLong() }) } const tabPatients = () => { @@ -58,50 +57,7 @@ url: "/pages/user/choose/choose", }); }; - let lola=ref(null) let hospital_long=ref(''); - const getLong = (time = 0) => { - uni.getLocation({ - type: 'wgs84', - success: (res) => { - console.log(res) - lola.value = { - longitude: res.longitude, - latitude: res.latitude - } - let long = calculateDistance( - lola.value.latitude, - lola.value.longitude, - - $store.config.hospital[0].latitude, - $store.config.hospital[0].longitude) - if (long === 'NaN') { - hospital_long.value=0 - } else { - hospital_long.value=long - } - }, - fail: (e) => { - lola.value = { - longitude: 0, - latitude: 0 - } - - } - }); - } - 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); - } onShow(() => { getBaseInfo() diff --git a/h5/pages/main/index/index.vue b/h5/pages/main/index/index.vue index 7bdc2a8..f5050a9 100644 --- a/h5/pages/main/index/index.vue +++ b/h5/pages/main/index/index.vue @@ -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 userBoxRef = (e) => { if (!user_box_ref.value) { user_box_ref.value = e - getLong() getUserInfo() } } @@ -279,28 +168,6 @@ return item ? item.value : ''; } 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() let buyinfo=$store.getBuyInfo() buyinfo.combo_id=''