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 79813fc7
authored
Jul 08, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
文件写入
1 parent
328898cc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
5 deletions
mixin/click.js
mixin/uploader.js
utils/RecordManager.js
utils/file/FileManager.js
mixin/click.js
View file @
79813fc
...
@@ -221,8 +221,8 @@ export default {
...
@@ -221,8 +221,8 @@ export default {
if
(
this
.
audioInfo
.
audioStatus
!=
"start"
)
{
if
(
this
.
audioInfo
.
audioStatus
!=
"start"
)
{
return
;
return
;
}
}
let
finish_timer
=
null
;
let
finish_timer
=
null
;
this
.
setAudioInfo
({
audioStatus
:
"end"
});
//直接退出
//直接退出
uni
.
showLoading
({
uni
.
showLoading
({
mask
:
true
,
mask
:
true
,
...
...
mixin/uploader.js
View file @
79813fc
...
@@ -50,11 +50,11 @@ export default {
...
@@ -50,11 +50,11 @@ export default {
* 上报文件上传失败日志
* 上报文件上传失败日志
*/
*/
reportError
(
recordId
,
filePath
)
{
reportError
(
recordId
,
filePath
)
{
const
{
customerName
,
phoneNumber
,
carModel
,
s
taff
Name
}
=
const
{
customerName
,
phoneNumber
,
carModel
,
s
ales
Name
}
=
uni
.
$recordManager
.
getRecordById
(
recordId
)
||
{};
uni
.
$recordManager
.
getRecordById
(
recordId
)
||
{};
const
{
name
}
=
uni
.
$storage
.
get
(
"userInfo"
);
const
{
name
}
=
uni
.
$storage
.
get
(
"userInfo"
);
this
.
$sendSentry
(
this
.
$sendSentry
(
`上传失败:文件-
${
filePath
}
手机号-
${
phoneNumber
}
姓名-
${
customerName
}
销售-
${
s
taff
Name
}
车型-
${
carModel
}
员工-
${
name
}
`
`上传失败:文件-
${
filePath
}
手机号-
${
phoneNumber
}
姓名-
${
customerName
}
销售-
${
s
ales
Name
}
车型-
${
carModel
}
员工-
${
name
}
`
);
);
},
},
/**
/**
...
@@ -267,7 +267,10 @@ export default {
...
@@ -267,7 +267,10 @@ export default {
this
.
enQueue
()
this
.
enQueue
()
this
.
pollingLater
(
interval
)
this
.
pollingLater
(
interval
)
}
else
{
}
else
{
const
record
=
this
.
snapshot
.
dequeue
()
let
record
=
this
.
snapshot
.
dequeue
()
while
(
record
.
file
.
startsWith
(
'http'
))
{
record
=
this
.
snapshot
.
dequeue
()
}
this
.
uploadRecord
(
record
)
this
.
uploadRecord
(
record
)
}
}
},
},
...
...
utils/RecordManager.js
View file @
79813fc
import
{
storageApi
}
from
'./cache'
import
{
storageApi
}
from
'./cache'
import
fileManager
from
"@/utils/file/FileManager.js"
;
import
utils
from
'./utils'
import
utils
from
'./utils'
/**
/**
* 记录管理器类
* 记录管理器类
...
@@ -102,6 +103,8 @@ class RecordManager {
...
@@ -102,6 +103,8 @@ class RecordManager {
* @returns {Array} - 从 storageApi 获取的记录列表
* @returns {Array} - 从 storageApi 获取的记录列表
*/
*/
getRecords
()
{
getRecords
()
{
console
.
log
(
888
)
fileManager
.
writeFile
(
"123.txt"
,
storageApi
.
getRecords
());
return
storageApi
.
getRecords
()
return
storageApi
.
getRecords
()
}
}
/**
/**
...
@@ -156,7 +159,7 @@ class RecordManager {
...
@@ -156,7 +159,7 @@ class RecordManager {
records
.
forEach
(
i
=>
{
records
.
forEach
(
i
=>
{
if
(
i
.
recordUrlList
&&
i
.
recordUrlList
.
length
)
{
if
(
i
.
recordUrlList
&&
i
.
recordUrlList
.
length
)
{
i
.
recordUrlList
.
forEach
(
async
j
=>
{
i
.
recordUrlList
.
forEach
(
async
j
=>
{
if
(
!
j
.
file
.
startsWith
(
'file://'
))
{
if
(
!
j
.
file
.
startsWith
(
'file://'
)
&&
!
j
.
file
.
startsWith
(
'http'
)
)
{
const
fileName
=
j
.
file
.
split
(
'/'
).
pop
()
const
fileName
=
j
.
file
.
split
(
'/'
).
pop
()
j
.
file
=
path
+
fileName
j
.
file
=
path
+
fileName
}
}
...
...
utils/file/FileManager.js
0 → 100644
View file @
79813fc
class
FileManager
{
writeFile
(
addr
,
data
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
// 程序公用文档目录常量
(
fs
)
=>
{
// 创建或打开文件, fs.root是根目录操作对象,直接fs表示当前操作对象
fs
.
root
.
getFile
(
addr
,
{
create
:
true
,
// 文件不存在则创建
},
(
fileEntry
)
=>
{
// 文件在手机中的路径
console
.
log
(
fileEntry
.
fullPath
);
fileEntry
.
createWriter
((
writer
)
=>
{
// 写入文件成功完成的回调函数
writer
.
onwrite
=
(
e
)
=>
{
console
.
log
(
"写入成功"
);
};
// 向文件中写入数据
writer
.
write
(
JSON
.
stringify
(
data
));
});
},
(
e
)
=>
{
console
.
log
(
"getFile failed: "
+
e
.
message
);
}
);
},
(
e
)
=>
{
console
.
log
(
e
.
message
);
}
);
}
readFile
(
addr
)
{
let
that
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
(
fs
)
=>
{
fs
.
root
.
getFile
(
addr
,
{
create
:
true
,
},
(
fileEntry
)
=>
{
fileEntry
.
file
(
function
(
file
)
{
console
.
log
(
"文件大小:"
+
file
.
size
+
"-- 文件名:"
+
file
.
name
);
//创建读取文件对象
let
fileReader
=
new
plus
.
io
.
FileReader
();
//以文本格式读取文件数据内容
fileReader
.
readAsText
(
file
,
"utf-8"
);
//文件读取操作完成时的回调函数
fileReader
.
onloadend
=
function
(
evt
)
{
resolve
(
evt
.
target
.
result
);
//console.log("提取的服务器地址:", sURL);
};
});
},
(
e
)
=>
{
reject
(
e
);
console
.
log
(
e
);
}
);
},
(
e
)
=>
{
reject
(
e
);
console
.
log
(
e
.
message
);
}
);
});
}
}
export
default
new
FileManager
();
\ No newline at end of file
\ No newline at end of file
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