From a987eccb27891bbfaae334b7fa0e892ee2640271 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期一, 20 四月 2026 17:20:13 +0800
Subject: [PATCH] 调接口加页面
---
small-program/pages/index/index.vue | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/small-program/pages/index/index.vue b/small-program/pages/index/index.vue
index 1abd847..a5dc843 100644
--- a/small-program/pages/index/index.vue
+++ b/small-program/pages/index/index.vue
@@ -145,10 +145,54 @@
})
},
handleLocation() {
- uni.showToast({
- title: '瀹氫綅鍔熻兘寰呮帴鍏�',
- icon: 'none'
- })
+ var that = this;
+ uni.openSetting({
+ success: (res) => {
+ if (res.authSetting['scope.userLocation']) {
+ that.positioning()
+ }
+ }
+ });
+ },
+ // 瀹氫綅
+ positioning() {
+ var that = this;
+ uni.getLocation({
+ type: 'gcj02',
+ highAccuracyExpireTime: 3000,
+ isHighAccuracy: true,
+ success: function (addr) {
+ const locParam = { latitude: addr.latitude, longitude: addr.longitude };
+ const qqmapsdk = new QQMapWX({
+ key: 'WE3BZ-HN6WS-ONDOH-62QCV-MNL6F-5NFNE'
+ });
+ qqmapsdk.reverseGeocoder({
+ locParam,
+ success: async function(res) {
+ console.log(res, '==================鑾峰彇鍦板潃');
+ let info = res.result;
+ locParam.province = info.address_component.province;
+ locParam.city = info.address_component.city;
+ locParam.area = info.address_component.district;
+ locParam.street = info.address_component.street;
+ var ta = info.address || '鍦板潃鑾峰彇澶辫触' ;
+ if(info.formatted_addresses && info.formatted_addresses.recommend){
+ ta =info.formatted_addresses.recommend
+ }
+ locParam.address = ta
+ const resCity = await that.$u.api.getCityByName({ cityName: locParam.city })
+ if (resCity.code === 200) {
+ locParam.cityId = resCity.data.id
+ }
+ that.$store.commit('setPosition',locParam)
+ that.$isResolve()
+ },
+ fail: (err) => {
+ that.$isResolve()
+ }
+ });
+ }
+ });
},
goStoragePage() {
uni.navigateTo({
--
Gitblit v1.9.3