Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hbuilderApp_function
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王锐
hbuilderApp_function
Commits
6df0cc38
Commit
6df0cc38
authored
Apr 04, 2019
by
王锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用文档
parent
b0fa78aa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
10 deletions
+63
-10
ReadMe.txt
webapp/ReadMe.txt
+30
-0
index.html
webapp/index.html
+14
-2
methods.js
webapp/js/methods.js
+19
-8
No files found.
webapp/ReadMe.txt
0 → 100644
View file @
6df0cc38
//“plusready”事件之后调用
//获取经纬度 成功回调,失败回调
latitude(succ, error)
//创建文件 文件名,文件内容数据,成功回调,失败回调
write(name, data, success, error)
//读文件 文件名, 成功回调,失败回调
reader(name, success, error)
//网络变换 WIFI回调 4g回调 ,无网络回调
netChange(ntWifi, nt4g, ntNo)
//往指定文件夹创建文件 文件夹名 文件名 文件内容 成功回调,失败回调
writeFile(path, name, data, success, error)
//读取指定文件夹内容 文件夹名 文件名 成功回调,失败回调
//"storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/documents/"
readerFile(path, name, success, error)
//下载文件 下载链接 保存位置 成功回调 失败回调 文件存在回调
//"storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/downloads/"
fileDownload(downUrl, savePath, success, error,presence)
//获取设备唯一id
getUuid(success)
\ No newline at end of file
webapp/index.html
View file @
6df0cc38
...
@@ -49,6 +49,13 @@
...
@@ -49,6 +49,13 @@
text-align
:
center
;
text-align
:
center
;
background
:
greenyellow
;
background
:
greenyellow
;
}
}
#uuid
{
width
:
100%
;
height
:
40px
;
line-height
:
40px
;
text-align
:
center
;
background
:
greenyellow
;
}
</style>
</style>
<body>
<body>
<br>
<br>
...
@@ -66,6 +73,8 @@
...
@@ -66,6 +73,8 @@
<div
id=
"filereader"
>
读取文件夹
</div>
<div
id=
"filereader"
>
读取文件夹
</div>
<br
/>
<br
/>
<div
id=
"filedownload"
>
下载文件
</div>
<div
id=
"filedownload"
>
下载文件
</div>
<br
/>
<div
id=
"uuid"
>
设备唯一标识
</div>
</body>
</body>
</html>
</html>
<script
src=
"js/jquery-3.2.1.min.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"js/jquery-3.2.1.min.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
...
@@ -186,7 +195,10 @@
...
@@ -186,7 +195,10 @@
fileDownload
(
arr
[
i
],
savePath
,
success
,
error
);
fileDownload
(
arr
[
i
],
savePath
,
success
,
error
);
}
}
})
})
$
(
"#uuid"
).
on
(
"click"
,
function
(){
getUuid
(
function
success
(
res
){
alert
(
res
)
})
})
</script>
</script>
webapp/js/methods.js
View file @
6df0cc38
//“plusready”事件之后调用
//获取经纬度 成功回调,失败回调
function
latitude
(
succ
,
error
)
{
function
latitude
(
succ
,
error
)
{
plus
.
geolocation
.
getCurrentPosition
(
plus
.
geolocation
.
getCurrentPosition
(
function
(
res
)
{
function
(
res
)
{
...
@@ -15,7 +18,7 @@ function latitude(succ, error) {
...
@@ -15,7 +18,7 @@ function latitude(succ, error) {
}
}
);
);
}
}
//创建文件 文件名,文件内容数据,成功回调,失败回调
function
write
(
name
,
data
,
success
,
error
)
{
function
write
(
name
,
data
,
success
,
error
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
fs
.
root
.
getFile
(
name
+
'.json'
,
{
fs
.
root
.
getFile
(
name
+
'.json'
,
{
...
@@ -36,7 +39,7 @@ function write(name, data, success, error) {
...
@@ -36,7 +39,7 @@ function write(name, data, success, error) {
});
});
};
};
//读文件 文件名, 成功回调,失败回调
function
reader
(
name
,
success
,
error
)
{
function
reader
(
name
,
success
,
error
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
fs
.
root
.
getFile
(
name
+
'.json'
,
{
fs
.
root
.
getFile
(
name
+
'.json'
,
{
...
@@ -57,7 +60,7 @@ function reader(name, success, error) {
...
@@ -57,7 +60,7 @@ function reader(name, success, error) {
);
);
});
});
}
}
//网络变换 WIFI回调 4g回调 ,无网络回调
function
netChange
(
ntWifi
,
nt4g
,
ntNo
)
{
function
netChange
(
ntWifi
,
nt4g
,
ntNo
)
{
document
.
addEventListener
(
"netchange"
,
onNetChange
,
false
);
document
.
addEventListener
(
"netchange"
,
onNetChange
,
false
);
...
@@ -81,7 +84,7 @@ function netChange(ntWifi, nt4g, ntNo) {
...
@@ -81,7 +84,7 @@ function netChange(ntWifi, nt4g, ntNo) {
}
}
}
}
//往指定文件夹创建文件 文件夹名 文件名 文件内容 成功回调,失败回调
function
writeFile
(
path
,
name
,
data
,
success
,
error
)
{
function
writeFile
(
path
,
name
,
data
,
success
,
error
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
fs
.
root
.
getDirectory
(
path
,
{
fs
.
root
.
getDirectory
(
path
,
{
...
@@ -111,7 +114,8 @@ function writeFile(path, name, data, success, error) {
...
@@ -111,7 +114,8 @@ function writeFile(path, name, data, success, error) {
}
}
//读取指定文件夹内容 文件夹名 文件名 成功回调,失败回调
//"storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/documents/"
function
readerFile
(
path
,
name
,
success
,
error
)
{
function
readerFile
(
path
,
name
,
success
,
error
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PUBLIC_DOCUMENTS
,
function
(
fs
)
{
fs
.
root
.
getDirectory
(
path
,
{
fs
.
root
.
getDirectory
(
path
,
{
...
@@ -137,8 +141,9 @@ function readerFile(path, name, success, error) {
...
@@ -137,8 +141,9 @@ function readerFile(path, name, success, error) {
error
(
e
)
error
(
e
)
});
});
}
}
//下载文件 下载链接 保存位置 成功回调 失败回调 文件存在回调
function
fileDownload
(
downUrl
,
savePath
,
success
,
error
)
{
//"storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/downloads/"
function
fileDownload
(
downUrl
,
savePath
,
success
,
error
,
presence
)
{
//处理链接后问号
//处理链接后问号
var
allUrl
=
downUrl
.
split
(
"?"
)[
0
]
var
allUrl
=
downUrl
.
split
(
"?"
)[
0
]
//获取文件名称
//获取文件名称
...
@@ -155,7 +160,7 @@ function readerFile(path, name, success, error) {
...
@@ -155,7 +160,7 @@ function readerFile(path, name, success, error) {
console
.
log
(
savePath
+
"文件存在="
+
relativePath
);
console
.
log
(
savePath
+
"文件存在="
+
relativePath
);
//如果文件存在
//如果文件存在
function
callback
(
res
)
{
function
callback
(
res
)
{
error
(
res
)
presence
(
res
)
}
}
setUrlFromLocal
(
relativePath
,
callback
)
setUrlFromLocal
(
relativePath
,
callback
)
...
@@ -189,6 +194,7 @@ function readerFile(path, name, success, error) {
...
@@ -189,6 +194,7 @@ function readerFile(path, name, success, error) {
//下载失败,需删除 本地临时文件,否则下次进来时会检查到文件已存在
//下载失败,需删除 本地临时文件,否则下次进来时会检查到文件已存在
console
.
log
(
"下载失败="
+
status
+
"=="
+
relativePath
);
console
.
log
(
"下载失败="
+
status
+
"=="
+
relativePath
);
//dtask.abort();//文档描述:取消下载,删除临时文件(但经测试临时文件没有删除,故使用delFile()方法删除);
//dtask.abort();//文档描述:取消下载,删除临时文件(但经测试临时文件没有删除,故使用delFile()方法删除);
error
()
if
(
relativePath
!=
null
)
{
if
(
relativePath
!=
null
)
{
delFile
(
relativePath
);
delFile
(
relativePath
);
}
}
...
@@ -216,3 +222,7 @@ function readerFile(path, name, success, error) {
...
@@ -216,3 +222,7 @@ function readerFile(path, name, success, error) {
});
});
}
}
}
}
//获取设备唯一id
function
getUuid
(
success
){
success
(
plus
.
device
.
uuid
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment