更新记录
1.0(2024-12-18) 下载此版本
V1.0 初始版本
平台兼容性
Vue2 | Vue3 |
---|---|
√ | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.29,Android:4.4,iOS:不确定,HarmonyNext:不确定 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
插件集成说明
插件引入
将uts插件wif-lock
放入项目的uni_modules
目录下,在界面中导入相应插件功能,如下:
// 导入要使用的插件
import {
openSerialPort,
openAll,
assginDoor,
changeLockTime,
getLockTime,
checkLock,
checkAllLock,
lockUploadOn,
lockUploadOff,
checkLockType
} from "../../uni_modules/wif-lock"
打开串口
在使用插件功能之前,需要先打开串口,打开串口成功后即可使用其他功能:
返回值 open 为 true 即为初始化成功
onLoad() {
openSerialPort({
result: (open) => {
console.log("openSerialPort response open:" + open)
}
});
}
功能说明
插件功能接口
反馈
属性名 | 描述 |
---|---|
status | 响应状态,参考示例代码 |
scs_type | 方法 |
dial_up | 拨码 |
door_number | 锁号 |
msg | 响应消息 |
times | 时间(单位:毫秒) |
JsonBean{"status":"2", "scs_type":"OPEN_DOOR", "dial_up":"1", "door_number":"1", "msg":"OPEN_DOOR_FAILURE", "times":""}
1. 打开全部门
arg1 代表柜号,开几号柜子就输入几号,例如:开十号柜子arg1就是10
handleOpenAll() {
openAll({
arg1: Number.parseInt(this.inputValue),
response: (res) => {
console.log("handleOpenAll response res:" + res)
}
})
},
返回结果:
【开所有门——短路】
{
"status":"4",
"scs_type":"OPEN_ALL",
"dial_up":"1",
"door_number":"",
"msg":"OPEN_ALL_ FAILURE ",
"times":""
}
【开所有门——成功】
{
"status":"5",
"scs_type":"OPEN_ALL",
"dial_up":"1",
"door_number":"",
"msg":"OPEN_ALL_ SUCCESS ",
"times":""
}
2. 打开指定门(N号柜M号门)
参数 arg1:柜号 ,arg2:锁号,同上,动态数字均为十进制
assginDoor({
arg1: Number.parseInt(this.assign_g),
arg2: Number.parseInt(this.assign_m),
response: (res) => {
console.log("handleAssginDoor response res:" + res)
}
})
返回结果:
【开门成功】
{
"status":"1",
"scs_type":"OPEN_DOOR",
"dial_up":"1",
"door_number":"2",
"msg":"OPEN_DOOR_SUCCESS",
"times":""
}
【开门失败(锁未开)】
{
"status":"2",
"scs_type":"OPEN_DOOR",
"dial_up":"1",
"door_number":"2",
"msg":"OPEN_DOOR_FAILURE",
"times":""
}
【开门失败(锁短路)】
{
"status":"3",
"scs_type":"OPEN_DOOR",
"dial_up":"1",
"door_number":"2",
"msg":"SHORT_CIRCUIT",
"times":""
}
3. 修改锁的导通时间
参数 arg1: 柜号 ,arg2: 导通时间 单位:毫秒(小于200或大于2000不会进行串口发送)
changeLockTime({
arg1: Number.parseInt(this.change_time_g),
arg2: Number.parseInt(this.change_time_value),
response: (res) => {
console.log("handleChangeTime response res:" + res)
}
})
4. 获取锁的导通时间(N号柜)
参数 arg1: 柜号
getLockTime({
arg1: Number.parseInt(this.get_time_g),
response: (res) => {
console.log("getLockTime response res:" + res)
}
})
返回结果:
JsonBean{"status":"7", "scs_type":"GET_LIGHT_TIME", "dial_up":"1", "door_number":"", "msg":"GET_LIGHT_TIME_SUCCESS", "times":"500"}
5. 单个锁状态
参数 arg1: 柜号,arg2:锁号
checkLock({
arg1: Number.parseInt(this.check_lock_g),
arg2: Number.parseInt(this.check_lock_m),
response: (res) => {
console.log("checkLock response res:" + res)
}
})
返回结果:
{
"status":"9",
"scs_type":"READ_DOOR_TYPE",
"dial_up":"1",
"door_number":"2",
"msg":"READ_DOOR_TYPE_ON",
"times":""
}
{
"status":"8",
"scs_type":"READ_DOOR_TYPE",
"dial_up":"1",
"door_number":"2",
"msg":"READ_DOOR_TYPE_OFF",
"times":""
}
6. 所有锁状态
参数 arg1: 柜号 即当前板子拨码所有状态
checkAllLock({
arg1: Number.parseInt(this.check_lock_all_g),
response: (res) => {
console.log("checkAllLock response res:" + res)
}
})
返回结果:
Door_number
:值为二进制,从后往前数即为锁的位置
其中:0表示打开,1表示关闭
如下:111111111111111111111101
为2号锁状态为打开
{
"status":"10",
"scs_type":"READ_ALL_DOOR_TYPE",
"dial_up":"1",
"door_number":"111111111111111111111101",
"msg":"READ_ALL_DOOR_TYPE",
"times":""
}
7. 开启锁自动反馈
参数 arg1:柜号
lockUploadOn({
arg1: Number.parseInt(this.upload_on_g),
response: (res) => {
console.log("lockUploadOn response res:" + res)
}
})
8. 关闭锁自动反馈
参数 arg1:柜号
lockUploadOff({
arg1: Number.parseInt(this.upload_off_g),
response: (res) => {
console.log("lockUploadOff response res:" + res)
}
})
9. 查看是否开启自动反馈锁状态
动态数字均为十进制,同样,01-09不可省略0(参数为拨码数)
checkLockType({
arg1: Number.parseInt(this.check_type),
response: (res) => {
console.log("checkLockType response res:" + res)
}
})