feat: 实现动态拉取用户系统权限并提示权限说明

This commit is contained in:
tanjy888 2025-08-19 16:40:48 +08:00
parent 5609da82ee
commit da32049a7c
4 changed files with 80 additions and 30 deletions

View File

@ -224,7 +224,10 @@
// import emoji from "@/utils/emoji.js"; // import emoji from "@/utils/emoji.js";
import emoji from "../../static/im/emojiData.js"; import emoji from "../../static/im/emojiData.js";
import uParse from "../../uni_modules/uview-ui/components/u-parse/u-parse.vue"; import uParse from "../../uni_modules/uview-ui/components/u-parse/u-parse.vue";
import permission from "@/utils/permission.js";
const recorderManager = uni.getRecorderManager(); const recorderManager = uni.getRecorderManager();
export default { export default {
components: { uParse }, components: { uParse },
name: "tChatBar", name: "tChatBar",
@ -402,20 +405,61 @@ export default {
'<img src="$1" width="25" height="25" />' '<img src="$1" width="25" height="25" />'
); );
}, },
switchVoice() { async switchVoice() {
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"RECORD"
);
if (result != 1) {
return result
}
// #endif
this.isVoice = true; this.isVoice = true;
this.showIndex = 0; this.showIndex = 0;
}, },
switchInput() { switchInput() {
this.isVoice = false; this.isVoice = false;
}, },
uploadPictures() { async uploadPictures() {
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"EXTERNAL_STORAGE"
);
if (result != 1) {
return result
}
// #endif
this.$emit("uploadPictures"); this.$emit("uploadPictures");
}, },
photograph() { async photograph() {
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"CAMERA"
);
if (result != 1) {
return result
}
// #endif
this.$emit("photograph"); this.$emit("photograph");
}, },
uploadVideo() { async uploadVideo() {
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"CAMERA_EXTERNAL_STORAGE"
);
if (result != 1) {
return result
}
// #endif
this.$emit("uploadVideo"); this.$emit("uploadVideo");
}, },
async getMaskBottomRect() { async getMaskBottomRect() {

View File

@ -165,24 +165,10 @@ export default {
}); });
break; break;
case "IM": case "IM":
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"CAMERA_EXTERNAL_STORAGE_RECORD_AUDIO"
); //使
if (result == 1) {
uni.switchTab({
url: "/pages/IM/IM",
});
}
// #endif
// #ifdef H5
uni.switchTab({ uni.switchTab({
url: "/pages/IM/IM", url: "/pages/IM/IM",
}); });
// #endif
break; break;
case "shituzhongxin": case "shituzhongxin":

View File

@ -146,6 +146,8 @@ import { GetShopBaseInfo, UpdataShopInfo } from "../../api/shop";
import { GetBizCategoryList } from "../../api/audit"; import { GetBizCategoryList } from "../../api/audit";
import { UploadFilePromise } from "../../api/upload"; import { UploadFilePromise } from "../../api/upload";
import tpfTimeRange from "@/components/tpf-time-range/tpf-time-range.vue"; import tpfTimeRange from "@/components/tpf-time-range/tpf-time-range.vue";
import permission from "@/utils/permission.js";
export default { export default {
components: { components: {
tpfTimeRange, tpfTimeRange,
@ -219,8 +221,20 @@ export default {
url: "/pages/my/contract", url: "/pages/my/contract",
}); });
}, },
updateLogo() { async updateLogo() {
let that = this; let that = this;
// #ifdef APP-PLUS
//
let result = await permission.premissionCheck(
"EXTERNAL_STORAGE"
);
if (result != 1) {
return result
}
// #endif
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ["compressed"], sizeType: ["compressed"],

View File

@ -318,30 +318,36 @@ let permissionMap = {
android: { android: {
CAMERA_EXTERNAL_STORAGE: { CAMERA_EXTERNAL_STORAGE: {
// 相机权限/相册读写权限 // 相机权限/相册读写权限
name: "android.permission.READ_EXTERNAL_STORAGE,android.permission.WRITE_EXTERNAL_STORAGE,android.permission.CAMERA", name: "android.permission.READ_EXTERNAL_STORAGE,android.permission.CAMERA",
title: "相机/相册权限说明", title: "相机/相册权限说明",
content: content:
"便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布产品/需求、下载、与客服沟通等场景中读取和写入相册和文件内容", "用于读取您的相册和相机权限,实现发送视频或拍摄视频给好友聊天",
}, },
CAMERA: { CAMERA: {
// 相机权限 // 相机权限
name: "android.permission.CAMERA", name: "android.permission.WRITE_EXTERNAL_STORAGE,android.permission.CAMERA",
title: "相机权限说明", title: "相机权限说明",
content: "便于您使用该功能上传图片,用于与客服沟通等场景中发送拍摄图片", content: "用于读取您的相机权限,实现拍摄相片发送给好友聊天",
}, },
EXTERNAL_STORAGE: { EXTERNAL_STORAGE: {
//相册读权限 //相册读权限
name: "android.permission.READ_EXTERNAL_STORAGE,android.permission.WRITE_EXTERNAL_STORAGE", name: "android.permission.READ_EXTERNAL_STORAGE",
title: "相册读写权限说明", title: "相册读写权限说明",
content: content: "用于读取您的相册图片权限,实现发送图片给好友聊天或更换用户头像",
"便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布产品/需求、下载、与客服沟通等场景中读取和写入相册和文件内容",
}, },
CAMERA_EXTERNAL_STORAGE_RECORD_AUDIO: { CAMERA_EXTERNAL_STORAGE_RECORD_AUDIO: {
//视频录制和获取权限 //视频录制和获取权限
name: "android.permission.READ_EXTERNAL_STORAGE,android.permission.WRITE_EXTERNAL_STORAGE,android.permission.CAMERA,android.permission.RECORD_AUDIO", name: "android.permission.READ_EXTERNAL_STORAGE,android.permission.WRITE_EXTERNAL_STORAGE,android.permission.CAMERA",
title: "相机/相册和麦克风权限说明", title: "相机/相册和麦克风权限说明",
content: content:
"便于您使用该功能获取并上传视频用于发布产品/需求过程中读取和写入视频文件内容", "用于读取您的相册视频或录制视频权限,实现发送视频给好友聊天",
},
RECORD: {
//录制语音权限
name: "android.permission.RECORD_AUDIO",
title: "麦克风权限说明",
content:
"用于读取您的麦克风录音权限,实现发送语音给好友聊天",
}, },
}, },
ios: {}, ios: {},