更新记录
1.1.2(2026-02-05)
优化
1.1.1(2026-02-05)
优化
1.1.0(2026-02-04)
优化
查看更多平台兼容性
uni-app(4.81)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | - | - | - | - | √ | √ | √ |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.81)
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|
| - | - | √ | √ | √ | - |
umini-hk2036
开发文档
接口
export type HK2036Listener = {
/**
* 灯的状态监听
*
* LIGHT_WHITE = 0x01 白灯
*
* LIGHT_PURPLE = 0x02 紫灯
*
* LIGHT_RED_ON = 0x03 红灯开
*
* LIGHT_RED_OFF = 0x04 红灯关
*/
onLightStatusReceived ?: OnLightStatusReceived
/**
* 电池状态监听
*/
onBatteryStatusReceived ?: OnBatteryStatusReceived
/**
* 同步时间监听
*/
onSyncTimeReceived ?: OnSyncTimeReceived
/**
* 拍照按钮监听
*/
onPhotoCommandReceived ?: OnPhotoCommandReceived
onRecordReceived ?: OnRecordReceived
/**
* 关机监听
*/
onDeviceShutdown ?: OnDeviceShutdown
}
export interface IHK2036Controller {
/**
* 初始化并设置监听
*/
initialize(listener : HK2036Listener) : void
/**
* 销毁
*/
release() : void
/**
* 设置灯的状态
* LIGHT_WHITE = 0x01 白灯
* LIGHT_PURPLE = 0x02 紫灯
* LIGHT_RED_ON = 0x03 红灯开
* LIGHT_RED_OFF = 0x04 红灯关
*/
setLightStatus(status : number) : void
/**
* 关机
*/
setDeviceShutdown() : void
}
使用方法
HK2036Controller.initialize({
onLightStatusReceived: (status) => {
console.log("onLightStatusReceived = " + status)
},
onBatteryStatusReceived: (isCharging, level) => {
console.log("isCharging = " + isCharging + " level = " + level)
},
onPhotoCommandReceived: () => {
}
});
openRedLight() {
HK2036Controller.setLightStatus(HK2036Controller.LIGHT_RED_ON)
},
closeRedLight() {
HK2036Controller.setLightStatus(HK2036Controller.LIGHT_RED_OFF)
}
HK2036Controller.release()
视频
<template>
<view>
<hk2036-camera ref="camera",url="rtsp://192.168.1.1:7070/webcam" class="camera-view"></hk2036-camera>
</view>
</template>
<style>
.camera-view {
width: 600rpx;
height: 400rpx;
}
</style>
takePhoto() {
this.$refs.camera.captureFrameToGallery((savePath) => {
const result = savePath.lenth != 0
console.log(savePath)
uni.showToast({
title: result ? '拍照成功' : '拍照失败',
icon: result ? 'success' : 'none'
});
});
},
toggleRecord() {
if (this.isRecording) {
this.$refs.camera.stopRecord((savePath) => {
console.log(savePath)
this.isRecording = false;
uni.showToast({
title: '停止录制'
});
});
} else {
this.$refs.camera.startRecord((result) => {
if (result) {
this.isRecording = result;
uni.showToast({
title: '开始录制',
icon: 'none'
});
}
});
}
}

收藏人数:
购买普通授权版(
试用
赞赏(0)
下载 39
赞赏 0
下载 11229577
赞赏 1860
赞赏
京公网安备:11010802035340号