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 2cc44142
authored
Nov 18, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
30s轮询
1 parent
69311f56
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
10 deletions
components/HomeFrame/components/RecordList.vue
mixin/click.js
utils/cache/constantData.js
utils/recordManager/interruptRecord.js
ws/Ws.js
components/HomeFrame/components/RecordList.vue
View file @
2cc4414
...
...
@@ -182,6 +182,7 @@ export default {
async
handleSubmit
(
val
){
this
.
showRecord
=
true
;
uni
.
$recordManager
.
addRecord
(
val
)
uni
.
$logger
.
local
.
info
(
`添加记录${JSON.stringify(val)
}
`
)
interruptRecord
.
removePreRecord
(
val
.
id
)
this
.
getRecordNum
()
this
.
getPreRecordFail
()
...
...
mixin/click.js
View file @
2cc4414
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-11-
05 16:49:39
* @LastEditTime: 2024-11-
18 11:21:51
* @FilePath: \gl_tape\mixin\click.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -209,17 +209,25 @@ export default {
Object
.
assign
(
records
,
this
.
getParams
(
this
.
$store
.
state
.
user
.
customerInfo
,
this
.
booksList
,
this
.
receptionStatus
))
}
const
audioPath
=
records
.
audioPath
const
recordUrlList
=
[]
let
recordUrlList
=
[]
const
{
phone
}
=
uni
.
$storage
.
get
(
'userInfo'
)
try
{
// 把临时文件保存为永久录音文件
for
(
let
i
=
0
;
i
<
audioPath
.
length
;
i
++
)
{
console
.
log
(
audioPath
[
i
],
'audioPath[i]'
)
uni
.
$logger
.
local
.
info
(
`获取文件路径
${
audioPath
[
i
]}
`
)
const
saveResult
=
await
uni
.
saveFile
({
tempFilePath
:
audioPath
[
i
]
})
const
oldFilePath
=
saveResult
[
1
].
savedFilePath
console
.
log
(
oldFilePath
,
'oldFilePath'
)
const
{
phone
}
=
uni
.
$storage
.
get
(
'userInfo'
)
let
oldFilePath
if
(
saveResult
[
1
]
&&
saveResult
[
1
].
savedFilePath
)
{
oldFilePath
=
saveResult
[
1
].
savedFilePath
uni
.
$logger
.
local
.
info
(
`保存文件结果路径
${
oldFilePath
}
`
)
}
else
{
const
getPreAudioList
=
interruptRecord
.
getPreAudioList
||
[]
console
.
log
(
getPreAudioList
)
oldFilePath
=
getPreAudioList
[
i
]
uni
.
$logger
.
local
.
info
(
`临时文件不存在,找到之前保存的文件
${
oldFilePath
}
`
)
}
const
newFileName
=
String
(
phone
).
slice
(
-
4
)
+
'_'
+
oldFilePath
.
replace
(
/.+
\/(\d
+
\.
mp3
)
/
,
'$1'
)
const
newFilePath
=
oldFilePath
.
replace
(
/
(
.+
\/)(\d
+
\.
mp3
)
/
,
''
)
+
newFileName
const
path
=
await
utils
.
getFileSaveFolderOnClient
()
...
...
@@ -227,6 +235,7 @@ export default {
this
.
RenameFile
(
oldFilePath
,
newFileName
)
}
}
catch
(
error
)
{
recordUrlList
=
[]
uni
.
$logger
.
local
.
error
(
`
${
phone
}
上传保存失败:
${
JSON
.
stringify
(
error
)}
`
)
}
delete
records
.
audioPath
...
...
@@ -252,6 +261,7 @@ export default {
* @returns {void}
*/
async
saveRecord
(
record
)
{
uni
.
$logger
.
local
.
info
(
`添加记录
${
JSON
.
stringify
(
record
)}
`
)
const
unlock
=
await
uni
.
$recordManager
.
lock
()
console
.
log
(
'record'
,
record
)
uni
.
$recordManager
.
addRecord
(
record
)
...
...
utils/cache/constantData.js
View file @
2cc4414
...
...
@@ -20,6 +20,7 @@ export const STORAGE_OBJECTKEY = {
recordList
:
'recordList'
,
preRecordList
:
'preRecordList'
,
preRecordId
:
'preRecordId'
,
preAudioList
:
'preAudioList'
,
recordSuccessList
:
'recordSuccessList'
,
historyList
:
'historyList'
,
storageVersion
:
'storageVersion'
,
...
...
utils/recordManager/interruptRecord.js
View file @
2cc4414
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-10-14 17:38:35
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-1
0-18 18:09:1
5
* @LastEditTime: 2024-1
1-18 11:31:3
5
* @FilePath: \gl-tape\utils\recordManager\interruptRecord.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -10,6 +10,7 @@ import RecordManager from '../RecordManager.js'
import
utils
from
'@/utils/utils.js'
import
{
storageApi
}
from
'../cache'
import
store
from
'@/store'
let
Interval
=
null
class
InterruptRecord
extends
RecordManager
{
constructor
()
{
super
()
...
...
@@ -22,6 +23,7 @@ class InterruptRecord extends RecordManager {
}
records
=
{}
pathName
=
null
audioPath
=
null
/**
* 获取记录列表
*
...
...
@@ -47,6 +49,7 @@ class InterruptRecord extends RecordManager {
*
*/
removePreRecord
(
id
)
{
uni
.
$logger
.
local
.
info
(
`删除待提交的记录
${
id
}
`
)
this
.
removeRecord
(
id
)
storageApi
.
setRecords
(
''
,
'preRecordId'
)
}
...
...
@@ -57,15 +60,15 @@ class InterruptRecord extends RecordManager {
* @returns {void} - 此函数不返回任何值
*/
async
addPreRecords
(
params
)
{
console
.
log
(
storageApi
.
getRecords
(
'preRecordId'
),
6666
)
if
(
storageApi
.
getRecords
(
'preRecordId'
))
{
uni
.
$logger
.
local
.
info
(
`添加录音
${
storageApi
.
getRecords
(
'preRecordId'
)}
`
)
this
.
addPreAudio
()
return
}
console
.
log
(
'pathName'
)
const
pathName
=
await
this
.
getAudioPathName
()
const
audioPath
=
await
this
.
getAudioPath
(
pathName
)
this
.
audioPath
=
audioPath
const
id
=
utils
.
uuid
()
storageApi
.
setRecords
(
id
,
'preRecordId'
)
const
ids
=
storageApi
.
getRecords
(
'preRecordId'
)
...
...
@@ -75,22 +78,61 @@ class InterruptRecord extends RecordManager {
...
params
,
audioPath
:
[
audioPath
]
}
uni
.
$logger
.
local
.
info
(
`开始保存记录
${
id
}
`
)
const
records
=
this
.
getRecords
()
||
[]
records
.
push
(
this
.
records
)
this
.
setRecords
(
records
)
this
.
setLoopAudio
()
storageApi
.
setRecords
(
''
,
'preAudioList'
)
}
/**
* 30s保存录音文件
*
*/
setLoopAudio
()
{
Interval
=
setInterval
(()
=>
{
this
.
updateAudio
()
},
1000
*
30
)
}
async
updateAudio
()
{
const
len
=
this
.
records
.
audioPath
.
length
-
1
const
saveResult
=
await
uni
.
saveFile
({
tempFilePath
:
this
.
audioPath
})
const
preAudioList
=
storageApi
.
getRecords
(
'preAudioList'
)
||
[]
const
filePath
=
preAudioList
[
len
]
const
savedFilePath
=
saveResult
[
1
].
savedFilePath
if
(
filePath
)
{
uni
.
removeSavedFile
({
filePath
:
filePath
,
complete
:
()
=>
{
console
.
log
(
'complete'
)
}
})
}
preAudioList
[
len
]
=
savedFilePath
console
.
log
(
preAudioList
,
'preAudioList'
)
storageApi
.
setRecords
(
preAudioList
,
'preAudioList'
)
}
get
getPreAudioList
()
{
return
storageApi
.
getRecords
(
'preAudioList'
)
}
/**
* 添加录音文件
*
* @returns {void} - 此函数不返回任何值
*/
async
addPreAudio
()
{
clearInterval
(
Interval
)
this
.
updateAudio
()
const
pathName
=
await
this
.
getAudioPathName
()
const
audioPath
=
await
this
.
getAudioPath
(
pathName
)
this
.
records
.
audioPath
.
push
(
audioPath
)
const
records
=
this
.
getPreRecord
()
const
params
=
{
...
records
,
...
this
.
records
}
this
.
updateRecord
(
params
)
this
.
setLoopAudio
()
}
/**
* 更新参数
...
...
@@ -99,6 +141,7 @@ class InterruptRecord extends RecordManager {
*/
updatePreRecords
(
params
,
isRemoveId
)
{
if
(
isRemoveId
)
{
uni
.
$logger
.
local
.
info
(
`清除正在接待记录的id`
)
storageApi
.
setRecords
(
''
,
'preRecordId'
)
}
const
updateParams
=
{
...
this
.
records
,
...
params
}
...
...
ws/Ws.js
View file @
2cc4414
...
...
@@ -37,7 +37,7 @@ export class Ws {
// const userInfo = uni.$storage.get('userInfo')
// ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
if
(
!
sysInfo
?.
deviceId
)
return
uni
.
$logger
.
local
.
error
(
'未获取到系统设备信息'
)
sysInfo
.
deviceId
=
'4DF8801064461802495A2452CCD04EE4'
//
sysInfo.deviceId='4DF8801064461802495A2452CCD04EE4'
// const { name: user, phone: mobile, merchantName } = userInfo
uni
.
$logger
.
local
.
info
(
`========WS,用户登录
${
JSON
.
stringify
({
deviceId
:
sysInfo
.
deviceId
})}
========`
)
console
.
log
(
this
.
loginAddress
)
...
...
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