From 91bdf533489611366a7a10766569fbbc10c8c3a3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 19 Jul 2024 16:51:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E5=92=8C=E8=8E=B7=E5=8F=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagesOrder/settle/settle.vue | 94 +++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 12 deletions(-) diff --git a/pagesOrder/settle/settle.vue b/pagesOrder/settle/settle.vue index 7f88f92..451f4fc 100644 --- a/pagesOrder/settle/settle.vue +++ b/pagesOrder/settle/settle.vue @@ -209,6 +209,20 @@ + + + + + + + + + + + + + + @@ -249,6 +263,7 @@ const cartStore = useCartStore(); const reservation_time = ref('') const is_storage = ref(0) + const LocationShow = ref(false) const formData = ref({ remark: "" @@ -561,21 +576,76 @@ }) const getLocation = () => { - uni.getLocation({ - type: "gcj02", + uni.getSetting({ success(res) { - location.lat = res.latitude; - location.long = res.longitude; - uni.setStorageSync('location', JSON.stringify(location)) - checkOrder(); - }, - fail() { - uni.$u.toast('获取位置当前失败,为你推荐当前门店') - checkOrder(STORE_INFO.id); - }, - complete() {} + if (res.authSetting["scope.userLocation"] == false) { + LocationShowOpen() + } else { + opensettings(true) + } + } }) } + const LocationShowOpen = () => { + LocationShow.value = true; + } + const userLocationfalse = () => { + LocationShow.value = false; + uni.$u.toast('获取位置当前失败,为你推荐当前门店') + checkOrder(STORE_INFO.id); + } + const opensettings = (a = false) => { + if (a == false) { + uni.openSetting({ + success(res) { + LocationShow.value = false; + if (res.authSetting["scope.userLocation"] == true) { + uni.authorize({ + scope: 'scope.userLocation', + success() { + uni.getLocation({ + type: "gcj02", + success(res) { + location.lat = res.latitude; + location.long = res.longitude; + uni.setStorageSync('location', JSON.stringify( + location)) + checkOrder(); + }, + }) + }, + fail(e) { + userLocationfalse() + }, + }) + } + }, + fail(e) { + userLocationfalse() + } + }); + } else { + uni.authorize({ + scope: 'scope.userLocation', + success() { + uni.getLocation({ + type: "gcj02", + success(res) { + location.lat = res.latitude; + location.long = res.longitude; + uni.setStorageSync('location', JSON.stringify(location)) + checkOrder(); + }, + }) + }, + fail(e) { + userLocationfalse() + }, + }) + + } + + } onShow(() => { getAddressList(); })