// 安卓相机权限
androidCameraPermiss(index){
plus.android.requestPermissions(['android.permission.CAMERA'],(e) => {
if (e.deniedAlways.length > 0) {
this.androidAuthCamera = false
// 弹出提示框解释为何需要权限,引导用户打开设置页面开启
uni.showModal({
title: '提示',
content: '请打开手机相机相册功能(点击确定后在权限中授权相机相册功能)',
// showCancel: false, // 不显示取消按钮
success(res) {
if (res.confirm) {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass(
"android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(),
null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
}
});
} else if (e.deniedPresent.length > 0) { //权限被临时拒绝
this.androidAuthCamera = false
// 弹出提示框解释为何需要权限,可再次调用plus.android.requestPermissions申请权限
uni.showModal({
title: '提示',
content: '请打开手机相机功能(点击确定后在权限中授权相机功能)',
// showCancel: false, // 不显示取消按钮
success(res) {
if (res.confirm) {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass(
"android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(),
null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
}
});
} else {
plus.android.requestPermissions(['android.permission.READ_EXTERNAL_STORAGE'], (e) => {
if (e.deniedAlways.length > 0) { //权限被永久拒绝
// 弹出提示框解释为何需要权限,引导用户打开设置页面开启
uni.showModal({
title: '提示',
content: '请打开相册存储功能(点击确定后在权限中授权相册存储功能)',
// showCancel: false, // 不显示取消按钮
success(res) {
if (res.confirm) {
var Intent = plus.android.importClass(
"android.content.Intent");
var Settings = plus.android.importClass(
"android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings
.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity
.getPackageName(),
null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
}
});
} else if (e.deniedPresent.length > 0) { //权限被临时拒绝
this.androidAuthCamera = false
// 弹出提示框解释为何需要权限,可再次调用plus.android.requestPermissions申请权限
uni.showModal({
title: '提示',
content: '请打开相册存储功能(点击确定后在权限中授权相册存储功能)',
// showCancel: false, // 不显示取消按钮
success(res) {
if (res.confirm) {
var Intent = plus.android.importClass(
"android.content.Intent");
var Settings = plus.android.importClass(
"android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings
.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity
.getPackageName(),
null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
}
});
} else {
this.androidAuthCamera = true
// 选择照片 uni.chooseImage()
this.chooseImage(index)
}
})
}
})
},