fix: bug
This commit is contained in:
@@ -1,54 +1,24 @@
|
||||
<template>
|
||||
<view class="talk-btns" ref="talkBtnRef">
|
||||
<view
|
||||
class="touch-btn"
|
||||
@touchstart="getRecordPermission"
|
||||
@touchend="hideOverlayTalking"
|
||||
@touchmove="handleMove"
|
||||
v-if="!keyboardIsShow"
|
||||
>
|
||||
<view class="touch-btn" @touchstart="getRecordPermission" @touchend="hideOverlayTalking" @touchmove="handleMove"
|
||||
v-if="!keyboardIsShow">
|
||||
按住说话
|
||||
</view>
|
||||
<view class="touch-btn" v-if="keyboardIsShow">
|
||||
<uv-input
|
||||
class="input-box"
|
||||
ref="inputRef"
|
||||
v-model="answerValue"
|
||||
:maxlength="props.textValueLength"
|
||||
:adjustPosition="adjustPosition"
|
||||
placeholderStyle="color:#999999;font-size:26rpx"
|
||||
placeholder="请输入文字"
|
||||
></uv-input>
|
||||
<uv-input class="input-box" ref="inputRef" v-model="answerValue" :maxlength="props.textValueLength"
|
||||
:adjustPosition="adjustPosition" placeholderStyle="color:#999999;font-size:26rpx"
|
||||
placeholder="请输入文字"></uv-input>
|
||||
</view>
|
||||
<view class="talk-btn-box" v-show="!onlyVoice">
|
||||
<image
|
||||
class="talk-btn-icon"
|
||||
v-show="!keyboardIsShow"
|
||||
src="/src/static/images/course/jianpan.png"
|
||||
mode=""
|
||||
@click="changeBtn"
|
||||
></image>
|
||||
<image
|
||||
class="talk-btn-icon"
|
||||
v-show="keyboardIsShow && !answerValue"
|
||||
src="/src/static/images/course/record.png"
|
||||
mode=""
|
||||
@click="changeBtn"
|
||||
></image>
|
||||
<image
|
||||
class="talk-btn-icon"
|
||||
v-show="keyboardIsShow && !!answerValue"
|
||||
src="/src/static/images/course/send.png"
|
||||
mode=""
|
||||
@click.stop="showKeyboard"
|
||||
></image>
|
||||
<image class="talk-btn-icon" v-show="!keyboardIsShow" src="/src/static/images/course/jianpan.png" mode=""
|
||||
@click="changeBtn"></image>
|
||||
<image class="talk-btn-icon" v-show="keyboardIsShow && !answerValue" src="/src/static/images/course/record.png"
|
||||
mode="" @click="changeBtn"></image>
|
||||
<image class="talk-btn-icon" v-show="keyboardIsShow && !!answerValue" src="/src/static/images/course/send.png"
|
||||
mode="" @click.stop="showKeyboard"></image>
|
||||
</view>
|
||||
<uni-popup
|
||||
ref="talkModelRef"
|
||||
type="bottom"
|
||||
@click="showTalkingModel = false"
|
||||
mask-background-color="rgba(0,0,0,0.9)"
|
||||
>
|
||||
<uni-popup ref="talkModelRef" type="bottom" @click="showTalkingModel = false"
|
||||
mask-background-color="rgba(0,0,0,0.9)">
|
||||
<view class="overlay-box">
|
||||
<view class="circle-bg-box">
|
||||
<view class="icon-box">
|
||||
@@ -72,11 +42,25 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { toRefs, ref, computed, unref, onMounted, onUnmounted, nextTick, watch, getCurrentInstance } from 'vue';
|
||||
import {
|
||||
toRefs,
|
||||
ref,
|
||||
computed,
|
||||
unref,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
nextTick,
|
||||
watch,
|
||||
getCurrentInstance
|
||||
} from 'vue';
|
||||
import common from '../../../common/common';
|
||||
import permission from '@/common/permission.js';
|
||||
import { getPhoneEnvBool } from '@/common/common.js';
|
||||
import { useStorageStore } from '@/store/storage.js';
|
||||
import {
|
||||
getPhoneEnvBool
|
||||
} from '@/common/common.js';
|
||||
import {
|
||||
useStorageStore
|
||||
} from '@/store/storage.js';
|
||||
|
||||
const storageStore = useStorageStore();
|
||||
const proxy = getCurrentInstance();
|
||||
@@ -115,11 +99,16 @@
|
||||
type: Boolean
|
||||
},
|
||||
formatType: {
|
||||
default: 'mp3',// 生成语音文件类型
|
||||
default: 'mp3', // 生成语音文件类型
|
||||
type: String
|
||||
},
|
||||
});
|
||||
const { isDisabled, onlyVoice, adjustPosition, formatType } = toRefs(props);
|
||||
const {
|
||||
isDisabled,
|
||||
onlyVoice,
|
||||
adjustPosition,
|
||||
formatType
|
||||
} = toRefs(props);
|
||||
const isLoadingState = computed(() => props.isLoading);
|
||||
|
||||
const showTalkingModel = ref(false);
|
||||
@@ -134,24 +123,21 @@
|
||||
);
|
||||
watch(
|
||||
() => props.isLoading,
|
||||
() => {},
|
||||
{
|
||||
() => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => props.canAnswer,
|
||||
() => {},
|
||||
{
|
||||
() => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => props.onlyVoice,
|
||||
() => {},
|
||||
{
|
||||
() => {}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
@@ -162,8 +148,7 @@
|
||||
if (val) {
|
||||
keyboardIsShow.value = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
@@ -265,39 +250,7 @@
|
||||
// #endif
|
||||
onMounted(async () => {
|
||||
initRecord?.();
|
||||
//#ifdef APP-PLUS
|
||||
// 安卓端
|
||||
if (IsAndEnv) {
|
||||
let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO');
|
||||
if (_recordPerm !== 1) {
|
||||
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?', true, '取消', '确定').then((res) => {
|
||||
if (res) {
|
||||
// 去开启权限
|
||||
permission.gotoAppPermissionSetting();
|
||||
} else {
|
||||
// 取消
|
||||
common.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let _recordPerm = uni.getAppAuthorizeSetting();
|
||||
let _state = _recordPerm.microphoneAuthorized;
|
||||
if (_state === 'denied') {
|
||||
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?', true, '取消', '确定').then((res) => {
|
||||
if (res) {
|
||||
// 去开启权限
|
||||
uni.openAppAuthorizeSetting();
|
||||
} else {
|
||||
// 取消
|
||||
common.navigateBack();
|
||||
}
|
||||
});
|
||||
} else if (_state === 'not determined') {
|
||||
// startRecord()
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
});
|
||||
// 录音结束
|
||||
|
||||
@@ -317,6 +270,7 @@
|
||||
});
|
||||
const recNum = ref(1);
|
||||
const activeNum = ref(1);
|
||||
const hasPermission = ref(false)
|
||||
|
||||
const getRecordPermission = (obj) => {
|
||||
if (isDisabled.value) return;
|
||||
@@ -327,8 +281,59 @@
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
showOverlayTalking(obj);
|
||||
if(!hasPermission.value){
|
||||
let _res = getPermission()
|
||||
if (_res) {
|
||||
hasPermission.value = true
|
||||
showOverlayTalking(obj);
|
||||
}
|
||||
}else{
|
||||
showOverlayTalking(obj);
|
||||
}
|
||||
};
|
||||
const getPermission = () => {
|
||||
//#ifdef APP-PLUS
|
||||
// 安卓端
|
||||
if (IsAndEnv) {
|
||||
let _recordPerm = await permission.requestAndroidPermission('android.permission.RECORD_AUDIO');
|
||||
if (_recordPerm !== 1) {
|
||||
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?', true, '取消', '确定').then((res) => {
|
||||
if (res) {
|
||||
// 去开启权限
|
||||
permission.gotoAppPermissionSetting();
|
||||
} else {
|
||||
// 取消
|
||||
common.navigateBack();
|
||||
}
|
||||
});
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
let _recordPerm = uni.getAppAuthorizeSetting();
|
||||
let _state = _recordPerm.microphoneAuthorized;
|
||||
if (_state === 'denied') {
|
||||
common.show('提示信息', '当前页面需要使用的录音权限,是否前往开启?', true, '取消', '确定').then((res) => {
|
||||
if (res) {
|
||||
// 去开启权限
|
||||
uni.openAppAuthorizeSetting();
|
||||
} else {
|
||||
// 取消
|
||||
common.navigateBack();
|
||||
}
|
||||
});
|
||||
return false
|
||||
} else if (_state === 'not determined') {
|
||||
// startRecord()
|
||||
return true
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
//#ifndef APP-PLUS
|
||||
return true
|
||||
// #endif
|
||||
}
|
||||
const isMoving = ref(false);
|
||||
const isTalking = ref(false);
|
||||
const showOverlayTalking = (obj) => {
|
||||
@@ -366,8 +371,8 @@
|
||||
startRecord();
|
||||
// #endif
|
||||
setTimeout(() => {
|
||||
console.log(_recnum,recNum.value)
|
||||
if(_recnum === recNum.value) {
|
||||
console.log(_recnum, recNum.value)
|
||||
if (_recnum === recNum.value) {
|
||||
hideOverlayTalking(recNum.value);
|
||||
}
|
||||
}, 59 * 1010);
|
||||
@@ -440,6 +445,7 @@
|
||||
padding: 25rpx 30rpx 0;
|
||||
position: relative;
|
||||
z-index: v-bind(btnZindex);
|
||||
|
||||
.touch-btn {
|
||||
height: 92rpx;
|
||||
box-shadow: 0 8rpx 20rpx 0 rgba(0, 0, 0, 0.06);
|
||||
@@ -620,4 +626,4 @@
|
||||
::v-deep .uv-input__content__field-wrapper__field {
|
||||
padding-right: 60rpx;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user