Commit a7218268 by 前端

保存记录

1 parent 526dcf0f
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"launchtype" : "local" "launchtype" : "local"
}, },
"h5" : { "h5" : {
"launchtype" : "local" "launchtype" : "remote"
}, },
"mp-weixin" : { "mp-weixin" : {
"launchtype" : "local" "launchtype" : "local"
......
<template>
<view class="data-container">
<view class="nav-bar" @click="$emit('cancel')">
<view class="back" @click="$emit('update:showPayPage', false)">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">接待记录</view>
</view>
<view class="form">
<template v-for="(i, index) in formObject">
<view :class="['form-item', { active: focusIndex == index }]" :key="index">
<view class="label required">{{ i.label }}</view>
<view :class="['value', { error: showError(i.key) }]">
<template v-if="i.type == 'input'">
<input :type="i.inputType" :maxlength="i.maxlength" v-model="customerInfo[i.key]" class="input" :placeholder="i.placeholder" @focus="focusIndex = index" @blur="resetFocusIndex" />
</template>
<template v-else>
<view :class="['select flex', { placeholderStyle: !customerInfo[i.key] }]" @click="showPopup(i.popKey, index)">
<view class="text-hide">{{ customerInfo[i.key] || i.placeholder }}</view>
<uni-icons class="arrow" type="right" :size="16"></uni-icons>
</view>
</template>
</view>
</view>
</template>
</view>
<view class="footer-box">
<view class="cancel-btn" @click="$emit('cancel')">取消</view>
<view class="submit-btn" @click="handleSave">提交</view>
</view>
<car-brands ref="carBrandListVisible" @select="handleSelect($event, 'carBrandListVisible')" />
<employee ref="employeeBoxVisible" @select="handleSelect($event, 'employeeBoxVisible')" />
<MessageBox ref="receptionStatusVisible" position="bottom" :isFooter="false" title="请选择接待结果" :maxHeight="1000">
<view class="select-box">
<view class="select-item" :class="{ checked: customerInfo.receptionStatus == item.label }" @click="selectReception(item.label)" v-for="(item, index) in receptionList" :key="index">
{{ item.label }}
</view>
</view>
</MessageBox>
</view>
</template>
<script type="text/ecmascript-6">
import CarBrands from '@/components/CarBrands.vue'
import Employee from '@/components/Employee.vue'
import CustomerAutocomplete from '@/components/CustomerAutocomplete.vue'
const phoneRex = /^[1]([3-9])[0-9]{9}$/;
export default {
components: {
CarBrands,
Employee,
CustomerAutocomplete
},
props: {
customerInfo: {
type: Object,
default: () => ({})
}
},
data() {
return {
receptionList: [{
label: '成交',
value: 1
},
{
label: '战败',
value: 0
}
],
formObject: [{
label: "车主姓名",
placeholder: '车主姓名',
key: 'customerName',
type: 'input',
inputType: 'text',
maxlength: 50
},
{
label: "车主电话",
placeholder: '车主电话',
key: 'phoneNumber',
type: 'input',
inputType: 'tel',
maxlength: 11
},
{
label: "品牌车型",
placeholder: '品牌车型',
key: 'carModel',
type: 'select',
popKey: 'carBrandListVisible'
},
{
label: "接待结果",
key: "receptionStatus",
type: "select",
popKey: "receptionStatusVisible",
placeholder: '请选择',
},
{
label: "销售姓名",
key: "salesName",
type: "select",
popKey: "employeeBoxVisible",
placeholder: '请选择',
},
],
focusIndex: -1,
}
},
mounted() {
const i = this.receptionList.findIndex(e => e.value == this.customerInfo.receptionStatus)
this.customerInfo.receptionStatus = this.receptionList[i].label
},
methods: {
selectReception(value) {
this.customerInfo.receptionStatus = value
this.$refs.receptionStatusVisible.close()
},
showError(key) {
let flag = !this.customerInfo[key]
if (key == 'phoneNumber' && this.customerInfo[key]) flag = !phoneRex.test(this.customerInfo[key])
return flag
},
handleSave() {
const result = this.check(true)
if (!result) return
const i = this.receptionList.findIndex(e => e.label == this.customerInfo.receptionStatus)
this.customerInfo.receptionStatus = this.receptionList[i].value
this.$emit('submit',this.customerInfo)
},
check(all = false) {
let flag = true
try {
this.formObject.map(e => {
if (!this.customerInfo[e.key]) throw false
if (!all && e.key == 'phoneNumber' && !phoneRex.test(this.formData[e.key])) {
uni.showToast({
title: "请输入正确的车主电话",
icon: "none",
});
throw false
}
})
} catch (error) {
flag = error
}
return flag
},
handleSelect(item, popkey) {
this.$refs[popkey].close()
if (popkey == 'employeeBoxVisible') {
this.customerInfo.salesUuid = item.uuid
this.customerInfo.staffName = item.staffName
} else {
this.$refs.carBrandListVisible.close()
this.customerInfo.carModel = item.name
}
this.resetFocusIndex()
},
showPopup(e, index) {
this.focusIndex = index
this.$refs[e].open()
},
resetFocusIndex() {
this.focusIndex = -1
}
}
}
</script>
<style scoped lang="scss">
.data-container {
background: #ffffff59;
border-radius: 48rpx;
margin: 80rpx 66rpx 80rpx 0;
height: calc(100% - 160rpx);
box-shadow: inset 0 0 16rpx 0 #ffffff;
border: 2rpx solid #fff;
box-sizing: border-box;
position: relative;
.nav-bar {
position: absolute;
width: 100%;
height: 96rpx;
left: 0;
top: 28rpx;
z-index: 9;
text-align: center;
font-weight: 700;
font-size: 32rpx;
color: #1a1a1a;
line-height: 96rpx;
.back {
position: absolute;
left: 0;
top: 0;
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
}
}
.form {
display: flex;
flex-wrap: wrap;
gap: 80rpx 160rpx;
padding: 80rpx;
margin-top: 60rpx;
&-item {
width: calc(50% - 80rpx);
display: flex;
align-items: center;
color: #6c6c70;
font-size: 30rpx;
height: 80rpx;
box-sizing: border-box;
.label {
position: relative;
margin-left: auto;
flex-shrink: 0;
width: 124rpx;
margin-right: 30rpx;
}
.required {
&::before {
content: '*';
color: #ff0000;
position: absolute;
left: -20rpx;
top: 50%;
transform: translate(0, -50%);
}
}
.value {
height: 80rpx;
flex: 1;
border: 2rpx solid #e8e8ea;
background: #ffffff;
margin-left: 32rpx;
box-sizing: border-box;
padding: 0 40rpx;
border-radius: 8rpx;
&.error {
border: 2rpx solid #f24724;
border-radius: 8rpx;
}
.input,
.select {
width: 100%;
height: 100%;
border: none !important;
outline: none;
padding: 0 !important;
font-size: 30rpx;
color: #333;
&::placeholder {
color: #c9c9c9;
}
}
.placeholderStyle {
color: #999999;
}
.arrow {
color: #999 !important;
margin-left: auto;
flex-shrink: 0;
}
}
}
// .active {
// &::after {
// position: absolute;
// left: -2rpx;
// top: -2rpx;
// width: calc(100% + 4rpx);
// height: calc(100% + 4rpx);
// content: '';
// background-image: linear-gradient(#2f6af7, #75bcff);
// box-shadow: 0 0 0 8rpx #2c66f71a;
// border-radius: 16rpx;
// }
// }
}
.footer-box {
display: flex;
align-items: center;
justify-content: center;
gap: 34rpx;
padding: 0 280rpx;
.cancel-btn {
height: 80rpx;
background: #dae9ff;
border-radius: 48rpx;
line-height: 80rpx;
text-align: center;
color: #2c66f7;
flex: 1;
}
.submit-btn {
height: 80rpx;
background-image: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
border-radius: 48rpx;
line-height: 80rpx;
text-align: center;
flex: 1;
color: #ffffff;
}
}
}
.select-box {
margin: 40rpx 0;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
overflow-y: scroll;
max-height: 50vh;
padding-bottom: 60rpx;
.select-item {
text-align: center;
height: 68rpx;
line-height: 68rpx;
opacity: 1;
border: 2rpx solid #dce0e6;
color: #292d33;
font-size: 28rpx;
border-radius: 8rpx;
&.checked {
border: 2rpx solid #292d33;
}
}
}
</style>
<template> <template>
<view <view class="container" @click="handleTouchStart">
class="container"
@click="handleTouchStart"
>
<view :class="['home', { show: !id }]"> <view :class="['home', { show: !id }]">
<left-side <left-side :userInfo="userInfo" :tabIndex.sync="tabIndex" @changeTab="$emit('changeTab', $event)" @stopAudio="stopAudio" />
:userInfo="userInfo"
:tabIndex.sync="tabIndex"
@changeTab="$emit('changeTab', $event)"
@stopAudio="stopAudio"
/>
<view class="right-side"> <view class="right-side">
<template v-if="tabIndex == 0"> <template v-if="tabIndex == 0">
<view class="right-content"> <view class="right-content">
<view <view class="start" @click="$emit('start')">
class="start" <image class="start-btn" src="../../assets/images/home/start.gif" alt="开始接待" />
@click="$emit('start')" <image class="start-border" src="../../assets/images/home/start-border.png" />
>
<image
class="start-btn"
src="../../assets/images/home/start.gif"
alt="开始接待"
/>
<image
class="start-border"
src="../../assets/images/home/start-border.png"
/>
</view> </view>
<view class="module-list"> <view class="module-list">
<slot name="module" /> <slot name="module" />
...@@ -33,10 +15,7 @@ ...@@ -33,10 +15,7 @@
</view> </view>
</template> </template>
<template v-else> <template v-else>
<component <component :is="componentName" :userInfo="userInfo" />
:is="componentName"
:userInfo="userInfo"
/>
</template> </template>
<view class="store-addr"> <view class="store-addr">
<view class="icon-addr sprite-icon icon-addr"></view> <view class="icon-addr sprite-icon icon-addr"></view>
...@@ -48,67 +27,39 @@ ...@@ -48,67 +27,39 @@
<slot name="detail" /> <slot name="detail" />
</view> </view>
<!-- 未点击开始接待,弹窗 --> <!-- 未点击开始接待,弹窗 -->
<MessageBox <MessageBox ref="previewRef" @confirm="$emit('preview')" :popupW="704" content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」" confirmBtnText="预览素材" @cancel="$emit('previewCancel')" @close="$emit('previewClose')"></MessageBox>
ref="previewRef"
@confirm="$emit('preview')"
:popupW="704"
content="直接点击素材可进行预览,若面向车主展示,请点击「开始接待」"
confirmBtnText="预览素材"
@cancel="$emit('previewCancel')"
@close="$emit('previewClose')"
></MessageBox>
<!-- 停留弹框 --> <!-- 停留弹框 -->
<MessageBox <MessageBox ref="tipBox" @cancel="tipCancel" @confirm="tipConfirm" content="系统检测到您在当前页面停留较久,是否仍在客户接待中?" cancelBtnText="否" confirmBtnText="是"></MessageBox>
ref="tipBox"
@cancel="tipCancel"
@confirm="tipConfirm"
content="系统检测到您在当前页面停留较久,是否仍在客户接待中?"
cancelBtnText="否"
confirmBtnText="是"
></MessageBox>
<!-- 退出弹框 --> <!-- 退出弹框 -->
<MessageBox <MessageBox :popupW="704" ref="finish" :content="finishContene" :isFooter="false">
:popupW="704"
ref="finish"
:content="finishContene"
:isFooter="false"
>
<view class="footer"> <view class="footer">
<view <view class="footer-btn confirm flex" @click="$emit('openStep')">
class="footer-btn confirm flex"
@click="$emit('openStep')"
>
<template v-if="finishDoneText"> <template v-if="finishDoneText">
{{ finishDoneText }} {{ finishDoneText }}
</template> </template>
<template v-else> 完成接待<text>(推荐)</text> </template> <template v-else>
完成接待
<text>(推荐)</text>
</template>
</view> </view>
<view <view class="footer-btn cancel flex" @click="$emit('backHome')">
class="footer-btn cancel flex" 仍要退出
@click="$emit('backHome')" <text>(不推荐)</text>
>
仍要退出<text>(不推荐)</text>
</view> </view>
</view> </view>
</MessageBox> </MessageBox>
<!-- 升级弹框 --> <!-- 升级弹框 -->
<update-box /> <update-box />
<slot name="content" /> <slot name="content" />
<web-view <web-view @message="handlerMessage" ref="webview" src="/hybrid/html/index.html"></web-view>
@message="handlerMessage"
ref="webview"
src="/hybrid/html/index.html"
></web-view>
</view> </view>
</template> </template>
<script> <script>
import RecordList from './components/RecordList.vue'
import RecordList from "./components/RecordList.vue"; import myClick from '@/mixin/click'
import myClick from "@/mixin/click"; import uploader from '@/mixin/uploader.js'
import uploader from "@/mixin/uploader.js"; import CustomerFile from './components/CustomerFile.vue'
import CustomerFile from './components/CustomerFile.vue'; import LeftSide from './components/LeftSide.vue'
import LeftSide from './components/LeftSide.vue';
export default { export default {
mixins: [myClick, uploader], mixins: [myClick, uploader],
components: { RecordList, CustomerFile, LeftSide }, components: { RecordList, CustomerFile, LeftSide },
...@@ -117,35 +68,34 @@ export default { ...@@ -117,35 +68,34 @@ export default {
finishDoneText: String, finishDoneText: String,
finishContene: { finishContene: {
type: String, type: String,
default: "当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」", default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}, }
}, },
data () { data() {
return { return {
userInfo: {}, userInfo: {},
tabIndex: 0 tabIndex: 0
}; }
}, },
mounted () { mounted() {
const userInfo = uni.$storage.get("userInfo") || {}; const userInfo = uni.$storage.get('userInfo') || {}
this.userInfo = userInfo; this.userInfo = userInfo
}, },
computed: { computed: {
previewRef () { previewRef() {
return this.$refs.previewRef; return this.$refs.previewRef
}, },
finishRef () { finishRef() {
return this.$refs.finish; return this.$refs.finish
}, },
componentName () { componentName() {
if (this.tabIndex == 0) return 'HomeSlot' if (this.tabIndex == 0) return 'HomeSlot'
else if (this.tabIndex == 1) return 'RecordList' else if (this.tabIndex == 1) return 'RecordList'
else return 'CustomerFile' else return 'CustomerFile'
}
}, },
}, methods: {}
methods: { }
},
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.container { .container {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48 * @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-08-30 17:49:04 * @LastEditTime: 2024-10-17 11:02:23
* @FilePath: \gl_tape\mixin\click.js * @FilePath: \gl_tape\mixin\click.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
*/ */
const recorderManager = uni.getRecorderManager() const recorderManager = uni.getRecorderManager()
const plug = uni.requireNativePlugin('html5app-recordaudio') const plug = uni.requireNativePlugin('html5app-recordaudio')
import interruptRecord from '@/utils/recordManager/interruptRecord'
const UPLOAD_STATUS = { const UPLOAD_STATUS = {
// 上传状态 // 上传状态
success: 1, success: 1,
...@@ -16,7 +17,7 @@ const UPLOAD_STATUS = { ...@@ -16,7 +17,7 @@ const UPLOAD_STATUS = {
import { mapMutations, mapState } from 'vuex' import { mapMutations, mapState } from 'vuex'
import utils from '@/utils/utils.js' import utils from '@/utils/utils.js'
export default { export default {
data () { data() {
return { return {
voicePath: '', voicePath: '',
timer: null, timer: null,
...@@ -25,7 +26,8 @@ export default { ...@@ -25,7 +26,8 @@ export default {
reaction: 1 reaction: 1
} }
}, },
mounted () { mounted() {
this.handleSave(false)
// 获取当前页面栈数组 // 获取当前页面栈数组
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
...@@ -34,27 +36,23 @@ export default { ...@@ -34,27 +36,23 @@ export default {
if (url.includes(route)) return if (url.includes(route)) return
this.initTime() this.initTime()
}, },
watch: {
'$store.state.user.customerInfo'(val) {
const params = this.getParams(val)
interruptRecord.updatePreRecords(params)
}
},
computed: { computed: {
...mapState('audio', ['receptionStatus', 'booksList', 'audioInfo']), ...mapState('audio', ['receptionStatus', 'booksList', 'audioInfo']),
...mapState(['user.customerInfo']) ...mapState(['user.customerInfo'])
}, },
created () { created() {
console.log('created') console.log('created')
}, },
onHide () {
console.log('隐藏')
// recorderManager.stop();
// recorderManager.start({
// duration: 10000,
// });
},
onShow () {
// console.log(utils.requestAndroidPermission());
},
methods: { methods: {
...mapMutations('audio', ['setReceptionStatus', 'setBooks', 'setAudioInfo']), ...mapMutations('audio', ['setReceptionStatus', 'setBooks', 'setAudioInfo']),
// //关闭提示 // //关闭提示
tipCancel () { tipCancel() {
this.stopAudio() this.stopAudio()
this.setReceptionStatus(0) this.setReceptionStatus(0)
this.setAudioInfo({ endReasonType: 1 }) this.setAudioInfo({ endReasonType: 1 })
...@@ -67,11 +65,11 @@ export default { ...@@ -67,11 +65,11 @@ export default {
} }
}, },
//结束提示 //结束提示
tipConfirm () { tipConfirm() {
this.times = 0 this.times = 0
this.$refs.tipBox?.close() this.$refs.tipBox?.close()
}, },
closeAudio () { closeAudio() {
this.times = 0 this.times = 0
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null this.timer = null
...@@ -79,9 +77,9 @@ export default { ...@@ -79,9 +77,9 @@ export default {
this.setReceptionStatus(0) this.setReceptionStatus(0)
this.setAudioInfo({ endReasonType: 1 }) this.setAudioInfo({ endReasonType: 1 })
}, },
getParams () { getParams(val) {
const { shopMerchantId, phone, sceneType, uuid, name, merchantId, channelType, merchantName } = uni.$storage.get('userInfo'), const { shopMerchantId, phone, sceneType, uuid, name, merchantId, channelType, merchantName } = uni.$storage.get('userInfo'),
{ customerName, phoneNumber, salesUuid, carModel, staffName } = this.$store.state.user.customerInfo, { customerName, phoneNumber, salesUuid, carModel, staffName } = val || {},
receptionCustomerPaySourceList = this.booksList.map(item => { receptionCustomerPaySourceList = this.booksList.map(item => {
return { return {
id: item.id, id: item.id,
...@@ -99,7 +97,7 @@ export default { ...@@ -99,7 +97,7 @@ export default {
merchantId: shopMerchantId, merchantId: shopMerchantId,
businessScene: sceneType, businessScene: sceneType,
staffUuid: uuid, staffUuid: uuid,
staffName: name, staffName: name
}) })
}) })
let params = { let params = {
...@@ -131,7 +129,7 @@ export default { ...@@ -131,7 +129,7 @@ export default {
* @param {旧的文件路径} oldFilePath * @param {旧的文件路径} oldFilePath
* @param {新的文件名} newFileName * @param {新的文件名} newFileName
*/ */
RenameFile (oldFilePath, newFileName) { RenameFile(oldFilePath, newFileName) {
plus.io.resolveLocalFileSystemURL(oldFilePath, entry => { plus.io.resolveLocalFileSystemURL(oldFilePath, entry => {
entry.getParent(_oldFile => { entry.getParent(_oldFile => {
entry.moveTo(_oldFile, '/' + newFileName, newFilePath => { entry.moveTo(_oldFile, '/' + newFileName, newFilePath => {
...@@ -149,13 +147,15 @@ export default { ...@@ -149,13 +147,15 @@ export default {
this.$store.dispatch('clearCustomerInfo') this.$store.dispatch('clearCustomerInfo')
this.setReceptionStatus(1) this.setReceptionStatus(1)
this.initTime() this.initTime()
recorderManager.onStart(() => {
interruptRecord.addPreRecords()
})
recorderManager.start({ recorderManager.start({
duration: 600000, duration: 600000,
sampleRate: 16000, sampleRate: 16000,
numberOfChannels: 1 numberOfChannels: 1
}) })
recorderManager.onStop(async res => { recorderManager.onStop(async res => {
console.log('结束录音')
if (this.audioInfo.audioStatus == 'start') { if (this.audioInfo.audioStatus == 'start') {
uni.getRecorderManager().start({ uni.getRecorderManager().start({
duration: 600000, duration: 600000,
...@@ -163,63 +163,49 @@ export default { ...@@ -163,63 +163,49 @@ export default {
numberOfChannels: 1 numberOfChannels: 1
}) })
} }
if (this.audioInfo.audioStatus == 'no') {
uni.removeSavedFile({
filePath: res.tempFilePath,
complete: function (res) {
console.log(res)
}
}) })
return }, 300),
async handleSave(isNormal = true) {
const records = interruptRecord.getPreRecord()
console.log(records, 'records')
if (!records) return
if (isNormal) {
Object.assign(records, this.getParams(this.$store.state.user.customerInfo))
} }
const audioPath = records.audioPath
const recordUrlList = []
for (let i = 0; i < audioPath.length; i++) {
const saveResult = await uni.saveFile({ const saveResult = await uni.saveFile({
tempFilePath: res.tempFilePath tempFilePath: audioPath[i]
}) // 保存文件到本地
//删除默认文件
uni.removeSavedFile({
filePath: res.tempFilePath,
complete: function (res) {
console.log(res)
}
}) })
const oldFilePath = saveResult[1].savedFilePath const oldFilePath = saveResult[1].savedFilePath
console.log(oldFilePath, 'oldFilePath')
const { phone } = uni.$storage.get('userInfo') const { phone } = uni.$storage.get('userInfo')
const newFileName = String(phone).slice(-4) + '_' + oldFilePath.replace(/.+\/(\d+\.mp3)/, '$1') const newFileName = String(phone).slice(-4) + '_' + oldFilePath.replace(/.+\/(\d+\.mp3)/, '$1')
const newFilePath = oldFilePath.replace(/(.+\/)(\d+\.mp3)/, '') + newFileName const newFilePath = oldFilePath.replace(/(.+\/)(\d+\.mp3)/, '') + newFileName
const path = await utils.getFileSaveFolderOnClient()
recordUrlList.push({ status: UPLOAD_STATUS.fail, file: path + newFilePath })
this.RenameFile(oldFilePath, newFileName) this.RenameFile(oldFilePath, newFileName)
this.handleSave(newFilePath)
})
}, 300),
handleSave (file) {
const audioList = [...this.audioInfo.audioList, file]
if (file) {
this.setAudioInfo({ audioList })
} }
if (this.audioInfo.audioStatus != 'end' && this.audioInfo.audioStatus != 'finish') { delete records.audioPath
return let saveRecords = Object.assign(records, { recordUrlList })
console.log(isNormal, 'isNormal')
if (isNormal) {
this.saveRecord(saveRecords)
} else {
interruptRecord.updatePreRecords(saveRecords, true)
} }
this.saveRecord() },
this.setAudioInfo({ endReasonType: 0, audioStatus: 'finish' }) removeRecords() {
const records = interruptRecord.getPreRecord()
interruptRecord.removePreRecord(record.id)
}, },
/**保存记录*/ /**保存记录*/
async saveRecord () { async saveRecord(record) {
const params = this.getParams()
const unlock = await uni.$recordManager.lock() const unlock = await uni.$recordManager.lock()
const path = await utils.getFileSaveFolderOnClient() console.log('record', record)
const recordUrlList = this.audioInfo.audioList.map(i => { uni.$recordManager.addRecord(record)
return { interruptRecord.removePreRecord(record.id)
status: UPLOAD_STATUS.fail,
file: path + i.split('/').pop()
}
})
if (recordUrlList.length) {
this.$store.dispatch('clearCustomerInfo')
}
uni.$recordManager.addRecord({
...params,
id: utils.uuid(),
recordUrlList
})
unlock() unlock()
}, },
//结束接待 //结束接待
...@@ -264,11 +250,12 @@ export default { ...@@ -264,11 +250,12 @@ export default {
this.timer = null this.timer = null
if (status) { if (status) {
this.setAudioInfo({ audioStatus: 'no' }) this.setAudioInfo({ audioStatus: 'no' })
this.removeRecords()
} }
recorderManager.stop() recorderManager.stop()
}, 1500), }, 1500),
//监听点击事件 //监听点击事件
initTime () { initTime() {
if (this.audioInfo.audioStatus != 'start') return if (this.audioInfo.audioStatus != 'start') return
this.timer = setInterval(() => { this.timer = setInterval(() => {
// console.log(this.times); // console.log(this.times);
...@@ -280,11 +267,11 @@ export default { ...@@ -280,11 +267,11 @@ export default {
} }
}, 1000 * 10) }, 1000 * 10)
}, },
handleTouchStart () { handleTouchStart() {
this.times = 0 this.times = 0
} }
}, },
beforeCreate () { beforeCreate() {
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null this.timer = null
} }
......
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/' // export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
// import util from '~/utils/util' // import util from '~/utils/util'
export const IMG_URL = "https://img02.glsx.com.cn/weapp/resource/app-tape/"; export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/app-tape/'
// 缓存get方法为空的默认指定值 // 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ["sessionId", "merchantId", "userInfo"]; export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
// 缓存get方法key的对应才映射值 // 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = { export const STORAGE_OBJECTkEY = {
DEFAULT_GET_STORAGEKEY, DEFAULT_GET_STORAGEKEY,
mock_data: "mock_data", mock_data: 'mock_data',
storageFile: "storageFile", storageFile: 'storageFile',
userInfo: "userInfo", userInfo: 'userInfo',
customerInfo: "customerInfo", customerInfo: 'customerInfo',
noSignInUuid: "noSignInUuid", noSignInUuid: 'noSignInUuid',
noviceGuideStatus: "noviceGuideStatus", noviceGuideStatus: 'noviceGuideStatus',
carBrandList: "carBrandList", carBrandList: 'carBrandList',
employeeList: "employeeList", employeeList: 'employeeList',
recordList: "recordList", recordList: 'recordList',
recordSuccessList: "recordSuccessList", preRecordList: 'preRecordList',
historyList: "historyList", preRecordId: 'preRecordId',
storageVersion: "storageVersion", recordSuccessList: 'recordSuccessList',
byd_mock_data:'byd_mock_data', historyList: 'historyList',
boutique_mock_data:'boutique_mock_data' storageVersion: 'storageVersion',
}; byd_mock_data: 'byd_mock_data',
boutique_mock_data: 'boutique_mock_data'
}
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-16 09:55:40
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-16 13:51:15
* @FilePath: \gl-tape\utils\cache\storageApi.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { STORAGE_OBJECTkEY } from './constantData' import { STORAGE_OBJECTkEY } from './constantData'
// console.log(storage) // console.log(storage)
/** */ /** */
...@@ -59,16 +67,16 @@ export function setSystem_info(that) { ...@@ -59,16 +67,16 @@ export function setSystem_info(that) {
}) })
} }
export function getRecords() { export function getRecords(record = 'recordList') {
return storage.get(STORAGE_OBJECTkEY.recordList) return storage.get(STORAGE_OBJECTkEY[record])
} }
export function setRecords(data) { export function setRecords(data, record = 'recordList') {
storage.set(STORAGE_OBJECTkEY.recordList, data) storage.set(STORAGE_OBJECTkEY[record], data)
} }
export function removeRecords() { export function removeRecords(record = 'recordList') {
storage.rm(STORAGE_OBJECTkEY.recordList) storage.rm(STORAGE_OBJECTkEY[record])
} }
export default{ export default {
getSessionId, getSessionId,
setSessionId, setSessionId,
getUserInfo, getUserInfo,
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-10-14 17:38:35
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-10-17 10:47:17
* @FilePath: \gl-tape\utils\recordManager\interruptRecord.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import RecordManager from '../RecordManager.js'
import utils from '@/utils/utils.js'
import { storageApi } from '../cache'
class InterruptRecord extends RecordManager {
constructor() {
super()
// storageApi.removeRecords('preRecordList')
// storageApi.removeRecords('preRecordId')
}
records = {}
pathName = null
/**
* 获取记录列表
*
* @returns {Array} - 从 storageApi 获取的记录列表
*/
getRecords() {
console.log(storageApi.getRecords('preRecordList'), 'ddd')
return storageApi.getRecords('preRecordList')
}
/**
* 获取待提交的记录id
*
*/
getPreRecord() {
const id = storageApi.getRecords('preRecordId')
return this.getRecordById(id)
}
/**
* 删除待提交的记录
*
*/
removePreRecord(id) {
this.removeRecord(id)
storageApi.setRecords('', 'preRecordId')
}
/**
* 初始化保存记录
*
* @param {string} name - 录音文件目录名
* @returns {void} - 此函数不返回任何值
*/
async addPreRecords() {
if (storageApi.getRecords('preRecordId')) {
this.addPreAudio()
return
}
this.pathName = await this.getAudioPathName()
const audioPath = await this.getAudioPath(this.pathName)
const id = utils.uuid()
storageApi.setRecords(id, 'preRecordId')
const ids = storageApi.getRecords('preRecordId')
console.log(ids, 'id')
this.records = {
id,
audioPath: [audioPath]
}
const records = this.getRecords() || []
records.push(this.records)
this.setRecords(records)
}
/**
* 添加录音文件
*
* @returns {void} - 此函数不返回任何值
*/
async addPreAudio() {
const audioPath = await this.getAudioPath(this.pathName)
this.records.audioPath.push(audioPath)
this.updateRecord(this.records)
}
updatePreAudio(params) {
this.updateRecord(params)
}
/**
* 更新参数
*
* @returns {void} - 此函数不返回任何值
*/
updatePreRecords(params, isRemoveId) {
if (isRemoveId) {
storageApi.setRecords('', 'preRecordId')
}
const updateParams = { ...this.records, ...params }
this.updateRecord(updateParams)
}
/**
* 获取录音文件全路径
*
* @param {string} name - 录音文件目录名
* @returns {void} - 此函数不返回任何值
*/
async getAudioPath(name) {
return new Promise(async (resolve, reject) => {
const path = await utils.getAudioFilePath(name + '/recorder')
plus.io.resolveLocalFileSystemURL(
path,
e => {
var dirR = e.createReader()
dirR.readEntries(
function (er) {
Promise.all(
er.map((item, index) => {
return new Promise(resolve => {
item.getMetadata(metadata => {
resolve({
index: index,
name: item.name,
modificationTime: new Date(metadata.modificationTime).getTime()
})
})
})
})
).then(results => {
// 找到修改时间最晚的文件
const latest = results.reduce(
(acc, current) => {
if (current.modificationTime > acc.modificationTime) {
return current
}
return acc
},
{ modificationTime: 0 }
)
// 修改时间最晚的文件名
resolve(path + '/' + latest.name)
})
},
err => {
reject(err)
}
)
},
err => {}
)
})
}
/**
* 获取录音文件名
*
* @returns {void} - 此函数不返回任何值
*/
async getAudioPathName() {
return new Promise(async (resolve, reject) => {
const path = await utils.getAudioFilePath()
plus.io.resolveLocalFileSystemURL(
path,
e => {
var dirR = e.createReader()
dirR.readEntries(
function (er) {
for (var i = 0; i < er.length; i++) {
if (er[i].name.startsWith('uniapp_temp')) {
resolve(er[i].name)
}
// er[i].getMetadata(function (metadata) {
// console.log(metadata.modificationTime, '修改时间')
// })
}
},
err => {
console.log(err)
}
)
},
err => {}
)
})
}
/**
* 设置记录列表
*
* @param {Array} records - 要设置的记录列表
* @returns {void} - 此函数不返回任何值
*/
setRecords(records) {
storageApi.setRecords(records, 'preRecordList')
console.log(storageApi.getRecords('preRecordList'))
}
}
export default new InterruptRecord()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!