feat: 添加位置授权和获取功能
This commit is contained in:
parent
e2ae755323
commit
91bdf53348
|
@ -209,6 +209,20 @@
|
||||||
<up-modal :show="showModal" title="您还没设置密码" :closeOnClickOverlay="true" zoom confirmText='去设置' showCancelButton
|
<up-modal :show="showModal" title="您还没设置密码" :closeOnClickOverlay="true" zoom confirmText='去设置' showCancelButton
|
||||||
@close='showModal=false' @cancel='showModal=false' @confirm="navgo('/pagesOrder/setPayPassword/index')"
|
@close='showModal=false' @cancel='showModal=false' @confirm="navgo('/pagesOrder/setPayPassword/index')"
|
||||||
confirmColor='#27B52F' cancelText='取消'></up-modal>
|
confirmColor='#27B52F' cancelText='取消'></up-modal>
|
||||||
|
<up-popup :show="LocationShow" mode="bottom" @open="LocationShowOpen()">
|
||||||
|
<view style="margin: 40rpx 10rpx;">
|
||||||
|
<up-row customStyle="margin-bottom: 10px" gutter="10">
|
||||||
|
<up-col span="6">
|
||||||
|
<up-button text="取消" @click="userLocationfalse()"></up-button>
|
||||||
|
</up-col>
|
||||||
|
<up-col span="6">
|
||||||
|
<up-button type="primary" text="设置授权" color="#20B128" @click="opensettings()"></up-button>
|
||||||
|
</up-col>
|
||||||
|
</up-row>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</up-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -249,6 +263,7 @@
|
||||||
const cartStore = useCartStore();
|
const cartStore = useCartStore();
|
||||||
const reservation_time = ref('')
|
const reservation_time = ref('')
|
||||||
const is_storage = ref(0)
|
const is_storage = ref(0)
|
||||||
|
const LocationShow = ref(false)
|
||||||
|
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
remark: ""
|
remark: ""
|
||||||
|
@ -561,21 +576,76 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const getLocation = () => {
|
const getLocation = () => {
|
||||||
uni.getLocation({
|
uni.getSetting({
|
||||||
type: "gcj02",
|
|
||||||
success(res) {
|
success(res) {
|
||||||
location.lat = res.latitude;
|
if (res.authSetting["scope.userLocation"] == false) {
|
||||||
location.long = res.longitude;
|
LocationShowOpen()
|
||||||
uni.setStorageSync('location', JSON.stringify(location))
|
} else {
|
||||||
checkOrder();
|
opensettings(true)
|
||||||
},
|
}
|
||||||
fail() {
|
}
|
||||||
uni.$u.toast('获取位置当前失败,为你推荐当前门店')
|
|
||||||
checkOrder(STORE_INFO.id);
|
|
||||||
},
|
|
||||||
complete() {}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
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(() => {
|
onShow(() => {
|
||||||
getAddressList();
|
getAddressList();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue