|
@@ -57,6 +57,8 @@ import Slide from '@/pages_classify/components/Slide/index.vue'
|
|
|
import { useDict } from '@/utils/dict.js'
|
|
|
import DictTag from '@/components/DictTag/index.vue'
|
|
|
import { wxMakePhoneCall } from '@/utils/wxRequest.js'
|
|
|
+
|
|
|
+import { getLatLong } from '@/utils/adress'
|
|
|
import { computed } from 'vue'
|
|
|
const secondOrderId = ref('')
|
|
|
const detaile = ref({})
|
|
@@ -79,33 +81,36 @@ const getCurrentLocation = () => {
|
|
|
// 先检查用户是否授权了位置权限
|
|
|
uni.getSetting({
|
|
|
success: (res) => {
|
|
|
- if (!res.authSetting['scope.userLocation']) {
|
|
|
- // 如果用户未授权,先请求授权
|
|
|
- uni.authorize({
|
|
|
- scope: 'scope.userLocation',
|
|
|
- success: () => {
|
|
|
- // 授权成功后获取位置
|
|
|
- getLocation(resolve, reject);
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- console.error('位置授权失败:', err);
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '需要获取您的位置信息,请在设置中打开位置权限',
|
|
|
- confirmText: '去设置',
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.openSetting();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- reject(err);
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- // 已授权,直接获取位置
|
|
|
- getLocation(resolve, reject);
|
|
|
- }
|
|
|
+ console.log("TCL: getCurrentLocation -> res", res)
|
|
|
+ // 已授权,直接获取位置
|
|
|
+ getLocation(resolve, reject);
|
|
|
+ // if (!res.authSetting['scope.getFuzzyLocation']) {
|
|
|
+ // // 如果用户未授权,先请求授权
|
|
|
+ // uni.authorize({
|
|
|
+ // scope: 'scope.getFuzzyLocation',
|
|
|
+ // success: () => {
|
|
|
+ // // 授权成功后获取位置
|
|
|
+ // getLocation(resolve, reject);
|
|
|
+ // },
|
|
|
+ // fail: (err) => {
|
|
|
+ // console.error('位置授权失败:', err);
|
|
|
+ // uni.showModal({
|
|
|
+ // title: '提示',
|
|
|
+ // content: '需要获取您的位置信息,请在设置中打开位置权限',
|
|
|
+ // confirmText: '去设置',
|
|
|
+ // success: (res) => {
|
|
|
+ // if (res.confirm) {
|
|
|
+ // uni.openSetting();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // reject(err);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // // 已授权,直接获取位置
|
|
|
+ // getLocation(resolve, reject);
|
|
|
+ // }
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
console.error('获取设置失败:', err);
|
|
@@ -118,10 +123,10 @@ const getCurrentLocation = () => {
|
|
|
// 获取位置的具体实现
|
|
|
const getLocation = (resolve, reject) => {
|
|
|
// 删除开发环境模拟位置的代码,始终获取真实位置
|
|
|
- uni.getLocation({
|
|
|
+ uni.getFuzzyLocation({
|
|
|
type: 'gcj02',
|
|
|
- isHighAccuracy: true, // 高精度
|
|
|
- highAccuracyExpireTime: 3000, // 高精度过期时间
|
|
|
+ // isHighAccuracy: true, // 高精度
|
|
|
+ // highAccuracyExpireTime: 3000, // 高精度过期时间
|
|
|
success: (res) => {
|
|
|
const { longitude, latitude } = res;
|
|
|
console.log('当前位置 - 经度:', longitude);
|
|
@@ -211,12 +216,13 @@ const change = async (e) => {
|
|
|
// })
|
|
|
|
|
|
// 获取开始服务时的位置
|
|
|
- const locationData = await getCurrentLocation().catch(err => {
|
|
|
- // uni.hideLoading()
|
|
|
- verify.value.initialization()
|
|
|
- throw new Error('无法获取位置信息,请确保已开启位置权限')
|
|
|
- })
|
|
|
-
|
|
|
+ // const locationData = await getCurrentLocation().catch(err => {
|
|
|
+ // // uni.hideLoading()
|
|
|
+ // verify.value.initialization()
|
|
|
+ // throw new Error('无法获取位置信息,请确保已开启位置权限')
|
|
|
+ // })
|
|
|
+
|
|
|
+ const locationData =await getLatLong()
|
|
|
// 构建参数字符串
|
|
|
const params = `secondOrderId=${secondOrderId.value}&serviceStartLongitude=${locationData.longitude.toString()}&serviceStartLatitude=${locationData.latitude.toString()}`
|
|
|
|
|
@@ -250,7 +256,7 @@ const change = async (e) => {
|
|
|
// uni.showLoading({
|
|
|
// title: '获取位置信息...'
|
|
|
// })
|
|
|
-
|
|
|
+
|
|
|
uni.showToast({
|
|
|
title: '操作成功',
|
|
|
icon: 'success',
|
|
@@ -279,23 +285,23 @@ onLoad((options) => {
|
|
|
secondOrderId.value = options.secondOrderId
|
|
|
getOrderDetail()
|
|
|
|
|
|
- // 初始检查位置权限
|
|
|
- getCurrentLocation().then(location => {
|
|
|
- console.log('位置权限正常,可以获取位置');
|
|
|
- }).catch(err => {
|
|
|
- console.error('位置权限检查失败', err);
|
|
|
- uni.showModal({
|
|
|
- title: '位置权限提示',
|
|
|
- content: '服务需要获取您的位置信息,请确保已开启位置权限',
|
|
|
- confirmText: '去设置',
|
|
|
- cancelText: '知道了',
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.openSetting();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ // // 初始检查位置权限
|
|
|
+ // getCurrentLocation().then(location => {
|
|
|
+ // console.log('位置权限正常,可以获取位置');
|
|
|
+ // }).catch(err => {
|
|
|
+ // console.error('位置权限检查失败', err);
|
|
|
+ // uni.showModal({
|
|
|
+ // title: '位置权限提示',
|
|
|
+ // content: '服务需要获取您的位置信息,请确保已开启位置权限',
|
|
|
+ // confirmText: '去设置',
|
|
|
+ // cancelText: '知道了',
|
|
|
+ // success: (res) => {
|
|
|
+ // if (res.confirm) {
|
|
|
+ // uni.openSetting();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // });
|
|
|
})
|
|
|
onUnload(() => {
|
|
|
clearInterval(timer)
|