Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
* 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启
|
||||
*/
|
||||
|
||||
var isIos
|
||||
// #ifdef APP-PLUS
|
||||
isIos = (plus.os.name == "iOS")
|
||||
// #endif
|
||||
|
||||
// 判断推送权限是否开启
|
||||
function judgeIosPermissionPush() {
|
||||
var result = false;
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var app = UIApplication.sharedApplication();
|
||||
var enabledTypes = 0;
|
||||
if (app.currentUserNotificationSettings) {
|
||||
var settings = app.currentUserNotificationSettings();
|
||||
enabledTypes = settings.plusGetAttribute("types");
|
||||
console.log("enabledTypes1:" + enabledTypes);
|
||||
if (enabledTypes == 0) {
|
||||
console.log("推送权限没有开启");
|
||||
} else {
|
||||
result = true;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
plus.ios.deleteObject(settings);
|
||||
} else {
|
||||
enabledTypes = app.enabledRemoteNotificationTypes();
|
||||
if (enabledTypes == 0) {
|
||||
console.log("推送权限没有开启!");
|
||||
} else {
|
||||
result = true;
|
||||
console.log("已经开启推送功能!")
|
||||
}
|
||||
console.log("enabledTypes2:" + enabledTypes);
|
||||
}
|
||||
plus.ios.deleteObject(app);
|
||||
plus.ios.deleteObject(UIApplication);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断定位权限是否开启
|
||||
function judgeIosPermissionLocation() {
|
||||
var result = false;
|
||||
var cllocationManger = plus.ios.import("CLLocationManager");
|
||||
var status = cllocationManger.authorizationStatus();
|
||||
result = (status != 2)
|
||||
console.log("定位权限开启:" + result);
|
||||
// 以下代码判断了手机设备的定位是否关闭,推荐另行使用方法 checkSystemEnableLocation
|
||||
/* var enable = cllocationManger.locationServicesEnabled();
|
||||
var status = cllocationManger.authorizationStatus();
|
||||
console.log("enable:" + enable);
|
||||
console.log("status:" + status);
|
||||
if (enable && status != 2) {
|
||||
result = true;
|
||||
console.log("手机定位服务已开启且已授予定位权限");
|
||||
} else {
|
||||
console.log("手机系统的定位没有打开或未给予定位权限");
|
||||
} */
|
||||
plus.ios.deleteObject(cllocationManger);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断麦克风权限是否开启
|
||||
function judgeIosPermissionRecord() {
|
||||
var result = false;
|
||||
var avaudiosession = plus.ios.import("AVAudioSession");
|
||||
var avaudio = avaudiosession.sharedInstance();
|
||||
var permissionStatus = avaudio.recordPermission();
|
||||
console.log("permissionStatus:" + permissionStatus);
|
||||
if (permissionStatus == 1684369017 || permissionStatus == 1970168948) {
|
||||
console.log("麦克风权限没有开启");
|
||||
} else {
|
||||
result = true;
|
||||
console.log("麦克风权限已经开启");
|
||||
}
|
||||
plus.ios.deleteObject(avaudiosession);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断相机权限是否开启
|
||||
function judgeIosPermissionCamera() {
|
||||
var result = false;
|
||||
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||
console.log("authStatus:" + authStatus);
|
||||
if (authStatus == 3) {
|
||||
result = true;
|
||||
console.log("相机权限已经开启");
|
||||
} else {
|
||||
console.log("相机权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(AVCaptureDevice);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断相册权限是否开启
|
||||
function judgeIosPermissionPhotoLibrary() {
|
||||
var result = false;
|
||||
var PHPhotoLibrary = plus.ios.import("PHPhotoLibrary");
|
||||
var authStatus = PHPhotoLibrary.authorizationStatus();
|
||||
console.log("authStatus:" + authStatus);
|
||||
if (authStatus == 3) {
|
||||
result = true;
|
||||
console.log("相册权限已经开启");
|
||||
} else {
|
||||
console.log("相册权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(PHPhotoLibrary);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断通讯录权限是否开启
|
||||
function judgeIosPermissionContact() {
|
||||
var result = false;
|
||||
var CNContactStore = plus.ios.import("CNContactStore");
|
||||
var cnAuthStatus = CNContactStore.authorizationStatusForEntityType(0);
|
||||
if (cnAuthStatus == 3) {
|
||||
result = true;
|
||||
console.log("通讯录权限已经开启");
|
||||
} else {
|
||||
console.log("通讯录权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(CNContactStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断日历权限是否开启
|
||||
function judgeIosPermissionCalendar() {
|
||||
var result = false;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(0);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = true;
|
||||
console.log("日历权限已经开启");
|
||||
} else {
|
||||
console.log("日历权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 判断备忘录权限是否开启
|
||||
function judgeIosPermissionMemo() {
|
||||
var result = false;
|
||||
var EKEventStore = plus.ios.import("EKEventStore");
|
||||
var ekAuthStatus = EKEventStore.authorizationStatusForEntityType(1);
|
||||
if (ekAuthStatus == 3) {
|
||||
result = true;
|
||||
console.log("备忘录权限已经开启");
|
||||
} else {
|
||||
console.log("备忘录权限没有开启");
|
||||
}
|
||||
plus.ios.deleteObject(EKEventStore);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Android权限查询
|
||||
function requestAndroidPermission(permissionID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
plus.android.requestPermissions(
|
||||
[permissionID], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
|
||||
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
|
||||
}
|
||||
resolve(result);
|
||||
// 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
|
||||
// if (result != 1) {
|
||||
// gotoAppPermissionSetting()
|
||||
// }
|
||||
},
|
||||
function(error) {
|
||||
console.log('申请权限错误:' + error.code + " = " + error.message);
|
||||
resolve({
|
||||
code: error.code,
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// 使用一个方法,根据参数判断权限
|
||||
function judgeIosPermission(permissionID) {
|
||||
if (permissionID == "location") {
|
||||
return judgeIosPermissionLocation()
|
||||
} else if (permissionID == "camera") {
|
||||
return judgeIosPermissionCamera()
|
||||
} else if (permissionID == "photoLibrary") {
|
||||
return judgeIosPermissionPhotoLibrary()
|
||||
} else if (permissionID == "record") {
|
||||
return judgeIosPermissionRecord()
|
||||
} else if (permissionID == "push") {
|
||||
return judgeIosPermissionPush()
|
||||
} else if (permissionID == "contact") {
|
||||
return judgeIosPermissionContact()
|
||||
} else if (permissionID == "calendar") {
|
||||
return judgeIosPermissionCalendar()
|
||||
} else if (permissionID == "memo") {
|
||||
return judgeIosPermissionMemo()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 跳转到**应用**的权限页面
|
||||
function gotoAppPermissionSetting() {
|
||||
if (isIos) {
|
||||
var UIApplication = plus.ios.import("UIApplication");
|
||||
var application2 = UIApplication.sharedApplication();
|
||||
var NSURL2 = plus.ios.import("NSURL");
|
||||
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
|
||||
var setting2 = NSURL2.URLWithString("app-settings:");
|
||||
application2.openURL(setting2);
|
||||
|
||||
plus.ios.deleteObject(setting2);
|
||||
plus.ios.deleteObject(NSURL2);
|
||||
plus.ios.deleteObject(application2);
|
||||
} else {
|
||||
// console.log(plus.device.vendor);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查系统的设备服务是否开启
|
||||
// var checkSystemEnableLocation = async function () {
|
||||
function checkSystemEnableLocation() {
|
||||
if (isIos) {
|
||||
var result = false;
|
||||
var cllocationManger = plus.ios.import("CLLocationManager");
|
||||
var result = cllocationManger.locationServicesEnabled();
|
||||
console.log("系统定位开启:" + result);
|
||||
plus.ios.deleteObject(cllocationManger);
|
||||
return result;
|
||||
} else {
|
||||
var context = plus.android.importClass("android.content.Context");
|
||||
var locationManager = plus.android.importClass("android.location.LocationManager");
|
||||
var main = plus.android.runtimeMainActivity();
|
||||
var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
|
||||
var result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
|
||||
console.log("系统定位开启:" + result);
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
export default ({
|
||||
judgeIosPermission: judgeIosPermission,
|
||||
requestAndroidPermission: requestAndroidPermission,
|
||||
checkSystemEnableLocation: checkSystemEnableLocation,
|
||||
gotoAppPermissionSetting: gotoAppPermissionSetting
|
||||
})
|
||||
+11
-1
@@ -198,5 +198,15 @@
|
||||
"bounce": "none"
|
||||
}
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
"uniIdRouter": {},
|
||||
"condition" : { //模式配置,仅开发期间生效
|
||||
"current": 0, //当前激活的模式(list 的索引项)
|
||||
"list": [
|
||||
{
|
||||
"name": "", //模式名称
|
||||
"path": "", //启动页面,必选
|
||||
"query": "" //启动参数,在页面的onLoad函数里面得到
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -436,18 +436,14 @@ const audioCacheObj = computed(() => storageStore.audioObj)
|
||||
}
|
||||
const showNextBtn = ref(true)
|
||||
const showGoonBtn = computed(()=>{
|
||||
return showNextBtn.value && [3, 6].indexOf(props.type) >= 0 && isLast.value && !isPlaying.value
|
||||
return showNextBtn.value && [3, 6].indexOf(props.type) >= 0 && isLast.value // && !isPlaying.value
|
||||
})
|
||||
const goOnGetQues = () => {
|
||||
if(props.type === 5){
|
||||
// 完成问题
|
||||
emit('nextQuestion', unref(dataInfo))
|
||||
}else if(props.type === 3){
|
||||
// studyParagraphOverApi({
|
||||
// pgrphId:unref(dataInfo)?.pgrphId,
|
||||
// logId:unref(dataInfo)?.logId,
|
||||
// }).then(res=>{
|
||||
// showNextBtn.value = false
|
||||
// })
|
||||
// 完成段落
|
||||
emit('nextQuestion', unref(dataInfo), 'overGraph')
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<script setup>
|
||||
import { toRefs, ref, computed, unref, onMounted, onUnmounted, nextTick } from 'vue';
|
||||
import common from '../../../common/common';
|
||||
import permission from '@/common/permission.js'
|
||||
const emit = defineEmits(['uploadVoice', 'submitAnswer','startRecord'])
|
||||
const props = defineProps({
|
||||
isDisabled:{
|
||||
@@ -57,25 +58,46 @@ const audioPath = ref('')
|
||||
const audioObj = uni.createInnerAudioContext()
|
||||
//#ifdef APP-PLUS
|
||||
// app端
|
||||
const recordObjCom = uni.getRecorderManager()
|
||||
const recordObjCom = ref({})
|
||||
const initRecord = () => {
|
||||
recordObjCom.value = uni.getRecorderManager()
|
||||
unref(recordObjCom)?.onStop((res, duration)=>{
|
||||
audioPath.value = res.tempFilePath
|
||||
})
|
||||
unref(recordObjCom).start({format:'mp3'})
|
||||
stopRecord()
|
||||
}
|
||||
const startRecord = () => {
|
||||
unref(recordObjCom).start({format:'mp3'})
|
||||
}
|
||||
const stopRecord = () => {
|
||||
unref(recordObjCom)?.stop?.()
|
||||
if(unref(recordObjCom).stop){
|
||||
unref(recordObjCom)?.stop?.()
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
//#ifndef APP-PLUS
|
||||
const recordObjCom = {}
|
||||
const recordObjCom = ref({})
|
||||
const initRecord = () => {}
|
||||
// #endif
|
||||
onMounted(()=>{
|
||||
onMounted(async ()=>{
|
||||
initRecord?.()
|
||||
// //#ifdef APP-PLUS
|
||||
// //#ifdef __IOS__
|
||||
// // ios端
|
||||
// let _recordPerm = permission.judgeIosPermission('record')
|
||||
// if(!_recordPerm){
|
||||
// permission.gotoAppPermissionSetting()
|
||||
// }
|
||||
// // #endif
|
||||
// // #endif
|
||||
// //#ifdef APP-PLUS
|
||||
// // 安卓端
|
||||
// let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO')
|
||||
// if(_recordPerm !== 1){
|
||||
// permission.gotoAppPermissionSetting()
|
||||
// }
|
||||
// // #endif
|
||||
})
|
||||
// const playRecord = () => {
|
||||
// audioObj.src = audioPath.value
|
||||
@@ -97,30 +119,20 @@ const isOut = computed(() => {
|
||||
const recNum = ref(1)
|
||||
const activeNum = ref(1)
|
||||
|
||||
const getRecordPermission = (obj) => {
|
||||
//#ifdef APP-PLUS
|
||||
uni.getSetting({
|
||||
success: (res) => {
|
||||
if(!res.authSetting['scope.record']){
|
||||
// 没有授权,请求授权
|
||||
uni.authorize({
|
||||
scope: 'scope.record',
|
||||
success:() => {
|
||||
showOverlayTalking(obj)
|
||||
},
|
||||
fail: () => {
|
||||
common.msg('请设置开启录音权限!')
|
||||
}
|
||||
})
|
||||
}else{
|
||||
showOverlayTalking(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
//#ifndef APP-PLUS
|
||||
showOverlayTalking(obj)
|
||||
// #endif
|
||||
const getRecordPermission = async (obj) => {
|
||||
//#ifdef APP-PLUS
|
||||
// 安卓端
|
||||
// let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO')
|
||||
// if(_recordPerm !== 1){
|
||||
// permission.gotoAppPermissionSetting()
|
||||
// return
|
||||
// }
|
||||
showOverlayTalking(obj)
|
||||
// #endif
|
||||
//#ifndef APP-PLUS
|
||||
// pc端
|
||||
showOverlayTalking(obj)
|
||||
// #endif
|
||||
}
|
||||
const showOverlayTalking = (obj) => {
|
||||
recNum.value += 1
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<uv-radio-group v-model="choiceTeacher">
|
||||
<view class="voice-item" v-for="item in teacherList" :key="item.teacherNo" @click="choiceTeacher = item.teacherNo">
|
||||
<view class="avatar-box">
|
||||
<ImagePreview class="img-box" :imgId="item.imgAddr" :isCache="true" :width="120" :height="160"></ImagePreview>
|
||||
<ImagePreview class="img-box" :src="item.imgAddr" :isCache="true" :width="120" :height="160"></ImagePreview>
|
||||
</view>
|
||||
<view class="right-cont">
|
||||
<view class="right-name">{{item.teacherName}}</view>
|
||||
@@ -82,7 +82,7 @@
|
||||
@uploadVoice="uploadRecordNow"
|
||||
@submitAnswer="submitAnswerNow"
|
||||
@startRecord="changePlayItemId('')"
|
||||
:isDisabled="(lastTalkingInfo.type||0) !== 4"
|
||||
:isDisabled="((lastTalkingInfo.type||0) !== 4) || isUploadingVoice"
|
||||
/>
|
||||
</view>
|
||||
<uv-overlay :show="showSeekModel" opacity=".6" @click="showSeekModel = false">
|
||||
@@ -162,6 +162,7 @@ const activeVoiceTalkingItemId = ref('')
|
||||
const answerValue = ref('')
|
||||
const inputRef = ref('')
|
||||
const flagVal = ref('1')
|
||||
const isUploadingVoice = ref(false)
|
||||
// 初始化数据
|
||||
const getData = async (flag) => {
|
||||
// if(flag === flagVal.value){
|
||||
@@ -171,7 +172,6 @@ const getData = async (flag) => {
|
||||
// }
|
||||
try{
|
||||
const { body } = await getCourseStudyInfoApi({crsId: crsId.value})
|
||||
console.log(body)
|
||||
initsocketTask()
|
||||
teacherList.value = body.teacheList.map(t=>({
|
||||
...t,
|
||||
@@ -584,7 +584,18 @@ onUnload(()=>{
|
||||
teacherVoiceObj?.stop?.()
|
||||
teacherVoiceObj.src = ''
|
||||
})
|
||||
const testAnswer = computed(()=>{
|
||||
if(talkingList.value.length < 5) return true
|
||||
let _arr = talkingList.value.slice(-5)
|
||||
let _num = _arr.map(t=>[1,2,6].indexOf(Number(t.type))>=0).filter(t => !!t)
|
||||
return _num.length < 5
|
||||
})
|
||||
const uploadRecordNow = (voicePath) => {
|
||||
if(!testAnswer.value){
|
||||
common.msg('每个问题最多连续发送五次答案!')
|
||||
return
|
||||
}
|
||||
isUploadingVoice.value = true
|
||||
let _data = {
|
||||
qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String
|
||||
pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String
|
||||
@@ -606,7 +617,8 @@ const uploadRecordNow = (voicePath) => {
|
||||
userInfo: {...choiceTeacherInfo.value},
|
||||
id: _id
|
||||
})
|
||||
scrollToBottomNow()
|
||||
isUploadingVoice.value = false
|
||||
scrollToBottomNow()
|
||||
// #endif
|
||||
//#ifdef APP-PLUS
|
||||
talkingList.value.push({
|
||||
@@ -648,7 +660,9 @@ const uploadRecordNow = (voicePath) => {
|
||||
})
|
||||
scrollToBottomNow()
|
||||
}else{}
|
||||
isUploadingVoice.value = false
|
||||
}).catch(err=>{
|
||||
isUploadingVoice.value = false
|
||||
talkingList.value = talkingList.value.filter(t=>t.id !== _id)
|
||||
uni.showToast({
|
||||
title: '系统异常,请联系管理员',
|
||||
@@ -660,6 +674,10 @@ const uploadRecordNow = (voicePath) => {
|
||||
}
|
||||
// 发送文本
|
||||
const submitAnswerNow = (val, cb) => {
|
||||
if(!testAnswer.value){
|
||||
common.msg('每个问题最多连续发送五次答案!')
|
||||
return
|
||||
}
|
||||
let _data = {
|
||||
qnsId: unref(lastTalkingInfo).qnsId,// 问题ID 必输项:true 类型:String
|
||||
pgrphId: unref(lastTalkingInfo).pgrphId,// 段落ID 必输项:true 类型:String
|
||||
|
||||
Reference in New Issue
Block a user