Commit 9d25c711 by liimin

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

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