From f7e0dfa745aa287e7de138a0cda24876fc934e65 Mon Sep 17 00:00:00 2001 From: Wik-T <812952667@qq.com> Date: Thu, 26 May 2022 10:46:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9H5=20=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/goods/refuel-details/refuel-details.vue | 4 +-- pages/tabBar/home/home.vue | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pages/goods/refuel-details/refuel-details.vue b/pages/goods/refuel-details/refuel-details.vue index 19a758e..3639b7f 100644 --- a/pages/goods/refuel-details/refuel-details.vue +++ b/pages/goods/refuel-details/refuel-details.vue @@ -264,7 +264,7 @@ latitude: app.globalData.latitude, longitude: app.globalData.longitude, isTyAgent: this.isTyAgent - } + } recentGasStation(params).then(res => { uni.hideLoading(); if (res.return_code == '000000') { @@ -304,7 +304,7 @@ latitude: app.globalData.latitude, longitude: app.globalData.longitude, isTyAgent: this.isTyAgent - } + } getGasDetailByStoreKey(params).then(res => { uni.hideLoading(); if (res.return_code == '000000') { diff --git a/pages/tabBar/home/home.vue b/pages/tabBar/home/home.vue index 4864c21..9a7295d 100644 --- a/pages/tabBar/home/home.vue +++ b/pages/tabBar/home/home.vue @@ -249,7 +249,12 @@ }) // #endif //定位 + // #ifdef MP this.postionIng(); + // #endif + // #ifdef H5 + this.getCoordinates(); + // #endif uni.getStorage({ key: "user", success(e) { @@ -428,6 +433,26 @@ } }) }, + //H5 获取定位 + getCoordinates() { + let that = this; + // 获取当前地理位置信息 + let data = { + key: "7UMBZ-HFEHX-HSD4Q-Z3QY6-OQKN7-2QBDB" //密钥,需要在腾讯位置服务官网(https://lbs.qq.com/)申请自己的密钥。 + }; + let url = "https://apis.map.qq.com/ws/location/v1/ip"; //地理位置信息接口(根据IP自动获取当前城市位置信息) + data.output = "jsonp"; + //判断用户是否输入了搜索关键字,若没有输入搜索关键字则调用根据IP自动获取当前城市位置信息的接口。 + this.$jsonp(url, data) + .then(res => { + app.globalData.latitude = res.result.location.lat; + app.globalData.longitude = res.result.location.lng; + that.getUserLocation(res.result.location.lng, res.result.location.lat); + }) + .catch(error => { + console.log(error); + }); + }, //经纬度转换 findByLatAndLng(item, item1) { let that = this;