Commit 025e48e6 by 前端

变量

1 parent cc4dbb26
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-21 10:49:34
* @LastEditTime: 2024-10-23 17:23:29
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -14,6 +14,11 @@ const UPLOAD_STATUS = {
success: 1,
fail: 2
}
const AUDIO_STATUS = {
START: 'start', //开始
END: 'end', //结束
ABNORMAL: 'abnormal' //异常
}
const audioTime = 10 * 60 * 1000
import { mapMutations, mapState } from 'vuex'
import utils from '@/utils/utils.js'
......@@ -41,7 +46,7 @@ export default {
changeData: {
handler(val) {
console.log(val, 'val', this.audioInfo.audioStatus)
if (this.audioInfo.audioStatus != 'start') return
if (this.audioInfo.audioStatus != AUDIO_STATUS.START) return
const { customerInfo, booksList, receptionStatus } = val
const params = this.getParams(customerInfo, booksList, receptionStatus)
interruptRecord.updatePreRecords(params)
......@@ -83,7 +88,7 @@ export default {
this.times = 0
clearInterval(this.timer)
this.timer = null
this.stopAudio('abnormal')
this.stopAudio(AUDIO_STATUS.ABNORMAL)
this.setReceptionStatus(0)
this.setAudioInfo({ endReasonType: 1 })
},
......@@ -151,12 +156,12 @@ export default {
//开始录音
startAudio: utils.throttle(async function () {
if (this.audioInfo.audioStatus == 'start') return
if (this.audioInfo.audioStatus == AUDIO_STATUS.START) return
this.setBooks([])
this.$store.dispatch('clearCustomerInfo')
this.setReceptionStatus('')
this.initTime()
this.setAudioInfo({ audioList: [], audioStatus: 'start' })
this.setAudioInfo({ audioList: [], audioStatus: AUDIO_STATUS.START })
recorderManager.onStart(() => {
setTimeout(() => {
const params = this.getParams(this.$store.state.user.customerInfo, this.booksList, this.receptionStatus)
......@@ -169,7 +174,7 @@ export default {
numberOfChannels: 1
})
recorderManager.onStop(async res => {
if (this.audioInfo.audioStatus == 'start') {
if (this.audioInfo.audioStatus == AUDIO_STATUS.START) {
uni.getRecorderManager().start({
duration: audioTime,
sampleRate: 16000,
......@@ -178,6 +183,11 @@ export default {
}
})
}, 300),
/**
* 保存记录
* @params {boolean} isNormal 是否是正常保存
* @returns {void}
*/
async handleSave(isNormal = true) {
const records = interruptRecord.getPreRecord()
console.log(records, 'records')
......@@ -203,7 +213,6 @@ export default {
}
delete records.audioPath
let saveRecords = Object.assign(records, { recordUrlList })
console.log(isNormal, 'isNormal')
if (isNormal) {
this.saveRecord(saveRecords)
} else {
......@@ -222,7 +231,11 @@ export default {
interruptRecord.removePreRecord(record.id)
unlock()
},
//结束接待
/**
* 结束接待
* @params {boolean} status true 不保存记录/AUDIO_STATUS.ABNORMAL 只要断开录音
* @returns {void}
*/
stopAudio: utils.throttle(async function (status) {
console.log('结束')
// const result = await this.$permision.requestAndroidPermission(
......@@ -235,27 +248,27 @@ export default {
// });
// return;
// }
if (status == 'abnormal') {
this.setAudioInfo({ audioStatus: 'abnormal' })
if (status == AUDIO_STATUS.ABNORMAL) {
this.setAudioInfo({ audioStatus: AUDIO_STATUS.ABNORMAL })
recorderManager.stop()
return
}
if (this.audioInfo.audioStatus == 'abnormal' && status != true) {
this.setAudioInfo({ audioStatus: 'end' })
if (this.audioInfo.audioStatus == AUDIO_STATUS.ABNORMAL && status != true) {
this.setAudioInfo({ audioStatus: AUDIO_STATUS.END })
this.handleSave()
return
}
if (this.audioInfo.audioStatus != 'start') {
if (this.audioInfo.audioStatus != AUDIO_STATUS.START) {
return
}
this.setAudioInfo({ audioStatus: 'end' })
this.setAudioInfo({ audioStatus: AUDIO_STATUS.END })
//直接退出
uni.showLoading({
mask: true
})
setTimeout(() => {
uni.hideLoading()
if (this.audioInfo.audioStatus == 'end') {
if (this.audioInfo.audioStatus == AUDIO_STATUS.END) {
this.handleSave()
}
}, 3000)
......@@ -263,14 +276,13 @@ export default {
clearInterval(this.timer)
this.timer = null
if (status) {
this.setAudioInfo({ audioStatus: 'no' })
this.removeRecords()
}
recorderManager.stop()
}, 1500),
//监听点击事件
initTime() {
if (this.audioInfo.audioStatus != 'start') return
if (this.audioInfo.audioStatus != AUDIO_STATUS.START) return
this.timer = setInterval(() => {
// console.log(this.times);
this.times++
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!