Commit 35cd5609 by liimin

修改40分钟未操作后无法修改参数的问题

1 parent 6fc8708e
......@@ -2,22 +2,22 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-26 10:03:54
* @LastEditors: limin
* @LastEditTime: 2025-01-15 21:23:38
* @LastEditTime: 2025-03-11 18:19:33
* @FilePath: \gl_tape\mixin\record\recorder.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { AudioManager, TempRecord, RecordDto } from '../../utils/recordManager/index'
import { AudioManager, TempRecord, RecordDto, helpler } from '../../utils/recordManager/index'
import { mapMutations, mapState, mapGetters } from 'vuex'
import utils from '@/utils/utils.js'
import { storageApi } from '@/utils/cache'
import permision from '@/js_sdk/wa-permission/permission.js'
export default {
provide () {
provide() {
return {
getRecorder: () => this.record
}
},
async mounted () {
async mounted() {
this.audioManager = new AudioManager(this.onAudioStart, this.onAudioStop, this.onError)
this.initDto()
this.record = new TempRecord(this.tempRecord, this.triggleTempNumber)
......@@ -29,30 +29,30 @@ export default {
* @param {object} val 监听客户信息
*/
customerInfo: {
handler (val) {
handler(val) {
this.handler(val, this.updateCustomerInfo)
},
deep: true
},
booksList: {
handler (val) {
handler(val) {
this.handler(val, this.updateBookList)
}
},
receptionStatus: {
handler (val) {
handler(val) {
this.handler(val, this.updateReceptionStatus)
}
},
receptionKey: {
handler (val) {
this.handler(this.receptionTrack, this.updateMaterialPointList)
receptionTrack: {
handler(val) {
this.handler(val, this.updateMaterialPointList)
}
}
},
computed: {
...mapState(['user.customerInfo']),
...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack', 'receptionKey'])
...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack'])
},
methods: {
...mapMutations('audio', ['setReceptionStatus', 'setBooks', 'setPerRecordNumber']),
......@@ -66,20 +66,20 @@ export default {
this.audioManager.start()
}, 300),
initReception () {
initReception() {
this.setBooks([])
this.clearCustomerInfo()
this.setReceptionStatus('')
this.initTime()
},
async onAudioStart () {
async onAudioStart() {
if (this.audioManager.counter === 0) {
await this.record.add()
} else {
this.record.addAudio()
}
},
async onAudioStop () {
async onAudioStop() {
if (this.audioManager.isRecording) {
uni.$logger.local.info('〖接待管理Recorder〗 == 接待中,再次开启录音! ')
this.audioManager.start()
......@@ -87,7 +87,7 @@ export default {
uni.$logger.local.info('〖接待管理Recorder〗 == 断开录音! ')
}
},
onAudioError (error) {
onAudioError(error) {
const message = error.message
this.reportError(`录音异常: error: ${message}`, message)
},
......@@ -96,12 +96,12 @@ export default {
* @params {boolean} status true 不保存记录/AUDIO_STATUS.ABNORMAL 只要断开录音
* @returns {void}
*/
async stopAudio (isNotSave = false) {
async stopAudio(isNotSave = false) {
uni.$logger.local.info('〖接待管理Recorder〗 == 结束接待! ')
this.stop()
await this.saveAndClearRecord(isNotSave)
},
async saveAndClearRecord (isNotSave = false) {
async saveAndClearRecord(isNotSave = false) {
if (isNotSave) {
return this.record.clearLocalRecord()
}
......@@ -109,23 +109,23 @@ export default {
//如果不需要保存记录
await this.record.save()
},
stop () {
stop() {
this.endWatchClick()
this.record.clearLoopTimer()
if (this.audioManager.isRecording) {
this.audioManager.stop()
}
},
handler (params, fn) {
if (!this.audioManager.isRecording) return
handler(params, fn) {
if (!this.audioManager.isRecording && (this.record?.endReasonType !== 1 || this.receptionStatus == 0)) return
fn.call(this, params)
},
reset () {
reset() {
this.audioManager = null
this.record = null
this.tempRecord = null
},
initDto () {
initDto() {
const { shopMerchantId, phone, sceneType, uuid, name, merchantId, channelType, merchantName } = storageApi.getUserInfo()
const { deviceId: appCode } = uni.getDeviceInfo()
const dto = new RecordDto({
......@@ -143,7 +143,7 @@ export default {
this.sceneType = sceneType
this.tempRecord = dto
},
updateCustomerInfo (customerInfo = {}) {
updateCustomerInfo(customerInfo = {}) {
const { customerName, phoneNumber, salesUuid, carModel, staffName: salesName } = customerInfo
this.record.updatePreRecords({
customerName,
......@@ -153,7 +153,7 @@ export default {
salesName
})
},
updateBookList (booksList) {
updateBookList(booksList) {
const receptionCustomerPaySourceList = booksList.map(item => {
return {
id: item.id,
......@@ -163,7 +163,7 @@ export default {
})
this.record.updatePreRecords({ receptionCustomerPaySourceList })
},
updateMaterialPointList (receptionTrack) {
updateMaterialPointList(receptionTrack) {
const { merchantId, staffUuid, staffName } = this.tempRecord
let receptionCustomerMaterialPointList = []
Object.keys(receptionTrack).map(key => {
......@@ -177,18 +177,19 @@ export default {
})
this.record.updatePreRecords({ receptionCustomerMaterialPointList })
},
updateReceptionStatus (status) {
updateReceptionStatus(status) {
this.record.updatePreRecords({ receptionStatus: status })
},
getRecorder () {
getRecorder() {
return this.record
},
async triggleTempNumber () {
async triggleTempNumber() {
const _records = await this.record.getRecords()
this.setPerRecordNumber(_records.length)
},
async isPermission () {
async isPermission() {
const result = await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
await helpler.sleep(0)
if (result !== 1) {
uni.showToast({
title: '为了记录语音通话,请打开录音权限',
......@@ -197,13 +198,13 @@ export default {
}
return result === 1
},
async checkBeforeStart () {
async checkBeforeStart() {
const isPermission = await this.isPermission()
const isRecording = this.audioManager.isRecording
return isPermission && !isRecording
}
},
beforeDestroy () {
beforeDestroy() {
this.stop()
this.reset()
}
......
......@@ -3,8 +3,8 @@
* @version: 1.0.0
* @Author: limin
* @Date: 2024-06-28 17:12:39
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2025-01-14 16:56:37
* @LastEditors: limin
* @LastEditTime: 2025-03-11 18:07:04
* @FilePath: \gl_tape\utils\recordManager\index.js
*/
// import { singleton } from '../utils.js'
......@@ -13,5 +13,6 @@ import DBRecord from './dbRecord.js'
// import Record from './Record.js'
import RecordDto from './RecordDto.js'
import TempRecord from './TempRecord.js'
import helpler from './helpler.js'
// const SingleDBTempRecord = singleton(TempRecord)
module.exports = { AudioManager, DBRecord, RecordDto, TempRecord }
module.exports = { AudioManager, DBRecord, RecordDto, TempRecord, helpler }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!