From 75ce1ab5915837eae080fc9473b705e270fbf1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E6=B4=81?= <209192278@qq.com> Date: Mon, 20 Nov 2023 21:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=93=E6=B4=81=20:=20=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=A1=86=E5=8F=AA=E6=98=BE=E7=A4=BA=E7=A1=AE=E8=AE=A4=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DropDown/DropDown.vue | 19 ++--- components/InputAndSwiper/InputAndSwiper.vue | 7 +- pages/index/index.vue | 89 +++++++++++++++++++- 3 files changed, 96 insertions(+), 19 deletions(-) diff --git a/components/DropDown/DropDown.vue b/components/DropDown/DropDown.vue index 29e8fe5..5d363b2 100644 --- a/components/DropDown/DropDown.vue +++ b/components/DropDown/DropDown.vue @@ -1,27 +1,22 @@ @@ -60,9 +55,9 @@ } }, created() { - this.postlist[0]=JSON.parse(uni.getStorageSync('classList')) + this.postlist[0] = JSON.parse(uni.getStorageSync('classList')) // this.postlist[0].unshift('全部') - this.postlist[1]=JSON.parse(uni.getStorageSync('regionList')) + this.postlist[1] = JSON.parse(uni.getStorageSync('regionList')) }, methods: { changeActiveIndex(index) { diff --git a/components/InputAndSwiper/InputAndSwiper.vue b/components/InputAndSwiper/InputAndSwiper.vue index 478d6b2..92f06ff 100644 --- a/components/InputAndSwiper/InputAndSwiper.vue +++ b/components/InputAndSwiper/InputAndSwiper.vue @@ -46,14 +46,13 @@ options: { styleIsolation: 'shared', // 解除样式隔离 }, - created() { - }, + created() {}, methods: { //点击轮播图 handleSwiperList(currentNum, bannerURL) { - const item=bannerURL[currentNum] + const item = bannerURL[currentNum] uni.navigateTo({ - url: item.link+`?id=${item.param}&type=${item.type}` + url: item.link + `?id=${item.param}&type=${item.type}` }) }, } diff --git a/pages/index/index.vue b/pages/index/index.vue index 04a0159..7536d51 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -179,6 +179,32 @@ }, fail(err) { console.log("获取经纬度失败", err); + uni.getSystemInfo({ + success: (res) => { + if (!res.locationEnabled || !res.locationAuthorized) { + uni.showModal({ + content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启', + confirmText: "确认", + showCancel: false, + success: (res) => { + if (res.confirm) { + // uni.openSetting({ + // success: (res) => { + // console.log(res); + that.getUserLocation(); + // } + // }) + } else { + console.log('取消'); + return false; + } + } + }) + } else { + that.getUserLocation() + } + } + }) }, }); }, @@ -189,20 +215,77 @@ success: function(res) { if (res.authSetting['scope.userFuzzyLocation']) { console.log('用户已经授权定位权限'); + uni.getSystemInfo({ + success: (res) => { + if (!res.locationEnabled || !res.locationAuthorized) { + uni.showModal({ + content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启', + confirmText: "确认", + showCancel: false, + success: (res) => { + if (res.confirm) { + // uni.openSetting({ + // success: (res) => { + // console.log(res); + that.getUserLocation(); + // } + // }) + } else { + console.log('取消'); + return false; + } + } + }) + } else { + that.getUserLocation() + } + } + }) + // that.getUserLocation() } else { console.log('用户未授权定位权限'); uni.authorize({ scope: 'scope.userFuzzyLocation', success: function() { console.log('授权成功'); - that.getUserLocation() + uni.getSystemInfo({ + success: (res) => { + if (!res.locationEnabled || !res.locationAuthorized) { + // uni.showToast({ + // title: '请确保手机系统定位已开启', + // icon: 'none', + // duration: 2000, + // }) + uni.showModal({ + content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启', + confirmText: "确认", + showCancel: false, + success: (res) => { + if (res.confirm) { + // uni.openSetting({ + // success: (res) => { + // console.log(res); + that.getUserLocation(); + // } + // }) + } else { + console.log('取消'); + return false; + } + } + }) + } else { + that.getUserLocation() + } + } + }) }, fail: function() { console.log('授权失败'); uni.showModal({ - content: '检测到您没打开获取信息功能权限,是否去设置打开?', + content: '检测到您没打开手机系统定位权限,请确保手机系统定位已开启', confirmText: "确认", - cancelText: '取消', + showCancel: false, success: (res) => { if (res.confirm) { uni.openSetting({