|  | @@ -12,12 +12,12 @@
 | 
	
		
			
				|  |  |        </span>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        <label v-if="type === 'big'" :class="['record-time', microphoneStatus ? 'record-ing' : '']">
 | 
	
		
			
				|  |  | -        {{ secondFormatConversion(recordTimes) }}
 | 
	
		
			
				|  |  | +        {{ audio.paused ? '' : '-' }}{{ secondFormatConversion(recordTimes) }}
 | 
	
		
			
				|  |  |        </label>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  |      <div v-if="type === 'small'" class="sound-item">
 | 
	
		
			
				|  |  |        <label :class="['record-time', microphoneStatus ? 'record-ing' : '']">
 | 
	
		
			
				|  |  | -        {{ secondFormatConversion(recordTimes) }}
 | 
	
		
			
				|  |  | +        {{ audio.paused ? '' : '-' }}{{ secondFormatConversion(recordTimes) }}
 | 
	
		
			
				|  |  |        </label>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  |      <div class="sound-item">
 | 
	
	
		
			
				|  | @@ -32,13 +32,14 @@
 | 
	
		
			
				|  |  |        </span>
 | 
	
		
			
				|  |  |        <label v-if="type === 'big'" class="tips">删除</label>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  | -    <audio ref="audio" :src="wavBlob" preload="metadata"></audio>
 | 
	
		
			
				|  |  | +    <audio ref="audio" :src="file_url" preload="metadata"></audio>
 | 
	
		
			
				|  |  |    </div>
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script>
 | 
	
		
			
				|  |  |  import Recorder from 'js-audio-recorder'; // 录音插件
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import { GetStaticResources, GetFileStoreInfo } from '@/api/app';
 | 
	
		
			
				|  |  |  import { secondFormatConversion } from '@/utils/transform';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export default {
 | 
	
	
		
			
				|  | @@ -48,10 +49,6 @@ export default {
 | 
	
		
			
				|  |  |        type: String,
 | 
	
		
			
				|  |  |        default: '',
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    recordTime: {
 | 
	
		
			
				|  |  | -      type: Number,
 | 
	
		
			
				|  |  | -      default: 0,
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  |      itemIndex: {
 | 
	
		
			
				|  |  |        type: Number,
 | 
	
		
			
				|  |  |        default: null,
 | 
	
	
		
			
				|  | @@ -76,7 +73,9 @@ export default {
 | 
	
		
			
				|  |  |          paused: true,
 | 
	
		
			
				|  |  |        },
 | 
	
		
			
				|  |  |        playtime: 0, // 播放时间
 | 
	
		
			
				|  |  | -      recordTimes: JSON.parse(JSON.stringify(this.recordTime)),
 | 
	
		
			
				|  |  | +      recordTimes: 0,
 | 
	
		
			
				|  |  | +      file_url: '',
 | 
	
		
			
				|  |  | +      recordTime: 0,
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |    computed: {
 | 
	
	
		
			
				|  | @@ -87,6 +86,19 @@ export default {
 | 
	
		
			
				|  |  |        return this.type === 'big' ? 24 : 16;
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | +  watch: {
 | 
	
		
			
				|  |  | +    wavBlob: {
 | 
	
		
			
				|  |  | +      handler(val) {
 | 
	
		
			
				|  |  | +        if (!val) return;
 | 
	
		
			
				|  |  | +        GetFileStoreInfo({ file_id: val }).then(({ file_url, media_duration }) => {
 | 
	
		
			
				|  |  | +          this.file_url = file_url;
 | 
	
		
			
				|  |  | +          this.recordTime = media_duration;
 | 
	
		
			
				|  |  | +          this.recordTimes = JSON.parse(JSON.parse(media_duration));
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +      immediate: true,
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  |    mounted() {
 | 
	
		
			
				|  |  |      this.$refs.audio.addEventListener('ended', () => {
 | 
	
		
			
				|  |  |        this.audio.paused = true;
 | 
	
	
		
			
				|  | @@ -139,20 +151,26 @@ export default {
 | 
	
		
			
				|  |  |          this.hasMicro = 'normal';
 | 
	
		
			
				|  |  |          this.recorder.stop();
 | 
	
		
			
				|  |  |          clearInterval(this.timer);
 | 
	
		
			
				|  |  | -        let tolTime = this.recorder.duration; // 录音总时长
 | 
	
		
			
				|  |  |          // 录音结束,获取取录音数据
 | 
	
		
			
				|  |  |          let wav = this.recorder.getWAVBlob(); // 获取 WAV 数据
 | 
	
		
			
				|  |  |          this.microphoneStatus = false;
 | 
	
		
			
				|  |  |          let reader = new window.FileReader();
 | 
	
		
			
				|  |  |          reader.readAsDataURL(wav);
 | 
	
		
			
				|  |  |          reader.onloadend = () => {
 | 
	
		
			
				|  |  | -          this.$emit('updateWav', reader.result, Math.floor(tolTime), this.itemIndex);
 | 
	
		
			
				|  |  | -          this.updateData(reader.result, Math.floor(tolTime));
 | 
	
		
			
				|  |  | +          let MethodName = 'file_store_manager-SaveFileByteBase64Text';
 | 
	
		
			
				|  |  | +          let data = {
 | 
	
		
			
				|  |  | +            base64_text: reader.result.replace('data:audio/wav;base64,', ''),
 | 
	
		
			
				|  |  | +            file_suffix_name: 'mp3',
 | 
	
		
			
				|  |  | +          };
 | 
	
		
			
				|  |  | +          GetStaticResources(MethodName, data).then((res) => {
 | 
	
		
			
				|  |  | +            if (res.status === 1) {
 | 
	
		
			
				|  |  | +              this.$emit('update:wavBlob', res.file_id);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |        } else {
 | 
	
		
			
				|  |  |          this.hasMicro = '';
 | 
	
		
			
				|  |  | -        this.$emit('updateWav', '', 0, this.itemIndex);
 | 
	
		
			
				|  |  | -        this.updateData('', 0);
 | 
	
		
			
				|  |  | +        this.$emit('update:wavBlob', '');
 | 
	
		
			
				|  |  |          // 开始录音
 | 
	
		
			
				|  |  |          this.recorder.start();
 | 
	
		
			
				|  |  |          this.microphoneStatus = true;
 | 
	
	
		
			
				|  | @@ -171,12 +189,7 @@ export default {
 | 
	
		
			
				|  |  |        this.playtime = 0;
 | 
	
		
			
				|  |  |        this.recordTimes = 0;
 | 
	
		
			
				|  |  |        clearInterval(this.timer);
 | 
	
		
			
				|  |  | -      this.$emit('deleteWav', this.itemIndex);
 | 
	
		
			
				|  |  | -      this.updateData('', 0);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    updateData(wav, time) {
 | 
	
		
			
				|  |  | -      this.$emit('update:wavBlob', wav);
 | 
	
		
			
				|  |  | -      this.$emit('update:recordTime', time);
 | 
	
		
			
				|  |  | +      this.$emit('update:wavBlob', '');
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  };
 |