扫码API
scanCode
调起客户端扫码界面进行扫码
引入
import { scanCode } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
onlyFromCamera | boolean | 否 | 是否只能从相机扫码,不允许从相册选择图片 | |
scanType | array | 否 | 扫码类型 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
object.success 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
result | string | 所扫码的内容 |
scanType | string | 所扫码的类型 |
charSet | string | 所扫码的字符集 |
path | string | 当所扫的码为当前小程序二维码时,会返回此字段,内容为二维码携带的 path (不一定会有返回值) |
rawData | string | 原始数据,base64 编码 |
object.fail 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
震动API
vibrateShort
使手机发生较短时间的振动(30 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
引入
import { vibrateShort } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
type | string | 是 | 震动强度类型,有效值为:heavy、medium、light | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
vibrateLong
使手机发生较长时间的振动(400 ms)
引入
import { vibrateLong } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
屏幕API
getScreenBrightness
获取手机屏幕亮度
引入
import { getScreenBrightness } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
object.success 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
value | number | 屏幕亮度值,范围 0 ~ 1。0 最暗,1 最亮 |
object.fail 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
setKeepScreenOn
设置是否保持常亮状态
引入
import { setKeepScreenOn } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
keepScreenOn | boolean | 是 | 是否保持屏幕常亮 | |
complete | function | 否 | 接口调用完成的回调函数(成功或失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
setScreenBrightness
设置手机屏幕亮度
引入
import { setScreenBrightness } from '@ray-js/ray';
需引入
BaseKit
,且在>=2.3.2
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
value | number | 是 | 屏幕亮度值,范围 0 ~ 1。0 最暗,1 最亮 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。