系统提示
系统提示
发送消息,
弹出alert,
弹出确认对话框,
弹出输入对话框,
浮层提示(toast),
vibarte(震动),
autoLock(自动锁屏),
src/doc/doc.js:1925
方法
alert
alert
(
-
opts
)
Object
Defined in
src/doc/doc.js:2016
弹出提醒
参数:
opts
Object
opts.title
String
标题文字
opts.message
String
内容文字
opts.button
String
按钮文字
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Base
Example:
<html>
<h1>弹出提醒</h1>
</html>
<script>
DPZeus.alert({
title: 'title', // 标题文字
message: 'message', // 内容文字
button: '按钮', // 按钮文字
success: function(data){
alert(JSON.stringify(data));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
autoLock
autoLock
(
-
opts
)
Object
Defined in
src/doc/doc.js:2049
Available since 2.0.0
设置自动锁屏
注意:因为权限问题没法实现
参数:
opts
Object
opts.disable=0
Number
default 0: 打开自动锁屏, 1: 禁止自动锁屏
opts.success
Function
成功回调
opts.fail
Function
失败回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Base
Example:
<html>
<h1>设置自动锁屏</h1>
</html>
<script>
DPZeus.autoLock({
disable: 1, //default 0:打开自动锁屏, 1:禁止自动锁屏
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
confirm
confirm
(
-
opt
)
Object
Defined in
src/doc/doc.js:1994
弹出原生的确认对话框(类似于window.confirm),允许用户确认或取消
参数:
opt
Object
opt.title
String
标题文字
opt.message
String
内容文字
opt.okButton
String
确认按钮文字,可选,默认值『确定』
opt.cancelButton
String
取消按钮文字,可选,默认值『取消』
opt.success
Function
调用成功执行的回调 有返回值
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
{
ret: <Boolean>
}
Example:
<html>
<h1>弹出原生的确认对话框(类似于window.confirm),允许用户确认或取消</h1>
</html>
<script>
DPZeus.confirm({
title: 'title', // 标题文字
message: 'message', // 内容文字
okButton: 'OK', // 确认按钮文字
cancelButton: 'Cancel', // 取消按钮文字
success: function(e) {
// 用户点击确认或取消
if (e.ret) {} // true: 确认 false: 取消
alert(JSON.stringify(e));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
prompt
prompt
(
-
opt
)
Object
Defined in
src/doc/doc.js:1970
弹出原生的输入对话框(类似于window.prompt),允许用户输入一段文字,确认或取消。
参数:
opt
Object
opt.title
String
标题文字
opt.message
String
内容文字
opt.placeholder
String
输入框默认文字
opt.okButton
String
确认按钮文字,可选,默认值『确定』
opt.cancelButton
String
取消按钮文字,可选,默认值『取消』
opt.success
Function
调用成功执行的回调 有返回值
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
{
text: <String>,
ret: <Boolean>
}
Example:
<html>
<h1>弹出原生的输入对话框(类似于window.prompt),允许用户输入一段文字,确认或取消。</h1>
</html>
<script>
DPZeus.prompt({
title: 'title', // 标题文字
message: 'message', // 内容文字
placeholder: 'placeholder', // 输入框默认文字
okButton: 'btnconfirm', // 确认按钮文字,可选,默认值『确定』
cancelButton: 'btncancel', // 取消按钮文字,可选,默认值『取消』
success: function(e) {
// 用户点击确认或取消
if (e.ret) {
// true: 确认 false: 取消
// log(e.text); // 用户输入的文字
}
alert(JSON.stringify(e));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
sendSMS
sendSMS
(
-
opts
)
Object
Defined in
src/doc/doc.js:1936
Available since 0.3.0
发送消息
参数:
opts
Object
opts.content
String
消息内容
opts.recipients
String
联系人,多个之间用';'分割开
参数名 | 类型 | 标识 | 描述 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Base
Example:
<html>
<h1>发送消息</h1>
</html>
<script>
DPZeus.sendSMS({
recipients: '18521015811;18509510536',
content: "短信",
success: function(e){
alert(JSON.stringify(e));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
toast
toast
(
-
opt
)
Object
Defined in
src/doc/doc.js:1952
浮层提示(toast) 弹出一段简短的信息,一定时间后消失。
安卓设备上toast显示持续时间受到系统限制,只有2秒和3.5秒两个选项。
调用本接口时,如果timeout
大于2000,则按3.5秒展示;否则按2秒展示。
注意: 2.0.0 为了适配KNB,添加了 content 和 duration 参数,与原先的 title, timeout 分别对应
参数:
opt
Object
opt.title(content)
String
文字
opt.timeout(duration)
Number
持续时间,若属性为duration, 则0表示2000ms, 1表示3500ms
参数名 | 类型 | 标识 | 描述 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
Base
Example:
<html>
<h1>浮层提示(toast) 弹出一段简短的信息,一定时间后消失。 安卓设备上toast显示持续时间受到系统限制,只有2秒和3.5秒两个选项。调用本接口时,如果timeout
大于2000,则按3.5秒展示;否则按2秒展示。
注意: 2.0.0 适配KNB,添加了 content和duration 参数,与原先的 title, timeout 分别对应</h1>
</html>
<script>
DPZeus.toast({
title: 'title', // 文字
timeout: 2000 , // 持续时间
success: function (data) {
alert(JSON.stringify(data));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
vibarte
vibarte
(
-
opts
)
Object
Defined in
src/doc/doc.js:2032
Available since 2.0.0
震动
参数:
opts
Object
需要执行的回调方法
opts.duration=1000
Number
震动间隔,单位ms
opts.success
Function
成功回调
opts.fail
Function
失败回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object | 需要执行的回调方法
|
Returns:
Base
Example:
<html>
<h1>震动</h1>
</html>
<script>
DPZeus.vibarte({
duration: 1000,
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>