Skip to content

方法事件

注意

方法事件为组件方法调用后异步回调事件

用法示例

js
//事件
onEventMethod(e) {
  console.log(e.detail)
}
js
function onEventMethod(e : JSONObject) {
  console.log("onEvent:" + e.toJSONString())
}

回调示例

json
{
    "type": "register",
    "data": {
        "data": {
          "userId": "123",
          "userName": "leven",
          "faceId": 1431,
          "imagePath": "/storage/emulated/0/Android/data/test.leven.uniplugin.com/files/Pictures/faceDB/registerFaces/123###leven_1702028708665.jpg",
          "registerTime": 1702028708670,
          "featureData": []
        },
        "message": "",
        "code": 0
    }
}
json
{
    "type": "switchCamera",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "stop",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "start",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "closeFace",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "openFace",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "getCameraData",
    "data": {
        "data": {
          "supportedPreviewSizes": [
            {
              "height": 1080,
              "width": 1920
            },
            {
              "height": 1200,
              "width": 1600
            },
            {
              "height": 1080,
              "width": 1440
            },
            {
              "height": 1080,
              "width": 1260
            },
            {
              "height": 960,
              "width": 1280
            },
            {
              "height": 1080,
              "width": 1080
            },
            {
              "height": 720,
              "width": 1584
            },
            {
              "height": 1080,
              "width": 960
            },
            {
              "height": 768,
              "width": 1280
            },
            {
              "height": 720,
              "width": 1280
            },
            {
              "height": 768,
              "width": 1024
            },
            {
              "height": 738,
              "width": 1024
            },
            {
              "height": 720,
              "width": 960
            },
            {
              "height": 540,
              "width": 960
            },
            {
              "height": 720,
              "width": 720
            },
            {
              "height": 600,
              "width": 800
            },
            {
              "height": 480,
              "width": 864
            },
            {
              "height": 540,
              "width": 720
            },
            {
              "height": 480,
              "width": 800
            },
            {
              "height": 480,
              "width": 720
            },
            {
              "height": 480,
              "width": 640
            },
            {
              "height": 400,
              "width": 640
            },
            {
              "height": 360,
              "width": 640
            },
            {
              "height": 288,
              "width": 352
            },
            {
              "height": 240,
              "width": 320
            },
            {
              "height": 180,
              "width": 320
            },
            {
              "height": 144,
              "width": 176
            }
          ],
          "cameraId": 1
        },
        "message": "",
        "code": 0
    }
}

回调说明

参数名参数类型参数描述
typeString事件类型,请参考下方说明
dataObject事件数据
data.codeInteger事件结果类型,0.成功,其他:失败
data.dataInteger事件结果数据
data.messageString事件结果消息

回调事件类型说明

注册人脸

类型名称

register

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.userIdString注册的用户id
data.userNameString注册的用户名字
data.faceIdStringsdk保存的用户id
data.imagePathString注册后本地保存的头像路径
data.registerTimeInteger注册时间
data.featureDatabyte[]人脸特征数据
codeInteger返回类型,0.成功,其他:失败

切换相机

类型名称

switchCamera

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

关闭预览

类型名称

stop

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

开启预览

类型名称

start

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

关闭人脸识别

类型名称

closeFace

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

开启人脸识别

类型名称

openFace

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

获取摄像头数据

类型名称

getCameraData

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.supportedPreviewSizesObject[]相机支持的预览分辨率
data.supportedPreviewSizes.widthInteger分辨率的宽
data.supportedPreviewSizes.heightInteger分辨率的高
data.cameraIdInteger当前预览的摄像头,1.前置,0.后置
codeInteger返回类型,0.成功,其他:失败