Commit 35cd5609 by liimin

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

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