From fb05bfa40c16bae1978d65018d250439a23f7cfc Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Wed, 11 Feb 2026 19:32:49 +0800
Subject: [PATCH] feat:二级页获取权限
---
uniapps/work-app/src/subPackages/voiceCallDetail/index.vue | 56 ++++++++++++++++++++++++++------------------------------
1 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/uniapps/work-app/src/subPackages/voiceCallDetail/index.vue b/uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
index 86c915e..ffe9134 100644
--- a/uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
+++ b/uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
@@ -23,37 +23,33 @@
*/
async function requestAndroidMicPermission() {
try {
- // 使用 uni 的权限 API(需要 HBuilderX 3.4.0+)
- if (uni.requestPermissions) {
- const result = await uni.requestPermissions({
- permissions: ['android.permission.RECORD_AUDIO']
- })
-
- console.log('权限请求结果:', result)
-
- if (result[0].granted) {
- console.log('✅ 麦克风权限已授予')
- return true
- } else {
- console.warn('⚠️ 麦克风权限被拒绝')
-
- // 可以提示用户
- uni.showModal({
- title: '权限提示',
- content: '语音通话需要麦克风权限,请前往设置开启',
- showCancel: false,
- success: () => {
- // 跳转到应用设置
- plus.runtime.openURL(plus.runtime.getProperty('package') + '://settings')
- }
- })
- return false
- }
- }
+ // 获取麦克风权限
+// #ifdef APP-PLUS
+plus.android.requestPermissions(
+ ['android.permission.RECORD_AUDIO'],
+ (result) => {
+ if (result.granted.length > 0) {
+ console.log('麦克风权限已获取')
+ }
+ if (result.deniedAlways.length > 0) {
+ uni.showModal({
+ title: '提示',
+ content: '需要麦克风权限才能正常使用语音功能,请前往系统设置开启',
+ success(res) {
+ if (res.confirm) {
+ plus.runtime.openURL('app-settings:')
+ }
+ },
+ })
+ }
+ },
+ (error) => {
+ console.error('请求麦克风权限失败:', error)
+ }
+)
+// #endif
- // 降级方案:使用原生方法
- return await requestAndroidMicPermissionNative()
-
+
} catch (error) {
console.error('❌ 请求麦克风权限失败:', error)
return false
--
Gitblit v1.9.3