Browse Source

优化交互

voice
zmt 4 years ago
parent
commit
67d769a8eb
  1. 62
      src/subpackage/device/pages/audio_manage/audio_manage.vue
  2. BIN
      src/subpackage/device/static/images/i_voice_4.png

62
src/subpackage/device/pages/audio_manage/audio_manage.vue

@ -64,9 +64,9 @@
</view>
<!-- 录音 -->
<view class="v_box" v-else>
<view class="voice_title">请说话</view>
<view class="voice_title">{{getVoiceTxt(voicePadConfig.step)}}</view>
<image class="voice_img" src="../../static/images/i_voice.png" :src="getVoiceIcon(voicePadConfig.step)"
:class="voicePadConfig.step==2?'voice_img_playing':''"></image>
:class="voicePadConfig.step==2||voicePadConfig.step==4?'voice_img_playing':''"></image>
<view class="voice_btn " @longpress="longPressHandle" @touchend="touchEndHandle"
hover-class="btn_active" v-if="voicePadConfig.step<3">按住说话</view>
<view class="v_btns" v-else-if="voicePadConfig.step==3">
@ -121,6 +121,11 @@
return i => {
return `../../static/images/i_voice_${i}.png`
}
},
getVoiceTxt() {
return i => {
return [,'请按住说话','录音中...','录音已完成','播放中...'][i]
}
},
},
@ -139,7 +144,7 @@
deviceList: [],
voicePadConfig: {
showVoicePad: false,
step: 1, // 0, 1 , 2 , 3
step: 1, // 0 , 1 , 2 , 3 , 4 ,
txt: "",
voicePath: "",
voiceUrl: "",
@ -147,24 +152,38 @@
}
},
onLoad(options) {
let self = this;
recorderManager.onStop(function(res) {
console.log('recorder stop' + JSON.stringify(res));
self.voicePadConfig.voicePath = res.tempFilePath;
});
let _pageInfo = showArr[`s${options.sid}`] || {};
this.pageInfo = _pageInfo;
uni.setNavigationBarTitle({
title: _pageInfo.name
});
this.getDeviceList({
stadium_id: this.curStoreInfo.id,
hardware_type: _pageInfo.hardware_type
})
this.initAudio();
this.initPage(options);
},
methods: {
methods: {
//
initAudio(){
let self = this;
recorderManager.onStop(function(res) {
console.log('recorder stop' + JSON.stringify(res));
self.voicePadConfig.voicePath = res.tempFilePath;
});
innerAudioContext.onPlay(function(res) {
console.log('play voice onPlay' + JSON.stringify(res));
if(self.voicePadConfig.step==3)self.voicePadConfig.step = 4
});
innerAudioContext.onEnded(function(res) {
console.log('play voice onEnded' + JSON.stringify(res));
if(self.voicePadConfig.step == 4)self.voicePadConfig.step = 3
});
},
initPage(options){
let _pageInfo = showArr[`s${options.sid}`] || {};
this.pageInfo = _pageInfo;
uni.setNavigationBarTitle({
title: _pageInfo.name
});
this.getDeviceList({
stadium_id: this.curStoreInfo.id,
hardware_type: _pageInfo.hardware_type
})
},
longPressHandle(e) {
console.log("长按开始...");
this.voicePadConfig.step = 2
@ -203,6 +222,7 @@
let _url = ""; //
if(this.voicePadConfig.step==0){
let txt = this.voicePadConfig.txt
if(!txt)return util.showNone("请先输入您要说的话后重试")
_url = `${deviceApi.ORIGIN}/ouxuanac/tts/textToVoice.wav?text=${txt}&voice_type=4&speed=-1&volume=10`;
}
//
@ -242,9 +262,11 @@
},
/// /
async listenVoice() {
let self = this
if(this.voicePadConfig.step==0){
//,
let txt = this.voicePadConfig.txt;
if(!txt)return util.showNone("请先输入您要说的话后重试")
let url =`${deviceApi.ORIGIN}/ouxuanac/tts/textToVoice.wav?text=${txt}&voice_type=4&speed=-1&volume=10`;
let updated_url = await this.getDownloadUrl(url)
innerAudioContext.src = updated_url

BIN
src/subpackage/device/static/images/i_voice_4.png

After

Width: 103  |  Height: 50  |  Size: 2.9 KiB

Loading…
Cancel
Save