Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a7218268
authored
Oct 17, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
保存记录
1 parent
526dcf0f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
675 additions
and
183 deletions
.hbuilderx/launch.json
components/HomeFrame/components/RecordList.vue
components/HomeFrame/components/saveRecord.vue
components/HomeFrame/index.vue
mixin/click.js
utils/cache/constantData.js
utils/cache/storageApi.js
utils/recordManager/interruptRecord.js
.hbuilderx/launch.json
View file @
a721826
...
...
@@ -11,7 +11,7 @@
"launchtype"
:
"local"
},
"h5"
:
{
"launchtype"
:
"
local
"
"launchtype"
:
"
remote
"
},
"mp-weixin"
:
{
"launchtype"
:
"local"
...
...
components/HomeFrame/components/RecordList.vue
View file @
a721826
This diff is collapsed.
Click to expand it.
components/HomeFrame/components/saveRecord.vue
0 → 100644
View file @
a721826
<
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
:
48
rpx
;
margin
:
80
rpx
66
rpx
80
rpx
0
;
height
:
calc
(
100%
-
160
rpx
);
box-shadow
:
inset
0
0
16
rpx
0
#ffffff
;
border
:
2
rpx
solid
#fff
;
box-sizing
:
border-box
;
position
:
relative
;
.nav-bar
{
position
:
absolute
;
width
:
100%
;
height
:
96
rpx
;
left
:
0
;
top
:
28
rpx
;
z-index
:
9
;
text-align
:
center
;
font-weight
:
700
;
font-size
:
32
rpx
;
color
:
#1a1a1a
;
line-height
:
96
rpx
;
.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
:
80
rpx
160
rpx
;
padding
:
80
rpx
;
margin-top
:
60
rpx
;
&-item
{
width
:
calc
(
50%
-
80
rpx
);
display
:
flex
;
align-items
:
center
;
color
:
#6c6c70
;
font-size
:
30
rpx
;
height
:
80
rpx
;
box-sizing
:
border-box
;
.label
{
position
:
relative
;
margin-left
:
auto
;
flex-shrink
:
0
;
width
:
124
rpx
;
margin-right
:
30
rpx
;
}
.required
{
&::before
{
content
:
'*'
;
color
:
#ff0000
;
position
:
absolute
;
left
:
-20
rpx
;
top
:
50%
;
transform
:
translate
(
0
,
-50%
);
}
}
.value
{
height
:
80
rpx
;
flex
:
1
;
border
:
2
rpx
solid
#e8e8ea
;
background
:
#ffffff
;
margin-left
:
32
rpx
;
box-sizing
:
border-box
;
padding
:
0
40
rpx
;
border-radius
:
8
rpx
;
&.error
{
border
:
2
rpx
solid
#f24724
;
border-radius
:
8
rpx
;
}
.input
,
.select
{
width
:
100%
;
height
:
100%
;
border
:
none
!important
;
outline
:
none
;
padding
:
0
!important
;
font-size
:
30
rpx
;
color
:
#333
;
&::placeholder
{
color
:
#c9c9c9
;
}
}
.placeholderStyle
{
color
:
#999999
;
}
.arrow
{
color
:
#999
!important
;
margin-left
:
auto
;
flex-shrink
:
0
;
}
}
}
//
.active
{
//
&::after
{
//
position
:
absolute
;
//
left
:
-2
rpx
;
//
top
:
-2
rpx
;
//
width
:
calc
(
100%
+
4
rpx
);
//
height
:
calc
(
100%
+
4
rpx
);
//
content
:
''
;
//
background-image
:
linear-gradient
(
#2f6af7
,
#75bcff
);
//
box-shadow
:
0
0
0
8
rpx
#2c66f71
a
;
//
border-radius
:
16
rpx
;
//
}
//
}
}
.footer-box
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
34
rpx
;
padding
:
0
280
rpx
;
.cancel-btn
{
height
:
80
rpx
;
background
:
#dae9ff
;
border-radius
:
48
rpx
;
line-height
:
80
rpx
;
text-align
:
center
;
color
:
#2c66f7
;
flex
:
1
;
}
.submit-btn
{
height
:
80
rpx
;
background-image
:
linear-gradient
(
0deg
,
#2c66f7
0%
,
#48a6ff
100%
);
border-radius
:
48
rpx
;
line-height
:
80
rpx
;
text-align
:
center
;
flex
:
1
;
color
:
#ffffff
;
}
}
}
.select-box
{
margin
:
40
rpx
0
;
display
:
grid
;
grid-template-columns
:
repeat
(
3
,
1
fr
);
gap
:
20
rpx
;
overflow-y
:
scroll
;
max-height
:
50vh
;
padding-bottom
:
60
rpx
;
.select-item
{
text-align
:
center
;
height
:
68
rpx
;
line-height
:
68
rpx
;
opacity
:
1
;
border
:
2
rpx
solid
#dce0e6
;
color
:
#292d33
;
font-size
:
28
rpx
;
border-radius
:
8
rpx
;
&.checked
{
border
:
2
rpx
solid
#292d33
;
}
}
}
</
style
>
components/HomeFrame/index.vue
View file @
a721826
<
template
>
<view
class=
"container"
@
click=
"handleTouchStart"
>
<view
class=
"container"
@
click=
"handleTouchStart"
>
<view
:class=
"['home',
{ show: !id }]">
<left-side
:userInfo=
"userInfo"
:tabIndex
.
sync=
"tabIndex"
@
changeTab=
"$emit('changeTab', $event)"
@
stopAudio=
"stopAudio"
/>
<left-side
:userInfo=
"userInfo"
:tabIndex
.
sync=
"tabIndex"
@
changeTab=
"$emit('changeTab', $event)"
@
stopAudio=
"stopAudio"
/>
<view
class=
"right-side"
>
<template
v-if=
"tabIndex == 0"
>
<view
class=
"right-content"
>
<view
class=
"start"
@
click=
"$emit('start')"
>
<image
class=
"start-btn"
src=
"../../assets/images/home/start.gif"
alt=
"开始接待"
/>
<image
class=
"start-border"
src=
"../../assets/images/home/start-border.png"
/>
<view
class=
"start"
@
click=
"$emit('start')"
>
<image
class=
"start-btn"
src=
"../../assets/images/home/start.gif"
alt=
"开始接待"
/>
<image
class=
"start-border"
src=
"../../assets/images/home/start-border.png"
/>
</view>
<view
class=
"module-list"
>
<slot
name=
"module"
/>
...
...
@@ -33,10 +15,7 @@
</view>
</
template
>
<
template
v-else
>
<component
:is=
"componentName"
:userInfo=
"userInfo"
/>
<component
:is=
"componentName"
:userInfo=
"userInfo"
/>
</
template
>
<view
class=
"store-addr"
>
<view
class=
"icon-addr sprite-icon icon-addr"
></view>
...
...
@@ -48,67 +27,39 @@
<slot
name=
"detail"
/>
</view>
<!-- 未点击开始接待,弹窗 -->
<MessageBox
ref=
"previewRef"
@
confirm=
"$emit('preview')"
:popupW=
"704"
content=
"直接点击素材可进行预览,若面向车主展示,请点击「开始接待」"
confirmBtnText=
"预览素材"
@
cancel=
"$emit('previewCancel')"
@
close=
"$emit('previewClose')"
></MessageBox>
<MessageBox
ref=
"previewRef"
@
confirm=
"$emit('preview')"
:popupW=
"704"
content=
"直接点击素材可进行预览,若面向车主展示,请点击「开始接待」"
confirmBtnText=
"预览素材"
@
cancel=
"$emit('previewCancel')"
@
close=
"$emit('previewClose')"
></MessageBox>
<!-- 停留弹框 -->
<MessageBox
ref=
"tipBox"
@
cancel=
"tipCancel"
@
confirm=
"tipConfirm"
content=
"系统检测到您在当前页面停留较久,是否仍在客户接待中?"
cancelBtnText=
"否"
confirmBtnText=
"是"
></MessageBox>
<MessageBox
ref=
"tipBox"
@
cancel=
"tipCancel"
@
confirm=
"tipConfirm"
content=
"系统检测到您在当前页面停留较久,是否仍在客户接待中?"
cancelBtnText=
"否"
confirmBtnText=
"是"
></MessageBox>
<!-- 退出弹框 -->
<MessageBox
:popupW=
"704"
ref=
"finish"
:content=
"finishContene"
:isFooter=
"false"
>
<MessageBox
:popupW=
"704"
ref=
"finish"
:content=
"finishContene"
:isFooter=
"false"
>
<view
class=
"footer"
>
<view
class=
"footer-btn confirm flex"
@
click=
"$emit('openStep')"
>
<view
class=
"footer-btn confirm flex"
@
click=
"$emit('openStep')"
>
<
template
v-if=
"finishDoneText"
>
{{
finishDoneText
}}
</
template
>
<
template
v-else
>
完成接待
<text>
(推荐)
</text>
</
template
>
<
template
v-else
>
完成接待
<text>
(推荐)
</text>
</
template
>
</view>
<view
class=
"footer-btn cancel flex"
@
click=
"$emit('backHome')"
>
仍要退出
<text>
(不推荐)
</text>
<view
class=
"footer-btn cancel flex"
@
click=
"$emit('backHome')"
>
仍要退出
<text>
(不推荐)
</text>
</view>
</view>
</MessageBox>
<!-- 升级弹框 -->
<update-box
/>
<slot
name=
"content"
/>
<web-view
@
message=
"handlerMessage"
ref=
"webview"
src=
"/hybrid/html/index.html"
></web-view>
<web-view
@
message=
"handlerMessage"
ref=
"webview"
src=
"/hybrid/html/index.html"
></web-view>
</view>
</template>
<
script
>
import
RecordList
from
"./components/RecordList.vue"
;
import
myClick
from
"@/mixin/click"
;
import
uploader
from
"@/mixin/uploader.js"
;
import
CustomerFile
from
'./components/CustomerFile.vue'
;
import
LeftSide
from
'./components/LeftSide.vue'
;
import
RecordList
from
'./components/RecordList.vue'
import
myClick
from
'@/mixin/click'
import
uploader
from
'@/mixin/uploader.js'
import
CustomerFile
from
'./components/CustomerFile.vue'
import
LeftSide
from
'./components/LeftSide.vue'
export
default
{
mixins
:
[
myClick
,
uploader
],
components
:
{
RecordList
,
CustomerFile
,
LeftSide
},
...
...
@@ -117,35 +68,34 @@ export default {
finishDoneText
:
String
,
finishContene
:
{
type
:
String
,
default
:
"当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」"
,
}
,
default
:
'当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}
},
data
()
{
data
()
{
return
{
userInfo
:
{},
tabIndex
:
0
}
;
}
},
mounted
()
{
const
userInfo
=
uni
.
$storage
.
get
(
"userInfo"
)
||
{};
this
.
userInfo
=
userInfo
;
mounted
()
{
const
userInfo
=
uni
.
$storage
.
get
(
'userInfo'
)
||
{}
this
.
userInfo
=
userInfo
},
computed
:
{
previewRef
()
{
return
this
.
$refs
.
previewRef
;
previewRef
()
{
return
this
.
$refs
.
previewRef
},
finishRef
()
{
return
this
.
$refs
.
finish
;
finishRef
()
{
return
this
.
$refs
.
finish
},
componentName
()
{
componentName
()
{
if
(
this
.
tabIndex
==
0
)
return
'HomeSlot'
else
if
(
this
.
tabIndex
==
1
)
return
'RecordList'
else
return
'CustomerFile'
},
},
methods
:
{
}
},
};
methods
:
{}
}
</
script
>
<
style
scoped
lang=
"scss"
>
.container
{
...
...
mixin/click.js
View file @
a721826
...
...
@@ -2,12 +2,13 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @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
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const
recorderManager
=
uni
.
getRecorderManager
()
const
plug
=
uni
.
requireNativePlugin
(
'html5app-recordaudio'
)
import
interruptRecord
from
'@/utils/recordManager/interruptRecord'
const
UPLOAD_STATUS
=
{
// 上传状态
success
:
1
,
...
...
@@ -16,7 +17,7 @@ const UPLOAD_STATUS = {
import
{
mapMutations
,
mapState
}
from
'vuex'
import
utils
from
'@/utils/utils.js'
export
default
{
data
()
{
data
()
{
return
{
voicePath
:
''
,
timer
:
null
,
...
...
@@ -25,7 +26,8 @@ export default {
reaction
:
1
}
},
mounted
()
{
mounted
()
{
this
.
handleSave
(
false
)
// 获取当前页面栈数组
const
pages
=
getCurrentPages
()
const
currentPage
=
pages
[
pages
.
length
-
1
]
...
...
@@ -34,27 +36,23 @@ export default {
if
(
url
.
includes
(
route
))
return
this
.
initTime
()
},
watch
:
{
'$store.state.user.customerInfo'
(
val
)
{
const
params
=
this
.
getParams
(
val
)
interruptRecord
.
updatePreRecords
(
params
)
}
},
computed
:
{
...
mapState
(
'audio'
,
[
'receptionStatus'
,
'booksList'
,
'audioInfo'
]),
...
mapState
([
'user.customerInfo'
])
},
created
()
{
created
()
{
console
.
log
(
'created'
)
},
onHide
()
{
console
.
log
(
'隐藏'
)
// recorderManager.stop();
// recorderManager.start({
// duration: 10000,
// });
},
onShow
()
{
// console.log(utils.requestAndroidPermission());
},
methods
:
{
...
mapMutations
(
'audio'
,
[
'setReceptionStatus'
,
'setBooks'
,
'setAudioInfo'
]),
// //关闭提示
tipCancel
()
{
tipCancel
()
{
this
.
stopAudio
()
this
.
setReceptionStatus
(
0
)
this
.
setAudioInfo
({
endReasonType
:
1
})
...
...
@@ -67,11 +65,11 @@ export default {
}
},
//结束提示
tipConfirm
()
{
tipConfirm
()
{
this
.
times
=
0
this
.
$refs
.
tipBox
?.
close
()
},
closeAudio
()
{
closeAudio
()
{
this
.
times
=
0
clearInterval
(
this
.
timer
)
this
.
timer
=
null
...
...
@@ -79,9 +77,9 @@ export default {
this
.
setReceptionStatus
(
0
)
this
.
setAudioInfo
({
endReasonType
:
1
})
},
getParams
(
)
{
getParams
(
val
)
{
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
=>
{
return
{
id
:
item
.
id
,
...
...
@@ -99,7 +97,7 @@ export default {
merchantId
:
shopMerchantId
,
businessScene
:
sceneType
,
staffUuid
:
uuid
,
staffName
:
name
,
staffName
:
name
})
})
let
params
=
{
...
...
@@ -131,7 +129,7 @@ export default {
* @param {旧的文件路径} oldFilePath
* @param {新的文件名} newFileName
*/
RenameFile
(
oldFilePath
,
newFileName
)
{
RenameFile
(
oldFilePath
,
newFileName
)
{
plus
.
io
.
resolveLocalFileSystemURL
(
oldFilePath
,
entry
=>
{
entry
.
getParent
(
_oldFile
=>
{
entry
.
moveTo
(
_oldFile
,
'/'
+
newFileName
,
newFilePath
=>
{
...
...
@@ -149,13 +147,15 @@ export default {
this
.
$store
.
dispatch
(
'clearCustomerInfo'
)
this
.
setReceptionStatus
(
1
)
this
.
initTime
()
recorderManager
.
onStart
(()
=>
{
interruptRecord
.
addPreRecords
()
})
recorderManager
.
start
({
duration
:
600000
,
sampleRate
:
16000
,
numberOfChannels
:
1
})
recorderManager
.
onStop
(
async
res
=>
{
console
.
log
(
'结束录音'
)
if
(
this
.
audioInfo
.
audioStatus
==
'start'
)
{
uni
.
getRecorderManager
().
start
({
duration
:
600000
,
...
...
@@ -163,63 +163,49 @@ export default {
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
({
tempFilePath
:
res
.
tempFilePath
})
// 保存文件到本地
//删除默认文件
uni
.
removeSavedFile
({
filePath
:
res
.
tempFilePath
,
complete
:
function
(
res
)
{
console
.
log
(
res
)
}
tempFilePath
:
audioPath
[
i
]
})
const
oldFilePath
=
saveResult
[
1
].
savedFilePath
console
.
log
(
oldFilePath
,
'oldFilePath'
)
const
{
phone
}
=
uni
.
$storage
.
get
(
'userInfo'
)
const
newFileName
=
String
(
phone
).
slice
(
-
4
)
+
'_'
+
oldFilePath
.
replace
(
/.+
\/(\d
+
\.
mp3
)
/
,
'$1'
)
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
.
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'
)
{
return
delete
records
.
audioPath
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
()
{
const
params
=
this
.
getParams
()
async
saveRecord
(
record
)
{
const
unlock
=
await
uni
.
$recordManager
.
lock
()
const
path
=
await
utils
.
getFileSaveFolderOnClient
()
const
recordUrlList
=
this
.
audioInfo
.
audioList
.
map
(
i
=>
{
return
{
status
:
UPLOAD_STATUS
.
fail
,
file
:
path
+
i
.
split
(
'/'
).
pop
()
}
})
if
(
recordUrlList
.
length
)
{
this
.
$store
.
dispatch
(
'clearCustomerInfo'
)
}
uni
.
$recordManager
.
addRecord
({
...
params
,
id
:
utils
.
uuid
(),
recordUrlList
})
console
.
log
(
'record'
,
record
)
uni
.
$recordManager
.
addRecord
(
record
)
interruptRecord
.
removePreRecord
(
record
.
id
)
unlock
()
},
//结束接待
...
...
@@ -264,11 +250,12 @@ export default {
this
.
timer
=
null
if
(
status
)
{
this
.
setAudioInfo
({
audioStatus
:
'no'
})
this
.
removeRecords
()
}
recorderManager
.
stop
()
},
1500
),
//监听点击事件
initTime
()
{
initTime
()
{
if
(
this
.
audioInfo
.
audioStatus
!=
'start'
)
return
this
.
timer
=
setInterval
(()
=>
{
// console.log(this.times);
...
...
@@ -280,11 +267,11 @@ export default {
}
},
1000
*
10
)
},
handleTouchStart
()
{
handleTouchStart
()
{
this
.
times
=
0
}
},
beforeCreate
()
{
beforeCreate
()
{
clearInterval
(
this
.
timer
)
this
.
timer
=
null
}
...
...
utils/cache/constantData.js
View file @
a721826
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
// 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方法为空的默认指定值
export
const
DEFAULT_GET_STORAGEKEY
=
[
"sessionId"
,
"merchantId"
,
"userInfo"
];
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
// 缓存get方法key的对应才映射值
export
const
STORAGE_OBJECTkEY
=
{
DEFAULT_GET_STORAGEKEY
,
mock_data
:
"mock_data"
,
storageFile
:
"storageFile"
,
userInfo
:
"userInfo"
,
customerInfo
:
"customerInfo"
,
noSignInUuid
:
"noSignInUuid"
,
noviceGuideStatus
:
"noviceGuideStatus"
,
carBrandList
:
"carBrandList"
,
employeeList
:
"employeeList"
,
recordList
:
"recordList"
,
recordSuccessList
:
"recordSuccessList"
,
historyList
:
"historyList"
,
storageVersion
:
"storageVersion"
,
byd_mock_data
:
'byd_mock_data'
,
boutique_mock_data
:
'boutique_mock_data'
};
mock_data
:
'mock_data'
,
storageFile
:
'storageFile'
,
userInfo
:
'userInfo'
,
customerInfo
:
'customerInfo'
,
noSignInUuid
:
'noSignInUuid'
,
noviceGuideStatus
:
'noviceGuideStatus'
,
carBrandList
:
'carBrandList'
,
employeeList
:
'employeeList'
,
recordList
:
'recordList'
,
preRecordList
:
'preRecordList'
,
preRecordId
:
'preRecordId'
,
recordSuccessList
:
'recordSuccessList'
,
historyList
:
'historyList'
,
storageVersion
:
'storageVersion'
,
byd_mock_data
:
'byd_mock_data'
,
boutique_mock_data
:
'boutique_mock_data'
}
utils/cache/storageApi.js
View file @
a721826
/*
* @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'
// console.log(storage)
/** */
...
...
@@ -59,16 +67,16 @@ export function setSystem_info(that) {
})
}
export
function
getRecords
()
{
return
storage
.
get
(
STORAGE_OBJECTkEY
.
recordList
)
export
function
getRecords
(
record
=
'recordList'
)
{
return
storage
.
get
(
STORAGE_OBJECTkEY
[
record
]
)
}
export
function
setRecords
(
data
)
{
storage
.
set
(
STORAGE_OBJECTkEY
.
recordList
,
data
)
export
function
setRecords
(
data
,
record
=
'recordList'
)
{
storage
.
set
(
STORAGE_OBJECTkEY
[
record
]
,
data
)
}
export
function
removeRecords
()
{
storage
.
rm
(
STORAGE_OBJECTkEY
.
recordList
)
export
function
removeRecords
(
record
=
'recordList'
)
{
storage
.
rm
(
STORAGE_OBJECTkEY
[
record
]
)
}
export
default
{
export
default
{
getSessionId
,
setSessionId
,
getUserInfo
,
...
...
utils/recordManager/interruptRecord.js
0 → 100644
View file @
a721826
/*
* @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
()
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment