修改 授权
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<template>
|
||||
<view class="con-body">
|
||||
<view class="con-bg">
|
||||
<!-- 头部 -->
|
||||
<customHeader ref="customHeaderRef" :title="'搜索'"
|
||||
:leftFlag="true" :rightFlag="false"
|
||||
></customHeader>
|
||||
<!-- 高度来避免头部遮挡 -->
|
||||
<view class="top-height"></view>
|
||||
|
||||
<customSearch :type="type"></customSearch>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import customHeader from '@/components/customHeader.vue'
|
||||
import customSearch from '@/components/customSearch.vue'
|
||||
|
||||
let type=ref(1);
|
||||
onLoad(async(opt) => {
|
||||
console.log(opt.type)
|
||||
type.value = opt.type;
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -42,8 +42,6 @@ export const requestAndroidPermissionAsync = (systemInfo, permissions) => {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 安卓同步调用
|
||||
export const requestAndroidPermission = (systemInfo) => {
|
||||
let granted = false;
|
||||
@@ -123,18 +121,66 @@ const goPermission = () => {
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转授权按钮
|
||||
// 跳转授权
|
||||
const jumpAuthPermission = () => {
|
||||
|
||||
var main = plus.android.runtimeMainActivity();
|
||||
var Intent = plus.android.importClass('android.content.Intent');
|
||||
var Uri = plus.android.importClass('android.net.Uri');
|
||||
var Build = plus.android.importClass('android.os.Build');
|
||||
var Settings = plus.android.importClass('android.provider.Settings');
|
||||
var PackageManager = plus.android.importClass('android.content.pm.PackageManager');
|
||||
var pkg = main.getPackageName();
|
||||
var intent = new Intent('android.settings.APPLICATION_DETAILS_SETTINGS');
|
||||
intent.setData(Uri.parse('package:' + pkg));
|
||||
main.startActivity(intent);
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/loading/loading',
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
var intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
try {
|
||||
// 尝试直接跳转到存储权限设置(Android 13+ 支持)
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
// Android 13+ 尝试直接打开存储权限页面
|
||||
intent.setAction(Settings.ACTION_MANAGE_APP_PERMISSIONS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, pkg);
|
||||
// 指定权限类型为存储(需要Android 13+支持)
|
||||
intent.putExtra(Settings.EXTRA_PERMISSION_NAME, "android.permission.READ_EXTERNAL_STORAGE");
|
||||
}
|
||||
// Android 11-12 尝试直接跳转到权限列表
|
||||
else if (Build.VERSION.SDK_INT >= 30) {
|
||||
intent.setAction(Settings.ACTION_MANAGE_APP_PERMISSIONS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, pkg);
|
||||
}
|
||||
// Android 6.0-10 跳转到应用详情页(用户需手动点击权限)
|
||||
else if (Build.VERSION.SDK_INT >= 23) {
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
var uri = Uri.fromParts("package", pkg, null);
|
||||
intent.setData(uri);
|
||||
}
|
||||
// 低版本系统
|
||||
else {
|
||||
intent.setAction(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
|
||||
}
|
||||
|
||||
main.startActivity(intent);
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/loading/loading',
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
} catch (e) {
|
||||
// 异常情况下降级处理
|
||||
console.error("跳转存储权限页面失败,使用备用方案", e);
|
||||
var fallbackIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
fallbackIntent.setData(Uri.parse('package:' + pkg));
|
||||
fallbackIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
main.startActivity(fallbackIntent);
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/loading/loading',
|
||||
});
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user