阿波罗手机端jsbridge
继承自dpapp-core,dpapp-core部分可参考http://efte.github.io/dpapp/#概述

Defined in: lib/patch-app.js:25
Module: dpapp-apollo

Methods

ajax

ajax
(
  • opts
)

Defined in lib/patch-app.js:76

发送一个请求,获取服务器端的数据

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
success Function

成功后的回调方法

fail Function

失败后的回调方法

data Object

传递给服务端的参数

method String

请求方式 get|post

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.ajax({
     method:'post',
     url:'https://a.dper.com/demo/demo',
     data:{
         name:'app'
     },
     success:function(data){
         console.dir('成功');
     },
     fail:function(){
         console.dir('失败');
     }
 });

closeWindow

closeWindow ()

Defined in lib/apis.js:101

关闭webview

downloadImage

downloadImage
(
  • opts
)

Defined in lib/apis.js:75

下载图片,下载完成后,图片会出现在用户设备的资源库中

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
type Integer

0或1,若为1则下载到相册,为0则返回imageData(base64)

imageUrl String

图片地址

success Function

Example:

 import dpappApollo from 'dpapp-apollo';

 dpappApollo.downloadImage({
     type: 1,
     imageUrl: "http://img5.douban.com/view/note/large/public/p22307117.jpg",
     success: function(result){
       alert("下载到相册");
     }
   });
   dpappApollo.downloadImage({
     type: 0,
     imageUrl: "http://img5.douban.com/view/note/large/public/p22307117.jpg",
     success: function(result){
       alert(result.imageData);
     }
   });

getCityId

getCityId
(
  • opt
)

Defined in lib/apis.js:40

获取城市信息

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.getCityId({
     success:function(e){
         console.dir(e.cityId);  //切换城市
         console.dir(e.locCityId);//定位城市
     }
 });

getContactList

getContactList
(
  • opt
)

Defined in lib/apis.js:55

获取联系人列表

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.getContactList({
     success:function(e){
         e.contactList.forEach(function(people){
           alert(e.lastName); // 姓
           alert(e.firstName); // 名
           alert(e.phone); // 号码
         });
         alert(e.authorized); // 用户是否授权
     }

 });

getDeviceInfo

getDeviceInfo
(
  • opt
)

Defined in lib/patch-app.js:364

Available since 0.3.0

获取手机端基本信息

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function
fail Function

Example:

 return {

getLocation

getLocation
(
  • opt
)

获取地理位置信息

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

获取完毕执行的回调,回调方法中会传入获取到的经度和纬度信息

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.getLocation({
     success: function(result){
         console.dir(result.lat);
         console.dir(result.lng);
     }
 });

getNetworkType

getNetworkType
(
  • opts
)

Defined in lib/apis.js:106

获取网络状态

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.getNetworkType({
     success: function(e){
       alert(e.networkType); // 2g, 3g, 4g, wifi
     }
   });

getUA

getUA
(
  • opt
)
Object

Defined in lib/patch-app.js:34

获取用户所使用的浏览器的代理信息

Parameters:

nametypeflagdescription
opt Object

参数传递

nametypeflagdescription
success Function

获取成功后执行的回调函数

Returns:

Object:

Example:

 import dpappApollo from 'dpapp-apollo';
 let ua = dpappApollo.getUA();

 console.dir(ua.platform); //平台信息
 console.dir(ua.appName);  //app名字
 console.dir(ua.packageId);
 console.dir(ua.appVersion);//版本考
 console.dir(ua.osName);
 console.dir(ua.osVersion);

getUserInfo

getUserInfo
(
  • opt
)

Defined in lib/apis.js:24

获取用户信息

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.getUserInfo({
     success:function(e){
         console.dir(e.dpid); //用户的dpid
         console.dir(e.userId); //用户id
         console.dir(e.token); //用户token
     }
 })

getWifiInfo

getWifiInfo
(
  • opt
)

Defined in lib/patch-app.js:341

Available since 0.3.0

获取wifi信息

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function
fail Function

isSupportEIM

isSupportEIM
(
  • callback
)
private

Defined in lib/patch-app.js:290

Available since 0.3.0

Parameters:

nametypeflagdescription
callback Function

jumpToScheme

jumpToScheme
(
  • opt
)

打开新的webview,并关闭原窗口。

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
url String

跳转链接

extra Object

此部分的参数会作为url的query传递

success Function

logout

logout ()

退出用户登陆

openEIM

openEIM
(
  • data
)

Defined in lib/patch-app.js:302

Available since 0.3.0

打开企业QQ

Parameters:

nametypeflagdescription
data Object

各环境打开的url

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.openEIM({
     android:"mqqwpa:\/\/im\/chat?chat_type=wpa&uin=2850297910",
     ios:"eimwpa:\/\/im\/chat?chat_type=wpa&uin=2850297910&version=1&src_type=web&web_src=null",
     pc:"qqeim:\/\/message?uin=14a3396e3211e36575e5e64086e40359a0d96398df048a14&src=200441309&flag=0&token=55e27e19d8757b47fe103f540267ca5d6788f28fb30e26c38cc3826e0618d3c900d074e31e80d0140768957d4833ec7d"
 });

openScheme

openScheme
(
  • opt
)

Defined in lib/apis.js:120

打开新的webview,extra参数会用于拼url,并做对value做encode

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
url String

跳转链接

extra Object

此部分的参数会作为url的query传递

success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.openScheme({
     url: "dpcrm://web",
     extra: {
       url:'http://www.dianping.com'
     },
     success: function(){
       // 跳转成功
     }
   });

publish

publish
(
  • opts
)

Defined in lib/apis.js:140

发布消息

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
action String

取消订阅的消息名称

data Object

需要传递的数据

success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.publish({
     action: 'myMessageName',
     data: {
       'info': 'detail'
     },
     success: function(){
       alert("发送成功");
     }
   });

ready

ready
(
  • callback
)
Null

Defined in lib/patch-app.js:54

等待整个native就绪后执行回调里的逻辑

Parameters:

nametypeflagdescription
callback Function

需要执行的回调方法

Returns:

Null:

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.ready(()=>{
     //页面主逻辑
     console.dir('页面主逻辑');
 });

setBackgroundColor

setBackgroundColor
(
  • opts
)

Defined in lib/apis.js:216

设置webview背景色

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
color String

颜色值

success Function

setLLButton

setLLButton
(
  • opts
)

Defined in lib/apis.js:179

设置按钮(icon或文字)
标题栏从左到右4个位置设置的方法分别为setLLButton,setLRButton,setRLButton,setRRButton。 使用方法一致。
注意base64代码的data:image/png;base64,部分不需要 base64的图片大小控制为 尺寸44X44(icon本身22X22)的三倍图,即132X132的画布,66X66的icon大小

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
type String

类型

icon String

和native对应的图片名称 例如:’H5_Search‘

success Function
handle Function

setLRButton

setLRButton
(
  • opts
)

Defined in lib/apis.js:204

设置按钮(icon或文字)
标题栏从左到右4个位置设置的方法分别为setLLButton,setLRButton,setRLButton,setRRButton。 使用方法一致。
注意base64代码的data:image/png;base64,部分不需要 base64的图片大小控制为 尺寸44X44(icon本身22X22)的三倍图,即132X132的画布,66X66的icon大小

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
type String

类型

icon String

和native对应的图片名称 例如:’H5_Search‘

success Function
handle Function

setPullDown

setPullDown
(
  • opt
)

下拉页面刷新,需要配合stopPullDown一起使用

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

设置成功后执行

fail Function

设置失败后执行

handle Function

刷新成功后执行

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.setPullDown({
     handle: function(){
         dpappApollo.ajax({
             url:'',
             success: function(){
                 dpappApollo.stopPullDown();
             }
         });
     }
 });

setRLButton

setRLButton
(
  • opts
)

Defined in lib/apis.js:191

设置按钮(icon或文字)
标题栏从左到右4个位置设置的方法分别为setLLButton,setLRButton,setRLButton,setRRButton。 使用方法一致。
注意base64代码的data:image/png;base64,部分不需要 base64的图片大小控制为 尺寸44X44(icon本身22X22)的三倍图,即132X132的画布,66X66的icon大小

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
type String

类型

icon String

和native对应的图片名称 例如:’H5_Search‘

success Function
handle Function

setRRButton

setRRButton
(
  • opts
)

Defined in lib/apis.js:167

设置按钮(base64)
标题栏从左到右4个位置设置的方法分别为setLLButton,setLRButton,setRLButton,setRRButton。 使用方法一致。
注意base64代码的data:image/png;base64,部分不需要 base64的图片大小控制为 尺寸44X44(icon本身22X22)的三倍图,即132X132的画布,66X66的icon大小

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
type String

base64,类型

icon String

base64的icon

success Function
handle Function

setTitle

setTitle
(
  • opts
)

Defined in lib/apis.js:160

设置标题

Parameters:

nametypeflagdescription
opts Object
nametypeflagdescription
title String

标题

showPhoto

showPhoto
(
  • opt
)

Defined in lib/patch-app.js:269

Available since 0.2.9

调用native的图片查看功能展示图片

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
name String

图片名称

url String

图片地址

success Function
fail Function

stopPullDown

stopPullDown
(
  • opt
)

停止下拉刷新,需要配合setPullDown一起使用

Parameters:

nametypeflagdescription
opt Object
nametypeflagdescription
success Function

设置成功后执行

fail Function

设置失败后执行

handle Function

刷新成功后执行

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.setPullDown({
     handle: function(){
         dpappApollo.ajax({
             url:'',
             success: function(){
                 dpappApollo.stopPullDown({

                 });
             }
         });
     }
 });

subscribe

subscribe
(
  • opts.action
  • opts.data
  • opts.success
)

Defined in lib/apis.js:224

广播功能

Parameters:

nametypeflagdescription
opts.action String

取消订阅的消息名称

opts.data Object

需要传递的数据

opts.success Function

Example:

 import dpappApollo from 'dpapp-apollo';
 dpappApollo.subscribe({
     action: 'myMessageName',
     data: {
       'info': 'detail'
     },
     success: function(){
       alert("发送成功");
     },
     handle: function(e){
       alert("广播触发");
     }
   });
Top