# DCToolBox **Repository Path**: da-chaoomt/dctool-box ## Basic Information - **Project Name**: DCToolBox - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-09 - **Last Updated**: 2025-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: 个人小程序, 个人小程序 ## README # DCToolBox #### 介绍 {**以下是 Gitee 平台说明,您可以替换此简介** Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} #### 软件架构 软件架构说明 #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) ``` const recorderManager = uni.getRecorderManager(); onLoad(option) { let self = this; recorderManager.onStop(function (res) { console.log("res",res) self.end_time = Math.round(new Date().getTime() / 1000); let voicePath = res.tempFilePath; self.voicePath = voicePath; self.closeTimeOut(); uni.showToast({ icon: 'loading', title: "请稍后...", duration: 0 }); uni.uploadFile({ url: self.upload_url, filePath: voicePath, name: "file", formData: { id: self.phoneInfo.id, start_time: self.start_time, end_time: self.end_time, phone: self.phoneNumber }, header: { Authorization: "Bearer " + uni.getStorageSync(EnumData.token) }, success: (res) => { // console.log("文件上传成功") console.log(res.data); }, fail(err) { console.log("文件上传失败") console.log(err); }, complete() { self.start_time = 0; self.end_time = 0; uni.hideToast(); } }) }); this.getCallStatus(); } getCallStatus() { let that = this; let maintest = plus.android.runtimeMainActivity(); let Contexttest = plus.android.importClass("android.content.Context"); let telephonyManager = plus.android.importClass("android.telephony.TelephonyManager"); let telManager = plus.android.runtimeMainActivity().getSystemService(Contexttest.TELEPHONY_SERVICE); let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', { onReceive: function (Contexttest, intent) { plus.android.importClass(intent); let phoneStatus = telManager.getCallState(); that.callStatus = phoneStatus; //电话状态 0->空闲状态 1->振铃状态 2->通话存在 switch (phoneStatus) { case 0: console.log("3、电话挂断,上传录音") // 结束录音 recorderManager.stop(); break; case 1: // console.log('1、振铃状态'); break; case 2: console.log('2、通话存在') // 延迟录音 that.start_time = Math.round(new Date().getTime() / 1000); recorderManager.start({ duration: EnumData.audioDuration, // 时长 10分钟 sampleRate: EnumData.audioSampleRate, // 码率 }); break; } } }); let IntentFilter = plus.android.importClass('android.content.IntentFilter'); let filter = new IntentFilter(); filter.addAction(telephonyManager.ACTION_PHONE_STATE_CHANGED); maintest.registerReceiver(receiver, filter); }, if (plus.os.name == 'Android') { plus.android.requestPermissions( ['android.permission.ANSWER_PHONE_CALLS',//手动 挂断和接听 需要这个权限 "android.permission.MODIFY_AUDIO_SETTINGS",//手动 挂断和接听 需要这个权限 "android.permission.CALL_PHONE",//手动 挂断和接听 需要这个权限 "android.permission.READ_PHONE_STATE",//>监听电话状态 需要这个权限 "android.permission.READ_CALL_LOG",//获取号码需要这个权限 "android.permission.READ_AUDIO" // 录音权限 ], function(resultObj) { var result = 0; for (var i = 0; i < resultObj.granted.length; i++) { var grantedPermission = resultObj.granted[i]; console.log('已获取的权限:' + grantedPermission); result = 1 } for (var i = 0; i < resultObj.deniedPresent.length; i++) { var deniedPresentPermission = resultObj.deniedPresent[i]; console.log('拒绝本次申请的权限:' + deniedPresentPermission); result = 0 } for (var i = 0; i < resultObj.deniedAlways.length; i++) { var deniedAlwaysPermission = resultObj.deniedAlways[i]; console.log('永久拒绝申请的权限:' + deniedAlwaysPermission); result = -1 } }, function(error) { console.log('申请权限错误:' + error.code + " = " + error.message); } ); } ```