Commit 9d25c711 by liimin

refactor(录音管理): 优化录音模块代码并调整超时设置

- 移除调试日志和未使用的代码
- 调整录音超时时间为1分钟便于测试
- 修复TempRecord销毁逻辑,添加reset方法
- 使用OAID替代deviceId作为设备标识
- 清理equity页面的冗余代码和注释
1 parent 70aa58ea
......@@ -66,31 +66,6 @@
<script type="text/ecmascript-6">
import { mapMutations } from "vuex";
const phoneRex = /^[1]([2-9])[0-9]{9}$/;
const formObject_boutique = [{
label: "客户姓名",
key: "customerName",
type: "input",
inputType: "text",
maxlength: 20,
placeholder: '请输入客户姓名',
required: true
},
{
label: "品牌车型",
key: "carModel",
type: "input",
popKey: "carBrandListVisible",
placeholder: '请选择品牌车型',
disabled: true
},
{
label: "品牌车型",
key: "carModel",
type: "input",
maxlength: 50,
placeholder: '请输入品牌车型',
required: true
}]
export default {
name: 'FinishStep',
props: {
......
......@@ -91,7 +91,6 @@ export default {
// 初始化 imagelist(最多三项)并更新 currentIndex
getDatalist() {
this.datalist = this.moduleList
console.log(this.datalist, '===')
const list = JSON.parse(JSON.stringify(this.style_object))
const len = this.datalist.length
......
......@@ -2,13 +2,14 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-26 10:03:54
* @LastEditors: limin
* @LastEditTime: 2025-12-24 15:09:02
* @LastEditTime: 2025-12-24 19:29:52
* @FilePath: \simgle_app\mixin\record\recorder.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { AudioManager, TempRecord, RecordDto, helpler } from '../../utils/recordManager/index'
import { mapMutations, mapState, mapGetters } from 'vuex'
import { storageApi } from '@/utils/cache'
import utils from '@/utils/utils'
import permision from '@/js_sdk/wa-permission/permission.js'
export default {
provide() {
......@@ -18,7 +19,7 @@ export default {
},
async mounted() {
this.audioManager = new AudioManager(this.onAudioStart, this.onAudioStop, this.onAudioError)
this.initDto()
await this.initDto()
this.record = new TempRecord(this.tempRecord, this.triggleTempNumber)
this.triggleTempNumber()
},
......@@ -133,7 +134,7 @@ export default {
},
stop() {
this.endWatchClick?.()
this.record?.destroy()
this.record?.clearLoopTimer()
this.audioManager?.stop()
},
handler(params, fn) {
......@@ -146,20 +147,17 @@ export default {
this.record = null
this.tempRecord = null
},
initDto() {
async initDto() {
const userInfo = storageApi.getUserInfo() || {}
const {
user: { userId, userName, deptId },
sceneType = ''
} = userInfo
const { deviceId: machineCode } = uni.getDeviceInfo()
const { user:{userId,userName,deptId} } = userInfo
const machineCode = await utils.getOAID()
const dto = new RecordDto({
userId,
userName,
merchantId: deptId,
machineCode
})
this.sceneType = sceneType
// this.sceneType = sceneType
this.tempRecord = dto
},
updateCustomerInfo(customerInfo = {}) {
......@@ -232,6 +230,7 @@ export default {
}
},
beforeDestroy() {
this.record?.destroy()
this.stop()
this.reset()
}
......
......@@ -36,10 +36,7 @@
import detail from './detail/detail'
import { mapMutations } from 'vuex'
import HomeFrame from '@/components/HomeFrame/index.vue'
import { set } from 'lodash';
// import storge from "@/mixin/storge";
export default {
// mixins: [storge],
components: { HomeFrame, detail },
data () {
return {
......@@ -66,9 +63,6 @@ export default {
},
finishRef() {
return this.homeRef.finishRef
},
isRecording() {
return this.homeRef && this.homeRef.audioManager && this.homeRef.audioManager.isRecording
}
},
onBackPress (options) {
......@@ -84,7 +78,6 @@ export default {
async onLoad () {
// uni.hideLoading()
const mockdata = await uni.$api.systemApi.getMockData(true) //获取APP配置信息
console.log(mockdata,'mockdata')
uni.$storage.set('typeItem', {
typeCode: mockdata?.typeCode || '',
typeName: mockdata?.typeName || ''
......@@ -97,7 +90,7 @@ export default {
// this.requested = true
// this.$refs.home.updateApp(true)
this.getHomeSource(mockdata?.typeCode)
this.getSoure(mockdata?.typeCode)
this.getSource(mockdata?.typeCode)
// setTimeout(() => {
// this.start()
// }, 1e3)
......@@ -107,13 +100,13 @@ export default {
},
methods: {
...mapMutations('audio', ['setReceptionStatus']),
...mapMutations('material', ['setTypeCode', 'setMaterial']),
...mapMutations('material', ['setMaterial']),
init () {
// this.findPayInfo()
if (this.requested && !this.id) this.$refs.home.updateApp()
if (this.requested && !this.id) this.homeRef.updateApp()
},
// 查询素材
async getSoure (typeCode) {
async getSource (typeCode) {
const first_res = await uni.$api.commonApi.getPadFolderList({
typeCode,
status: 0
......@@ -173,33 +166,32 @@ export default {
status: 0,
showOnHomepage: 1
})
console.log(res, 'res首页')
this.homeList = Array.isArray(res?.data) ? res.data : []
},
changeType () {
const typeItem = uni.$storage.get('typeItem')
this.getHomeSource(typeItem?.typeCode)
this.getSoure(typeItem?.typeCode)
this.setTypeCode(typeItem?.typeCode || '')
const typeCode = typeItem?.typeCode || ''
this.getHomeSource(typeCode)
this.getSource(typeCode)
},
async start (item) {
if (!this.moduleList.length) return uni.showToast({
title: '该场景尚未配置素材,请联系总部人员',
icon: 'none'
})
const isPermision = await this.$refs.home.isPermission()
if (this.recording || !isPermision) return
const isPermision = await this.homeRef.isPermission()
if (this.homeRef.audioManager.isRecording || !isPermision) return
const material = this.moduleList[0]
this.setMaterial(material)
// uni.showLoading({
// mask: true
// })
await this.$refs.home.startAudio()
await this.homeRef.startAudio()
this.clearHistory()
this.id = +material.id
// this.id = 6
this.type = 'edit'
this.recording = true
// this.recording = true
// setTimeout(() => {
// uni.hideLoading()
// }, 1e3)
......@@ -207,10 +199,10 @@ export default {
toDetail (index) {
let item = this.moduleList[index]
this.chooseItem = item
this.$refs.home.previewRef.open()
this.previewRef.open()
},
cancel () {
this.$refs.home.previewRef.close()
this.previewRef.close()
},
preview () {
let { id, title } = this.chooseItem
......@@ -221,9 +213,9 @@ export default {
},
// 完成接待
done (e) {
this.$refs.home.finishRef.close()
if (this.recording) this.$refs.home.stopAudio()
this.recording = false
this.finishRef.close()
if (this.homeRef.audioManager.isRecording) this.homeRef.stopAudio()
// this.recording = false
setTimeout(() => {
this.id = ''
this.type = ''
......@@ -236,17 +228,17 @@ export default {
const detailRef = this.$refs.detail
if (detailRef.showPayPage) return (detailRef.showPayPage = false)
if (!this.id) return uni.navigateBack()
if (this.type != 'preview') return this.$refs.home.finishRef.open()
if (this.type != 'preview') return this.finishRef.open()
this.backHome()
},
backHome () {
if (this.recording) this.$refs.home.stopAudio(true)
this.$refs.home.finishRef.close()
if (this.homeRef.audioManager.isRecording) this.homeRef.stopAudio(true)
this.finishRef.close()
this.id = ''
this.type = ''
this.clearHistory()
// this.init()
this.recording = false
// this.recording = false
// this.$refs.home.$refs.leftBox.getMessageInfo()
},
nextStep () {
......@@ -261,67 +253,67 @@ export default {
this.$store.dispatch('clearReceptionTrack')
},
openStep () {
this.$refs.home.finishRef.close()
this.finishRef.close()
this.$refs.detail.open()
},
// 查询门店支付配置
async findPayInfo () {
const { shopMerchantId } = uni.$storage.get('userInfo')
const data = await uni.$api.commonApi.findPayInfo({
merchantId: shopMerchantId
})
let paymentType = []
data.find(item => {
if (item.paymentType == 1)
paymentType.push({
name: '扫码支付',
type: 1,
title: '付款二维码',
...item
})
if (item.paymentType == 2)
paymentType.push({
name: '对公账户',
type: 2,
title: '付款方式',
...item
})
})
this.$store.dispatch('setPaymentType', paymentType)
},
// async findPayInfo () {
// const { shopMerchantId } = uni.$storage.get('userInfo')
// const data = await uni.$api.commonApi.findPayInfo({
// merchantId: shopMerchantId
// })
// let paymentType = []
// data.find(item => {
// if (item.paymentType == 1)
// paymentType.push({
// name: '扫码支付',
// type: 1,
// title: '付款二维码',
// ...item
// })
// if (item.paymentType == 2)
// paymentType.push({
// name: '对公账户',
// type: 2,
// title: '付款方式',
// ...item
// })
// })
// this.$store.dispatch('setPaymentType', paymentType)
// },
changeTab (index) {
// if (index == 0) this.init()
},
/**按序加载车型 */
async getCarBrandsList (carBrandList, index) {
const item = carBrandList[index]
if (!item) return
const carList = uni.getStorageSync(`${item.id}_${item.brandId}_carlist`)
if (index < carBrandList.length - 1) {
index += 1
if (!carList) {
const list = await uni.$api.commonApi.getCarBrandsList({
brandId: item.brandId,
childBrandId: item.id
})
if (list) uni.setStorageSync(`${item.id}_${item.brandId}_carlist`, list)
this.getCarBrandsList(carBrandList, ++index)
} else this.getCarBrandsList(carBrandList, ++index)
}
},
// async getCarBrandsList (carBrandList, index) {
// const item = carBrandList[index]
// if (!item) return
// const carList = uni.getStorageSync(`${item.id}_${item.brandId}_carlist`)
// if (index < carBrandList.length - 1) {
// index += 1
// if (!carList) {
// const list = await uni.$api.commonApi.getCarBrandsList({
// brandId: item.brandId,
// childBrandId: item.id
// })
// if (list) uni.setStorageSync(`${item.id}_${item.brandId}_carlist`, list)
// this.getCarBrandsList(carBrandList, ++index)
// } else this.getCarBrandsList(carBrandList, ++index)
// }
// },
/**素材内容 */
setViewInfo (data) {
let { moduleList, toolList, id } = data
this.moduleList = moduleList
this.toolList = toolList
this.mediaId = id
this.loadComplete = true
this.$store.state.user = {
...this.$store.state.user,
...data
}
}
// setViewInfo (data) {
// let { moduleList, toolList, id } = data
// this.moduleList = moduleList
// this.toolList = toolList
// this.mediaId = id
// this.loadComplete = true
// this.$store.state.user = {
// ...this.$store.state.user,
// ...data
// }
// }
}
}
</script>
......
......@@ -4,12 +4,12 @@
* @Author: limin
* @Date: 2024-12-04 18:17:23
* @LastEditors: limin
* @LastEditTime: 2025-12-23 13:55:42
* @LastEditTime: 2025-12-24 18:55:23
* @FilePath: \simgle_app\utils\recordManager\AudioManager.js
*/
class AudioManager {
startOptions = {
duration: 10 * 60 * 1000, //默认10分钟
duration: 1 * 60 * 1000, //默认10分钟
sampleRate: 16000,
numberOfChannels: 1
}
......
......@@ -4,7 +4,7 @@
* @Author: limin
* @Date: 2025-01-02 18:49:17
* @LastEditors: limin
* @LastEditTime: 2025-12-24 15:48:41
* @LastEditTime: 2025-12-24 19:28:04
* @FilePath: \simgle_app\utils\recordManager\TempRecord.js
*/
import utils from '../utils'
......@@ -192,6 +192,7 @@ class TempRecord {
* @returns {Promise<void>}
*/
async add() {
this.reset()
// 创建一个新的记录对象
this.record = this.__createNewRecord()
// 异步添加新创建的记录对象
......@@ -199,6 +200,9 @@ class TempRecord {
// 添加音频资源
this.addAudio()
}
reset() {
this._isDestroyed = false
}
/**
* 构造一条新的接待记录的初始对象
* @returns {Object} 新记录对象(含 id、开始时间、空的录音列表等)
......@@ -449,15 +453,6 @@ class TempRecord {
async destroy() {
this._isDestroyed = true
this.clearLoopTimer()
// 等待所有正在进行的保存操作完成
if (this._savingPromise) {
uni.$logger.local.info('〖接待记录Record〗 == 等待最后的保存操作完成...')
try {
await this._savingPromise
} catch (e) {
uni.$logger.local.error('〖接待记录Record〗 == 等待保存操作异常: ' + e.message)
}
}
// await this.clearLocalRecord()
uni.$logger.local.info('〖接待记录Record〗 == TempRecord 实例已销毁')
}
......@@ -502,7 +497,7 @@ class TempRecord {
* @returns {Promise<void>}
*/
withError() {
// return this.__update('endReasonType', 1)
return this.__update('endReasonType', 1)
}
/**
* 批量更新当前记录的多个预填字段
......
......@@ -258,6 +258,19 @@ const refreshPageData = notRefreshOrder => {
getApp().globalDataorderListDateListScreenRefresh = true
}
const getOAID = () => {
return new Promise((resolve, reject) => {
plus.device.getOAID({
success: function (e) {
resolve(e.oaid)
},
fail: function (e) {
resolve(uni.getDeviceInfo().deviceId)
}
})
})
}
export default {
compareVersions,
convertDateTimeFormat,
......@@ -277,5 +290,6 @@ export default {
decimal,
showNoAccess,
setCopyData,
refreshPageData
refreshPageData,
getOAID
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!