名片部分页面。地图定位。国家下拉搜索 回收站
This commit is contained in:
+43
-54
@@ -187,11 +187,12 @@
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options);
|
||||
this.getlocahost()
|
||||
this.id = options.id;
|
||||
this.form.customer_id = options.id;
|
||||
var that = this
|
||||
this.getGrade()
|
||||
this.getlocahost()
|
||||
|
||||
this.customerdetailfn()
|
||||
this.followlistfn()
|
||||
},
|
||||
@@ -281,62 +282,50 @@
|
||||
},
|
||||
});
|
||||
},
|
||||
getlocahost(){
|
||||
// 检查定位权限
|
||||
uni.getSetting({
|
||||
success: (res) => {
|
||||
if (!res.authSetting['scope.userLocation']) {
|
||||
// 未授权,请求权限
|
||||
uni.authorize({
|
||||
scope: 'scope.userLocation',
|
||||
success: () => {
|
||||
this.getlocahost();
|
||||
},
|
||||
fail: () => {
|
||||
getlocahost() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(position) => {
|
||||
console.log('当前位置的经度:' + position.coords.longitude);
|
||||
console.log('当前位置的纬度:' + position.coords.latitude);
|
||||
this.getarrd(position.coords.longitude,position.coords.latitude)
|
||||
this.error = '';
|
||||
console.log("获取位置成功:", position);
|
||||
},
|
||||
(error) => {
|
||||
this.error = this.getErrorMessage(error);
|
||||
uni.showToast({
|
||||
title: '定位权限未授权',
|
||||
icon: 'none',
|
||||
title: this.error,
|
||||
icon: 'none'
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 已授权,直接获取定位
|
||||
this.getlocahost();
|
||||
}
|
||||
},
|
||||
});
|
||||
console.error("获取位置失败:", error);
|
||||
},
|
||||
{
|
||||
enableHighAccuracy: true,
|
||||
timeout: 10000,
|
||||
maximumAge: 0
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.error = "浏览器不支持 Geolocation API";
|
||||
uni.showToast({
|
||||
title: this.error,
|
||||
icon: 'none'
|
||||
});
|
||||
console.error("浏览器不支持 Geolocation API");
|
||||
}
|
||||
},
|
||||
getlocahost(){
|
||||
|
||||
var that = this
|
||||
uni.getLocation({
|
||||
type: 'wgs84', // 默认为 wgs84 坐标系,可选 gcj02
|
||||
success: function (res) {
|
||||
console.log('当前位置的经度:' + res.longitude);
|
||||
console.log('当前位置的纬度:' + res.latitude);
|
||||
that.getarrd(res.longitude,res.latitude)
|
||||
// 如果需要将经纬度转换为具体地址,可以使用逆地理编码
|
||||
// 这里调用 uni.chooseLocation 或第三方地图服务(如高德、腾讯地图)
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('获取位置失败:', err);
|
||||
},
|
||||
complete: function () {
|
||||
console.log('获取位置完成');
|
||||
}
|
||||
});
|
||||
|
||||
// uni.chooseLocation({
|
||||
// success: function (res) {
|
||||
// console.log('位置名称:' + res.name);
|
||||
// console.log('详细地址:' + res.address);
|
||||
// console.log('经度:' + res.longitude);
|
||||
// console.log('纬度:' + res.latitude);
|
||||
// },
|
||||
// fail: function (err) {
|
||||
// console.log('选择位置失败:', err);
|
||||
// }
|
||||
// });
|
||||
getErrorMessage(error) {
|
||||
switch (error.code) {
|
||||
case error.PERMISSION_DENIED:
|
||||
return "用户拒绝了地理位置权限";
|
||||
case error.POSITION_UNAVAILABLE:
|
||||
return "无法获取当前位置";
|
||||
case error.TIMEOUT:
|
||||
return "获取位置超时";
|
||||
default:
|
||||
return "未知错误";
|
||||
}
|
||||
},
|
||||
// 跟进记录
|
||||
followlistfn(){
|
||||
|
||||
Reference in New Issue
Block a user