MapselectPoint() {
// #ifdef APP-PLUS
var that = this;
var systemSet = permision.checkSystemEnableLocation(); // 手机系统中定位权限配置
// console.log(autorSet, systemSet)
if (that.judgeClient() == "Android") {
const appAuthorizeSetting = uni.getAppAuthorizeSetting();
var autorSet = appAuthorizeSetting.locationAuthorized; // 应用权限配置
if (autorSet == 'authorized') {
if (systemSet) {
// 开启定位权限并且开启手机定位服务
uni.chooseLocation({
success(res) {
that.latitude = res.latitude;
that.longitude = res.longitude;
// 将选择的地理位置保存到本地
// uni.setStorageSync("selectMapItem", JSON.stringify(res));
that.textAreaPoint = res.address;
that.getadCode();
}
})
} else {
uni.showModal({
title: '提示',
content: '请打开手机系统中定位服务',
showCancel: false,
success(res) {
if (res.confirm) {}
}
})
}
} else {
this.selectTip('位置');
}
} else if (that.judgeClient() == "iOS") {
var cllocationManger = plus.ios.import("CLLocationManager");
var enable = cllocationManger.locationServicesEnabled();
var status = cllocationManger.authorizationStatus();
plus.ios.deleteObject(cllocationManger);
let reposi = permision.judgeIosPermission('location');
if (enable && status != 2) {
// console.log("手机系统的定位已经打开");
if (!reposi) {
that.selectTip('位置');
} else {
// 开启定位权限并且开启手机定位服务
uni.chooseLocation({
success(res) {
console.log("rereres", res)
that.latitude = res.latitude;
that.longitude = res.longitude;
// 将选择的地理位置保存到本地
// uni.setStorageSync("selectMapItem", JSON.stringify(res));
that.textAreaPoint = res.address;
that.getadCode();
}
})
}
} else if (enable && status == 2) {
that.selectTip('位置');
} else {
uni.showModal({
title: '提示',
content: '请前往设置-隐私-定位服务打开定位服务功能',
showCancel: false, // 不显示取消按钮
success() {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
}
});
}
}
// return
// #endif
},
3***@qq.com
- 发布:2024-03-26 16:18
- 更新:2024-03-26 16:19
- 阅读:179