Commit 7da1e581 by 李伟康

commit 修复埋点

1 parent c5a9c974
...@@ -12,12 +12,12 @@ import utils from '@/utils/utils.js' ...@@ -12,12 +12,12 @@ 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)
} }
}, },
receptionTrack: { receptionKey: {
handler(val) { handler (val) {
this.handler(val, this.updateMaterialPointList) this.handler(this.receptionTrack, this.updateMaterialPointList)
} }
} }
}, },
computed: { computed: {
...mapState(['user.customerInfo']), ...mapState(['user.customerInfo']),
...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack']) ...mapGetters(['customerInfo', 'receptionStatus', 'booksList', 'receptionTrack', 'receptionKey'])
}, },
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) 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,17 +177,17 @@ export default { ...@@ -177,17 +177,17 @@ 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')
if (result !== 1) { if (result !== 1) {
uni.showToast({ uni.showToast({
...@@ -197,13 +197,13 @@ export default { ...@@ -197,13 +197,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()
} }
......
...@@ -8,4 +8,5 @@ export default { ...@@ -8,4 +8,5 @@ export default {
receptionTrack: (state) => state.user.receptionTrack, receptionTrack: (state) => state.user.receptionTrack,
receptionStatus: (state) => state.audio.receptionStatus, receptionStatus: (state) => state.audio.receptionStatus,
booksList: (state) => state.audio.booksList, booksList: (state) => state.audio.booksList,
receptionKey: (state) => state.user.receptionKey,
}; };
...@@ -30,7 +30,8 @@ export default { ...@@ -30,7 +30,8 @@ export default {
receptionTrack: {}, //接待记录埋点 receptionTrack: {}, //接待记录埋点
boutiqueDefaultCarBrandId: '', boutiqueDefaultCarBrandId: '',
viewKey: Date.now(), viewKey: Date.now(),
boutiqueCarList:[] boutiqueCarList:[],
receptionKey:Date.now(), //接待记录埋点KEY
}; };
}, },
mutations: { mutations: {
...@@ -81,9 +82,11 @@ export default { ...@@ -81,9 +82,11 @@ export default {
}, },
setReceptionTrack ({ state }, { key, value }) { setReceptionTrack ({ state }, { key, value }) {
state.receptionTrack[key] = value state.receptionTrack[key] = value
state.receptionKey = Date.now()
}, },
clearReceptionTrack ({ state }) { clearReceptionTrack ({ state }) {
state.receptionTrack = {} state.receptionTrack = {}
state.receptionKey = Date.now()
}, },
updateViewKey({ state }){ updateViewKey({ state }){
state.viewKey = Date.now(); state.viewKey = Date.now();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!