acui-api

1.0.2 • Public • Published

API

APPCAN(ACUI) API

使用文档

使用浏览器打开网址

api.openBrowser(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
url String 要浏览的页面地址
system Boolean 是否使用系统浏览器打开(默认为:false,使用内置浏览器打开)
backgroundColor String 标题栏背景颜色
color String 标题栏文字颜色
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

扫码

api.scanCode(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
onlyFromCamera Boolean 是否只能从相机扫码,不允许从相册选择图片
backgroundColor String 标题栏背景颜色
color String 标题栏文字颜色
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

判断指纹硬件是否可用

api.canUseTouchID(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

使用指纹进行验证

api.useTouchID(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

分享到第三方应用

api.share(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
target String 要分享到的应用(weixin_timeline、weixin_message、weibo、qq)
type String 分享类型(link、text、image 默认为link)
title String 分享标题(分享类型需为link)
content String 分享内容(分享类型为text时必选)
icon String 分享缩略图(分享类型需为link、图片大小需要小于30Kb)
href String 分享链接(分享类型需为link)
pictures Array 分享图片(分享类型需为image、图片地址不支持网络路径、部分平台仅支持分享一张图片)
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

选择联系人电话号码

api.pickPhoneNumber(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回电话号码 phoneNumber
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

监听状态栏点击事件(仅支持iOS)

api.onStatusbarTap(CALLBACK)

CALLBACK返回参数:

监听返回按钮点击事件

api.onBackButtonClick(CALLBACK)

CALLBACK返回参数:

取消监听返回按钮点击

api.offBackButtonClick(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
listener Function 要移除的事件监听回调函数
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

获取页面的侧滑手势是否开启(仅支持iOS)

api.getPagePopGesture(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回手势是否开启(openPagePopGesture)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

设置页面的侧滑关闭手势(仅支持iOS)

api.setPagePopGesture(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
openPagePopGesture Boolean 是否开启侧滑关闭手势
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

设置系统状态栏样式(仅支持iOS和部分安卓)

api.setStatusBarStyle(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
style String 系统状态栏样式("dark":深色前景色样式、"light":浅色前景色样式)
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

获取系统状态栏样式(仅支持iOS和部分安卓)

api.getStatusBarStyle(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回系统状态栏样式 style("dark":深色前景色样式、"light":浅色前景色样式)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

进入全屏模式

api.enterFullscreen(CALLBACK)

CALLBACK返回参数:

离开全屏模式

api.leaveFullscreen(CALLBACK)

CALLBACK返回参数:

H5+ API初始化完毕

api.plusReady(CALLBACK)

CALLBACK返回参数:

判断是否APP环境

api.isApp

判断是否Android环境

api.isAndroid

判断是否iOS环境

api.isIos

获取客户端推送标识信息

api.getPushInfo(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回客户端推送标识信息
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
客户端推送标识信息
参数 类型 说明
appid String 应用在个推申请的appid
appkey String 应用在个推申请的appkey
clientid String 本机的clientid
token String 本机的token

监听推送消息点击

api.onPushClick(CALLBACK)

CALLBACK返回参数:

参数 类型 说明
title String 消息标题
content String 消息内容
payload String 附加内容

清空推送消息

api.clearPushMessage()

调用第三方地图进行导航

api.openSysMap(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
latitude Number 纬度,范围为-90~90,负数表示南纬
longitude Number 经度,范围为-180~180,负数表示西经
name String 位置名
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

查询启动界面是否显示状态

api.hasSplashscreen()

关闭启动界面

api.closeSplashscreen()

监听页面滚动

api.onScroll(CALLBACK)

CALLBACK返回参数:

参数 类型 说明
scrollLeft Number 当前页面的document.body.scrollLeft
scrollTop Number 当前页面的document.body.scrollTop

滚动页面到指定位置

api.scrollTo(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
scrollLeft Number 缺省为0
scrollTop Number 缺省为0

显示页面的垂直滚动条

api.showScrollIndicator()

隐藏页面的垂直滚动条

api.hideScrollIndicator()

初始化美洽客服

api.initMeiqia(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
appKey String 美洽 App Key
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

启动美洽客服界面

api.startMeiqia(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
info Object 需要携带的信息
group String 指定客服分组ID
agent String 指定客服ID
message String 启动客服界面后的预发送消息
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

获取美洽ID

api.getMeiqiaClientId(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回美洽ID clientId
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

设置美洽ID

api.setMeiqiaClientId(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
clientId String 美洽ID
success Function 接口调用成功的回调,返回美洽ID clientId
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

监听页面显示

api.onPageShow(CALLBACK)

CALLBACK返回参数:

获取当前页面信息

api.getPage(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回页面id
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

事件监听

api.on(EVENT,CALLBACK)

取消事件监听

api.off(EVENT,CALLBACK)

主动触发事件

api.emit(EVENT,DATA,PAGEID)

登录

api.login(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
target String 要获取登录信息的应用(qq、weixin)
success Function 接口调用成功的回调,返回登录数据
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

支付

api.requestPayment(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
target String 支付方式(alipay、wxpay)
statement Object 支付订单信息,不同的支付方式不同(支付宝订单参数微信订单参数
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

监听应用进入后台

api.onAppPause(CALLBACK)

监听应用返回前台继续运行

api.onAppResume(CALLBACK)

获取设备信息

api.getDeviceInfo(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回设备信息(imei、imsi、mac、uuid)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

获取状态栏高度

api.statusbarHeight()

获取顶部安全区插入位置

api.getSafeAreaInsetTop()

获取底部安全区插入位置

api.getSafeAreaInsetBottom()

获取左侧安全区插入位置

api.getSafeAreaInsetLeft()

获取右侧安全区插入位置

api.getSafeAreaInsetRight()

获取安全区插入位置

api.getSafeAreaInsets(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回安全区信息(top、left、right、bottom)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

监听安全区插入位置变更

api.onSafeAreaInsetsChange(CALLBACK)

CALLBACK返回参数:

参数 类型 说明
top Number safeAreaInsets.top
left Number safeAreaInsets.left
right Number safeAreaInsets.right
bottom Number safeAreaInsets.bottom

获取系统音量

api.getVolume(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回系统音量(value)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

设置系统音量

api.setVolume(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
value Number 要设置的系统音量值,0到1,0为静音,1为最大音量
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

开始语音识别

api.startSpeechRecognize(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
timeout Number 无语音输入识别超时时间,单位:毫秒,默认10秒
lang String 语言类型(zh-cn:中文-普通话;en-us:英语;zh-cantonese:中文-粤语;zh-henanese:中文-河南话。 默认值为“zh-cn”)
punctuation Boolean 识别结果中是否包含标点符号,默认:false
success Function 接口调用成功的回调,返回识别结果(text)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

停止(取消)语音识别

api.stopSpeechRecognize()

安装软件包(wgt、apk)

api.installPackage(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
src String 安装包的路径(可以是临时文件路径或存储文件路径,网络路径需先下载)
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

获取当前应用信息

api.getAppInfo(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回当前应用信息
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
应用信息
参数 类型 说明
appName String 应用名称
version String 应用版本
runtimeVersion String 应用运行环境版本

比较版本信息

api.compareVersions(v1,v2)

返回(Number)

  • 1:v1版本高
  • 0:v1和v2版本相等
  • -1:v1版本低

关闭APP

api.closeApp()

重启APP

api.restartApp()

获取启动参数

api.getLaunchArguments(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回启动参数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
启动参数
参数 类型 说明
arguments String 应用的启动参数

监听从其他应用启动事件

api.onLaunch(CALLBACK)

测试能否打开URL

api.canOpenURL(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
url String 要测试打开的URL
success Function 接口调用成功的回调,返回appList
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
success返回参数说明

参数|类型|说明 appList|Array|可以打开此URL的应用列表(安卓返回应用包名,iOS返回URL)

打开URL

api.openURL(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
url String 要打开的URL
identity String 要打开应用的包名(安卓)
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

设置本地化语言

api.setI18n(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
locale String 语言类型
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

打开数据库

api.openDatabase(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
name String 数据库名称
path String 数据库路径
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

执行sql语句参数

api.executeSql(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
name String 数据库名称
sql String sql语句
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

执行事务操作

api.executetTansaction(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
name String 数据库名称
operation String 事务操作类型(begin、commit、rollback)
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

执行sql查询

api.selectSql(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
name String 数据库名称
sql String sql语句
success Function 接口调用成功的回调,返回查询结果
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
success返回参数说明
参数 类型 说明
data Array 查询到的结果集合

关闭数据库

api.closeDatabase(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
name String 数据库名称
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

扫描打印机

api.scanPrinters(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调,返回查询结果
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
success返回参数说明
参数 类型 说明
printers Array 打印机名称集合

连接打印机

api.connectPrinter(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

开始打印

api.startPrint(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
width Number 打印区域宽度,单位mm
height Number 打印区域高度,单位mm
orientation Number 旋转角度,支持0、90、180、270
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

创建打印机上下文对象

api.createPrinterContext() 创建并返回printerContext对象

printerContext对象的方法列表

方法 参数 类型 说明
setItemOrientation orientation Number 设置顺时针旋转角度,支持0、90、180、270
setItemHorizontalAlignment alignment String 设置水平对齐方式,支持left、center、right
setItemVerticalAlignment alignment String 设置垂直对齐方式,支持top、center、bottom
drawText OBJECT Object 绘制文本
drawBarcode OBJECT Object 绘制条形码
drawQRCode OBJECT Object 绘制二维码
drawImage OBJECT Object 绘制图像
drawLine OBJECT Object 绘制线条
drawRoundRectangle OBJECT Object 绘制圆角矩形
drawText 的 OBJECT 参数列表:
参数 类型 必填 说明
text String 要绘制的文本
x Number 绘制文本的x坐标,单位mm
y Number 绘制文本的y坐标,单位mm
width Number 文本绘制的宽度,单位mm
height Number 文本绘制的高度,单位mm
fontHeight Number 文字高度,单位mm
drawBarcode 的 OBJECT 参数列表:
参数 类型 必填 说明
text String 条形码内容
x Number 绘制条形码的x坐标,单位mm
y Number 绘制条形码的y坐标,单位mm
width Number 条形码绘制的宽度,单位mm
height Number 条形码绘制的高度,单位mm
drawQRCode 的 OBJECT 参数列表:
参数 类型 必填 说明
text String 二维码内容
x Number 绘制二维码的x坐标,单位mm
y Number 绘制二维码的y坐标,单位mm
width Number 二维码绘制的宽度,单位mm
height Number 二维码绘制的高度,单位mm
drawImage 的 OBJECT 参数列表:
参数 类型 必填 说明
path String 图像地址
x Number 绘制图像的x坐标,单位mm
y Number 绘制图像的y坐标,单位mm
width Number 图像绘制的宽度,单位mm
height Number 图像绘制的高度,单位mm
drawLine 的 OBJECT 参数列表:
参数 类型 必填 说明
x Number 绘制线条的x坐标,单位mm
y Number 绘制线条的y坐标,单位mm
width Number 线条绘制的宽度,单位mm
height Number 线条绘制的高度,单位mm
drawRoundRectangle 的 OBJECT 参数列表:
参数 类型 必填 说明
x Number 绘制圆角矩形的x坐标,单位mm
y Number 绘制圆角矩形的y坐标,单位mm
width Number 圆角矩形绘制的宽度,单位mm
height Number 圆角矩形绘制的高度,单位mm
lineWidth Number 边框宽度,单位mm
radius Number 圆角大小,单位mm
isFilled Boolean 是否填充

提交打印

api.commitPrint(OBJECT)

OBJECT参数说明

参数 类型 必填 说明
success Function 接口调用成功的回调
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

关闭打印机连接

api.closePrinter()

Readme

Keywords

none

Package Sidebar

Install

npm i acui-api

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

254 kB

Total Files

5

Last publish

Collaborators

  • appcan