基础业务功能
基础业务功能
关闭webview,
打开新的webview,
关闭原窗口后打开新的webview,
打开webview(KNB),
打开新的webview,并关闭原窗口(KNB),
关闭webview(KNB),
发送ajax请求,
退出用户登陆,
用户登陆,
查找打印机,
打印,
检查交易,
分享,
右上角分享,
是否安装微信,
绑定微信,
绑定APP(KNB),
设置系统日历事件,
删除日历事件,
查询日历事件,
拨打电话,
获取webview的截屏,
src/doc/doc.js:592
方法
ajax
ajax
(
-
opts
)
Null
Defined in
src/doc/doc.js:709
发送一个请求,获取服务器端的数据
注意:阿波罗独有
参数:
opts
Object
opts.success
Function
成功后的回调方法
opts.fail
Function
失败后的回调方法
opts.data
Object
传递给服务端的参数
opts.method
String
请求方式 get|post
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>发送一个请求,获取服务器端的数据<br/></h1>
</html>
<script>
DPZeus.ajax({
method:'post',
url:'https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty',
data:{
print:'pretty'
},
success:function(data){
alert(JSON.stringify(data));
},
fail:function(error){
alert(JSON.stringify(error));
}
});
</script>
appBind
appBind
(
-
opts
)
Null
Defined in
src/doc/doc.js:926
Available since 2.0.0
绑定微博微信
已知问题:后续迭代实现
参数:
opts
Object
opts.url
String
bind url(选填)
opts.scope
String
权限(选填)
opts.type
Number
0为QQ、1为微信 (必填)
opts.appKey
String
App Key值 (选填)
opts.success
Function
opts.fail
Function
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>绑定微博微信</h1>
</html>
<script>
DPZeus.weixinBind({
type: 1, // 0为QQ、1为微信 (必填)
success: function(result){
alert(JSON.stringify(result));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
checkDeal
checkDeal
(
-
opt
)
Defined in
src/doc/doc.js:787
检查交易
参数:
opt
Object
opt.success
Function
调用成功执行的回调
参数名 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Example:
<html>
<h1>检查交易</h1>
</html>
<script>
DPZeus.checkDeal({
success: function(res){
alert(JSON.stringify(res));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
closeWebview
closeWebview
()
Null
Defined in
src/doc/doc.js:696
Available since 2.0.0
关闭webview
Returns:
configShare
configShare
(
-
opts
)
Null
Defined in
src/doc/doc.js:865
Available since 2.0.0
右上角分享
参数:
opts
Object
opts.title
String
标题
opts.desc
String
分享描述
opts.image
String
分享图标
opts.url
String
分享链接
opts.channel
Array
分享渠道,当分享渠道只有一个时,触发直接分享 可选值有 WECHAT_FRIENDS(微信好友) | WECHAT_TIMELINE(微信朋友圈)| QQ(手机QQ)| SMS(短信)| WEIBO(新浪微博)| QZONE | EMAIL | COPY
opts.success
Function
成功回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>右上角分享</h1>
</html>
<script>
DPZeus.configShare({
title: "分享标题",
desc: "分享描述",
image: "http://www.dpfile.com/toevent/img/16d05c85a71b135edc39d197273746d6.png",
url: "http://m.dianping.com",
handle: function(data){
alert(JSON.stringify(data));
},
success: function(channel){
alert(JSON.stringify(channel));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
deleteCalendersEvent
deleteCalendersEvent
(
-
opts
)
Object
Defined in
src/doc/doc.js:971
Available since 1.0.0
删除日历事件
参数:
opts
Object
opts.title
String
事件标题
opts.begintime
String
开始时间,格式为 yyyy-MM-dd HH:mm
opts.endtime
String
结束时间,格式为 yyyy-MM-dd HH:mm
opts.handle
Function
事件回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
{
id: <Number>
}
Example:
<html>
<h1>删除日历事件</h1>
</html>
<script>
DPZeus.deleteCalendersEvent({
title: "拜访日",
begintime: "2017-11-21 11:22",
endtime: "2017-11-22 14:23",
handle: function(data){
if(data.id == 1){
// log('deleteCalendersEvent success');
}
if(data.id == -1){
// log('deleteCalendersEvent fail');
}
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
getPrintDevice
getPrintDevice
(
-
opt
)
Object
Defined in
src/doc/doc.js:753
查找打印机
参数:
opt
Object
opt.success
Function
调用成功执行的回调,有返回值
参数名 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
{
deviceName: <String>
}
Example:
<html>
<h1>查找打印机</h1>
</html>
<script>
DPZeus.getPrintDevice({
success: function(e) {
if (e && e.deviceName) {
// log(e.deviceName);// 未连接打印机返回''
}
alert(JSON.stringify(e));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
getWebViewCapture
getWebViewCapture
(
-
opt
)
Object
Defined in
src/doc/doc.js:815
Available since 2.0.0
获取webview的截屏
注意:点评管家需要 6.3.0
及其以后的版本
阿波罗需要 3.0.4.0
及其以后的版本
参数:
opt
Object
opt.success
Function
调用成功执行的回调
opt.fail
Function
调用失败执行的回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
{
imagePath: <String>
}
Example:
<html>
<h1>对webview进行截图保存到本地</h1>
</html>
<script>
DPZeus.getWebViewCapture({
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
})
</script>
jumpToScheme
jumpToScheme
(
-
opt
)
Null
Defined in
src/doc/doc.js:646
打开新的webview,并关闭原窗口。
参数:
opt
Object
opt.url
String
跳转链接
opt.extra
Object
此部分的参数会作为url的query传递
opt.success
Function
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
Example:
<html>
<h1>打开新的webview,并关闭原窗口。</h1>
</html>
<script>
DPZeus.jumpToScheme({
url: "dpcrm://web",
extra: {
url:'http://www.dianping.com'
},
success: function(data){
// 跳转成功
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
jumpWebview
jumpWebview
(
-
opts
)
Null
Defined in
src/doc/doc.js:679
Available since 2.0.0
打开新的webview,并关闭原窗口
参数:
opts
Object
opts.url
String
需要打开的完整http链接
opts.gs
Object
opts.gs.notitlebar=1
Number
隐藏webview的导航栏功能
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>打开新的webview,并关闭原窗口</h1>
</html>
<script>
DPZeus.jumpWebview({
url: 'http://m.dianping.com', //需要打开的完整http链接
//隐藏webview的导航栏功能
qs: {
notitlebar: 1
},
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
login
login
(
-
opts
)
Null
Defined in
src/doc/doc.js:739
登录
参数:
opts
Object
opts.success
Function
成功回调
参数名 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>登录</h1>
</html>
<script>
DPZeus.login({
success: function(user){
var type = user.type;//账户类型:‘dp’,'mt'
var userId = user.userId; //用户ID
var token = user.token; //用户登录态
alert(JSON.stringify(user));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
logout
logout
()
Null
Defined in
src/doc/doc.js:727
退出用户登陆
Returns:
Example:
<html>
<h1>退出用户登陆</h1>
</html>
<script>
DPZeus.logout({
success: function(data){
alert(JSON.stringify(data));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
openScheme
openScheme
(
-
opt
)
Null
Defined in
src/doc/doc.js:630
打开新的webview,extra参数会用于拼url,并做对value做encode
参数:
opt
Object
opt.url
String
跳转链接
opt.extra
Object
此部分的参数会作为url的query传递
opt.success
Function
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
Example:
<html>
<h1>打开新的webview,extra参数会用于拼url,并做对value做encode</h1>
</html>
<script>
DPZeus.openScheme({
url: "dpcrm://web",
extra: {
url:'http://www.dianping.com'
},
success: function(data){
// 跳转成功
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
openWebview
openWebview
(
-
opts
)
Null
Defined in
src/doc/doc.js:662
Available since 2.0.0
打开webview
参数:
opts
Object
opts.url
String
需要打开的完整http链接
opts.gs
Object
opts.gs.notitlebar=1
Number
隐藏webview的导航栏功能
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>打开webview</h1>
</html>
<script>
DPZeus.openWebview({
url: 'http://m.dianping.com', //需要打开的完整http链接,
//隐藏webview的导航栏功能
qs: {
notitlebar: 1
},
success: function (data) {
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
phoneCall
phoneCall
(
-
opt
)
Object
Defined in
src/doc/doc.js:800
Available since 1.1.5
拨打电话
参数:
opt
Object
opt.success
Function
调用成功执行的回调
参数名 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
Base
Example:
<html>
<h1>拨打电话</h1>
</html>
<script>
DPZeus.phoneCall({
phoneNum: '13345511579',
success: function(result){
alert(JSON.stringify(result));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
print
(
-
opt
)
Null
Defined in
src/doc/doc.js:771
调用打印机 调用native发送广播,具体的打印方法由业务方实现。
参数:
opt
Object
opt.content
Object
和具体业务相关的数据结构
opt.action
String
广播名称
opt.success
Function
调用成功执行的回调,有返回值
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt
| Object |
|
Returns:
Example:
<html>
<h1>调用打印机 调用native发送广播,具体的打印方法由业务方实现。</h1>
</html>
<script>
DPZeus.print({
content: {},// 和具体业务相关的数据结构
action: 'com.dianping.dpmerchant.action.push.DISHPRINT', // 广播名称
success: function(e) {
// 发送打印广播成功
alert(JSON.stringify(e));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
queryCalendersEvent
queryCalendersEvent
(
-
opts
)
Object
Defined in
src/doc/doc.js:993
Available since 1.0.0
查询日历事件
参数:
opts
Object
opts.title
String
事件标题
opts.begintime
String
开始时间,格式为 yyyy-MM-dd HH:mm
opts.endtime
String
结束时间,格式为 yyyy-MM-dd HH:mm
opts.handle
Function
事件回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
{
id: <Number>
}
Example:
<html>
<h1>查询日历事件</h1>
</html>
<script>
DPZeus.queryCalendersEvent({
title: "拜访日",
begintime: "2017-11-21 11:22",
endtime: "2017-11-22 14:23",
handle: function(data){
if(data.id == 1){
// log('queryCalendersEvent success');
}
if(data.id == -1){
// log('queryCalendersEvent fail');
}
alert(JSON.stringify(data));
},
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>
setCalendersEvent
setCalendersEvent
(
-
opts
)
Object
Defined in
src/doc/doc.js:947
Available since 1.0.0
设置系统日历事件
参数:
opts
Object
opts.title
String
事件标题
opts.description
String
事件描述
opts.begintime
String
开始时间,格式为 yyyy-MM-dd HH:mm
opts.endtime
String
结束时间,格式为 yyyy-MM-dd HH:mm
opts.reminders
String
提前多少事件提醒
opts.handle
Function
事件回调
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
{
id: <Number>
}
Example:
<html>
<h1>设置系统日历事件</h1>
</html>
<script>
DPZeus.setCalendersEvent({
title: "拜访日",
description: "今天要去万达和王老板洽谈生意",
begintime: "2017-11-21 11:22",
endtime: "2017-11-22 14:23",
reminders: "10",
handle: function(data){
/*if(data.id == 1){
log('success');
}
if(data.id == -1){
log('fail');
}*/
alert(JSON.stringify(data));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
share
share
(
-
opts
)
Object
Defined in
src/doc/doc.js:837
Available since 0.3.0
分享
参数:
opts
Object
opts.title
String
标题
opts.desc
String
分享描述
opts.image
String
分享图标
opts.url
String
分享链接
opts.content
String
分享内容
opts.extra
String
附加字段,JSON 字符串
opts.channel
Array
分享渠道,当分享渠道只有一个时,触发直接分享 可选值有 WECHAT_FRIENDS(微信好友) | WECHAT_TIMELINE(微信朋友圈)| QQ(手机QQ)| SMS(短信)| WEIBO(新浪微博)| QZONE | EMAIL | COPY
opts.success
Function
成功后的回调方法
opts.fail
Function
失败后的回调方法
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
{
channel: <String>
}
Example:
<html>
<h1>分享
注意: 2.0.0 DPZeus 中将 feed 改成了 channel,作用一致</h1>
</html>
<script>
DPZeus.share({
title: "分享标题",
desc: "分享描述",
content: "分享内容",
image: "http://www.dpfile.com/toevent/img/16d05c85a71b135edc39d197273746d6.png",
url: "http://m.dianping.com",
channel: [DPZeus.Share.WECHAT_TIMELINE, DPZeus.Share.WECHAT_FRIENDS],
success: function(data){
alert(JSON.stringify(data));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
weixinBind
weixinBind
(
-
opts
)
Null
Defined in
src/doc/doc.js:907
Available since 0.3.0
绑定微信
已知问题:android 中据说自始至终没实现该接口
IOS 中升级Titians也失效
参数:
opts
Object
opts.scope
String
opts.success
Function
成功后的回调方法
opts.fail
Function
失败后的回调方法
参数名 | 类型 | 标识 | 描述 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
Example:
<html>
<h1>绑定微信</h1>
</html>
<script>
DPZeus.weixinBind({
scope:'test',
success: function(result){
alert(JSON.stringify(result));
},
fail: function (error) {
alert(JSON.stringify(error));
}
});
</script>
wixinCheck
wixinCheck
(
-
opts
)
Object
Defined in
src/doc/doc.js:886
Available since 0.3.0
是否安装微信
已知问题:android 中据说自始至终没实现该接口,可以使用isInstalledApp代替
参数:
opts
Object
opts.success
Function
成功后的回调方法
opts.fail
Function
失败后的回调方法
参数名 | 类型 | 标识 | 描述 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts
| Object |
|
Returns:
{
installed: <Boolean>
}
Example:
<html>
<h1>是否安装微信</h1>
</html>
<script>
DPZeus.wixinCheck({
success: function(data){
alert(JSON.stringify(data));
},
fail: function(error){
alert(JSON.stringify(error));
}
});
</script>