更改语音

This commit is contained in:
zoujiandong 2024-05-27 09:13:02 +08:00
parent 0c06201451
commit 9649d0a651
6 changed files with 47 additions and 6 deletions

View File

@ -37,6 +37,7 @@ Component({
lifetimes: {
detached() {
myaudio.stop();
wx.setStorageSync('currentAudioId', '')
},
},
@ -80,6 +81,8 @@ Component({
const { id } = e.currentTarget.dataset;
const { audioSave } = this.data;
console.log(id);
wx.setStorageSync('currentAudioId',id)
this.triggerEvent("closeAudio",false)
// 设置状态
audioSave.forEach((message, index) => {
@ -128,7 +131,9 @@ Component({
return;
});
},
stopmy(){
myaudio.stop();
},
// 音频停止
audioStop(e) {
const { key } = e.currentTarget.dataset;

View File

@ -120,6 +120,7 @@ Component({
serviceInfo:{},
baseInfo:{},
family_id:'',
fresh:true,
patient_user_id:'',
extensionArea: false,
sendMessageBtn: false,
@ -188,10 +189,16 @@ Component({
lifetimes: {
attached() {
let _this = this;
// 加载声音录制管理器
this.recorderManager = wx.getRecorderManager();
this.recorderManager.onStop(async(resData) => {
this.setData({
fresh:!this.data.fresh
})
wx.hideLoading();
if (this.data.canSend) {
if (resData.duration < 1000) {
wx.showToast({
@ -596,6 +603,10 @@ this.setData({
},
// 长按录音
handleLongPress(e) {
this.triggerEvent('closeAudio',false);
if(this.timer){
clearInterval(this.timer)
}
this.openRecord(e,this.recording)
},
recording(e,THIS){
@ -616,7 +627,7 @@ this.setData({
THIS.timer=setInterval(()=>{
if(THIS.data.recordtime>=60){
THIS.handleTouchEnd();
clearInterval(THIS.timer);
//clearInterval(THIS.timer);
};
THIS.setData({

View File

@ -22,11 +22,21 @@
bindlinechange="inputBindLinechange"
/>
</view>
<view wx:if="{{isAudio}}" class="TUI-message-input-main"
<view wx:if="{{isAudio && fresh}}"
id="talk1"
class="TUI-message-input-main"
catchlongpress="handleLongPress"
catchtouchmove="handleTouchMove"
catchtouchend="handleTouchEnd"
catchtouchcancel="handleTouchCancel"
style="display: flex; justify-content: center; font-size: 32rpx; font-family: PingFangSC-Regular; height: 30px">
<text >{{text}}</text>
</view>
<view wx:elif="{{isAudio && !fresh}}"
id="talk2" class="TUI-message-input-main"
catchlongpress="handleLongPress"
catchtouchmove="handleTouchMove"
catchtouchend="handleTouchEnd"
catchtap="handleTouchCancel"
catchtouchcancel="handleTouchCancel"
style="display: flex; justify-content: center; font-size: 32rpx; font-family: PingFangSC-Regular; height: 30px">
<text >{{text}}</text>

View File

@ -320,12 +320,21 @@ Component({
},
closeAudio(data){
//关闭其他语音
let currentAudioId= wx.getStorageSync('currentAudioId');
this.data.messageList.forEach((item)=>{
if(item.type=="TIMSoundElem"){
let ele=this.selectComponent('#audio'+item.ID);
if(item.ID!=currentAudioId){
ele.stopmy();
}
ele.setData({
isPlay:false
})
//console.log(ele);
//ele.stopmy();
//console.log(ele)
}

View File

@ -234,6 +234,9 @@ Component({
* 组件的方法列表
*/
methods: {
closeAudio(){
this.selectComponent('#MessageList').closeAudio();
},
checkChuFang(order_inquiry_id){
api.getDoctorPrescriptionCheck({order_inquiry_id: order_inquiry_id}).then(response => {
let status = response.data.status

View File

@ -73,8 +73,11 @@
<!-- wx:if="{{baseInfo.inquiry_status==4}}" -->
<view class="input-area" style="{{input_area_style}}" >
<!-- wx:if="{{showChat}}" -->
<!-- bind:closeAudio="closeAudio" -->
<view class="message-input" style="{{viewData.style}}" >
<MessageInput bind:myhandleExtensions="myhandleExtensions" id="MessageInput" inquiry_type="{{inquiry_type}}" baseInfo="{{baseInfo}}" order_inquiry_id="{{order_inquiry_id}}" conversation="{{conversation}}" from="{{from}}" hasCallKit="{{hasCallKit}}"
<MessageInput bind:myhandleExtensions="myhandleExtensions"
bind:closeAudio="closeAudio"
id="MessageInput" inquiry_type="{{inquiry_type}}" baseInfo="{{baseInfo}}" order_inquiry_id="{{order_inquiry_id}}" conversation="{{conversation}}" from="{{from}}" hasCallKit="{{hasCallKit}}"
serviceInfo="{{serviceInfo}}"
isEditTime="{{isEditTime}}"
videoInfo="{{videoInfo}}"