feat:增加扩展功能相关常量定义
This commit is contained in:
parent
de6b6e127c
commit
eb0a3cda0f
355
constant.js
355
constant.js
@ -1,184 +1,229 @@
|
|||||||
// 命令ID
|
// 命令ID
|
||||||
export const cmdIds = {
|
export const cmdIds = {
|
||||||
// 获取公钥
|
// 获取公钥
|
||||||
getPublicKey: 0x3090,
|
getPublicKey: 0x3090,
|
||||||
// 获取私钥
|
// 获取私钥
|
||||||
getCommKey: 0x3091,
|
getCommKey: 0x3091,
|
||||||
// 获取锁状态
|
// 获取锁状态
|
||||||
getLockStatus: 0x3040,
|
getLockStatus: 0x3040,
|
||||||
// 新增用户
|
// 新增用户
|
||||||
addUser: 0x3001,
|
addUser: 0x3001,
|
||||||
// 开门
|
// 开门
|
||||||
openDoor: 0x3005,
|
openDoor: 0x3005,
|
||||||
// 重置设备
|
// 重置设备
|
||||||
resetDevice: 0x3004,
|
resetDevice: 0x3004,
|
||||||
// 清理用户
|
// 清理用户
|
||||||
cleanUser: 0x300c,
|
cleanUser: 0x300c,
|
||||||
// 扩展命令
|
// 扩展命令
|
||||||
expandCmd: 0x3030
|
expandCmd: 0x3030
|
||||||
}
|
}
|
||||||
|
|
||||||
// 子命令ID
|
// 子命令ID
|
||||||
export const subCmdIds = {
|
export const subCmdIds = {
|
||||||
// 修改管理员密码
|
// 修改管理员密码
|
||||||
updateAdminPassword: 2,
|
updateAdminPassword: 2,
|
||||||
// 设置开锁密码
|
// 设置开锁密码
|
||||||
setLockPassword: 3,
|
setLockPassword: 3,
|
||||||
// 重置开锁密码
|
// 重置开锁密码
|
||||||
resetLockPassword: 19,
|
resetLockPassword: 19,
|
||||||
// 同步开门记录
|
// 同步开门记录
|
||||||
syncOpenRecord: 41
|
syncOpenRecord: 41,
|
||||||
|
// 注册卡片
|
||||||
|
registerCard: 24,
|
||||||
|
// 注册卡片确认
|
||||||
|
registerCardConfirm: 22,
|
||||||
|
// 注册卡片取消
|
||||||
|
registerCardCancel: 25,
|
||||||
|
// 注册指纹
|
||||||
|
registerFingerprint: 36,
|
||||||
|
// 注册指纹确认
|
||||||
|
registerFingerprintConfirm: 32,
|
||||||
|
// 注册指纹取消
|
||||||
|
registerFingerprintCancel: 37,
|
||||||
|
// 注册指纹过程
|
||||||
|
registerFingerprintProcess: 33,
|
||||||
|
// 注册人脸
|
||||||
|
registerFace: 81,
|
||||||
|
// 注册人脸确认
|
||||||
|
registerFaceConfirm: 82,
|
||||||
|
// 注册人脸取消
|
||||||
|
registerFaceCancel: 86,
|
||||||
|
// 注册人脸过程
|
||||||
|
registerFaceProcess: 83,
|
||||||
|
// 注册遥控
|
||||||
|
registerRemote: 26,
|
||||||
|
// 注册遥控确认
|
||||||
|
registerRemoteConfirm: 27,
|
||||||
|
// 注册遥控取消
|
||||||
|
registerRemoteCancel: 28,
|
||||||
|
// 注册掌纹
|
||||||
|
registerPalmVein: 42,
|
||||||
|
// 注册掌纹确认
|
||||||
|
registerPalmVeinConfirm: 43,
|
||||||
|
// 注册掌纹取消
|
||||||
|
registerPalmVeinCancel: 44,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 回调事件key昵称
|
||||||
|
export const eventKeys = {
|
||||||
|
// 注册卡片确认
|
||||||
|
registerCardConfirm: 'registerCardConfirm',
|
||||||
|
// 注册指纹过程
|
||||||
|
registerFingerprintProcess: 'registerFingerprintProcess',
|
||||||
|
// 注册指纹确认
|
||||||
|
registerFingerprintConfirm: 'registerFingerprintConfirm',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export class Result {
|
export class Result {
|
||||||
static codes = {
|
static codes = {
|
||||||
Success: 0,
|
Success: 0,
|
||||||
Fail: -1,
|
Fail: -1,
|
||||||
|
|
||||||
NotMoreData: -10,
|
NotMoreData: -10,
|
||||||
|
|
||||||
NotAvailableBluetooth: -20,
|
NotAvailableBluetooth: -20,
|
||||||
NotAvailableBluetoothPermission: -21,
|
NotAvailableBluetoothPermission: -21,
|
||||||
NotAvailableWeChatNearbyDevicesPermission: -22,
|
NotAvailableWeChatNearbyDevicesPermission: -22,
|
||||||
NotAvailableWeChatLocationPermission: -23,
|
NotAvailableWeChatLocationPermission: -23,
|
||||||
NotAvailableWeChatNearbyDevicesEmpty: -24,
|
NotAvailableWeChatNearbyDevicesEmpty: -24,
|
||||||
NotAvailableWeChatBluetoothPermission: -25,
|
NotAvailableWeChatBluetoothPermission: -25,
|
||||||
DeviceHasBeenReset: -30,
|
DeviceHasBeenReset: -30,
|
||||||
|
|
||||||
NotRegisteredLock: 4,
|
NotRegisteredLock: 4,
|
||||||
NotTokenLock: 6,
|
NotTokenLock: 6,
|
||||||
NotMoreKeyLock: 12,
|
NotMoreKeyLock: 12,
|
||||||
ReadyHasKeyLock: 15,
|
ReadyHasKeyLock: 15,
|
||||||
ReadyHasPassword: 251
|
ReadyHasPassword: 251
|
||||||
}
|
|
||||||
|
|
||||||
static resultsMap = new Map([
|
|
||||||
[Result.codes.Success, { message: '成功', data: {} }],
|
|
||||||
[Result.codes.Fail, { message: '失败', data: {} }],
|
|
||||||
|
|
||||||
[Result.codes.NotMoreData, { message: '没有更多数据', data: {} }],
|
|
||||||
|
|
||||||
[Result.codes.NotAvailableBluetooth, { message: '蓝牙尚未打开,请先打开蓝牙', data: {} }],
|
|
||||||
[
|
|
||||||
Result.codes.NotAvailableBluetoothPermission,
|
|
||||||
{ message: '小程序蓝牙功能被禁用,请打开小程序蓝牙权限', data: {} }
|
|
||||||
],
|
|
||||||
[
|
|
||||||
Result.codes.NotAvailableWeChatNearbyDevicesPermission,
|
|
||||||
{ message: '蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试', data: {} }
|
|
||||||
],
|
|
||||||
[
|
|
||||||
Result.codes.NotAvailableWeChatLocationPermission,
|
|
||||||
{ message: '蓝牙功能需要定位权限,请前往设置开启微信的定位权限后再试', data: {} }
|
|
||||||
],
|
|
||||||
[
|
|
||||||
Result.codes.NotAvailableWeChatNearbyDevicesEmpty,
|
|
||||||
{
|
|
||||||
message: '蓝牙功能需要定位服务,请前往设置开启定位服务后再试',
|
|
||||||
data: {}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
Result.codes.NotAvailableWeChatBluetoothPermission,
|
|
||||||
{
|
|
||||||
message: '微信的蓝牙权限被禁用,请前往设置开启微信的蓝牙权限后再试',
|
|
||||||
data: {}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[Result.codes.DeviceHasBeenReset, { message: '设备已被重置', data: {} }],
|
|
||||||
|
|
||||||
[Result.codes.NotRegisteredLock, { message: '用户在锁端未注册', data: {} }],
|
|
||||||
[Result.codes.NotTokenLock, { message: '用户在锁端token失效', data: {} }],
|
|
||||||
[Result.codes.NotMoreKeyLock, { message: '锁端钥匙数量已达上限', data: {} }],
|
|
||||||
[Result.codes.ReadyHasKeyLock, { message: '用户已是锁端用户', data: {} }],
|
|
||||||
[Result.codes.ReadyHasPassword, { message: '该密码已存在,请更换。', data: {} }]
|
|
||||||
])
|
|
||||||
|
|
||||||
constructor(code, data, message) {
|
|
||||||
const result = Result.resultsMap.get(code)
|
|
||||||
if (result) {
|
|
||||||
this.code = code
|
|
||||||
this.message = message || result.message
|
|
||||||
this.data = data || result.data
|
|
||||||
} else {
|
|
||||||
this.code = code
|
|
||||||
this.message = message || ''
|
|
||||||
this.data = data || {}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 成功
|
static resultsMap = new Map([
|
||||||
static get Success() {
|
[Result.codes.Success, {message: '成功', data: {}}],
|
||||||
return new Result(Result.codes.Success)
|
[Result.codes.Fail, {message: '失败', data: {}}],
|
||||||
}
|
|
||||||
|
|
||||||
// 失败(默认错误)
|
[Result.codes.NotMoreData, {message: '没有更多数据', data: {}}],
|
||||||
static get Fail() {
|
|
||||||
return new Result(Result.codes.Fail)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 没有更多数据
|
[Result.codes.NotAvailableBluetooth, {message: '蓝牙尚未打开,请先打开蓝牙', data: {}}],
|
||||||
static get NotMoreData() {
|
[
|
||||||
return new Result(Result.codes.NotMoreData)
|
Result.codes.NotAvailableBluetoothPermission,
|
||||||
}
|
{message: '小程序蓝牙功能被禁用,请打开小程序蓝牙权限', data: {}}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Result.codes.NotAvailableWeChatNearbyDevicesPermission,
|
||||||
|
{message: '蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试', data: {}}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Result.codes.NotAvailableWeChatLocationPermission,
|
||||||
|
{message: '蓝牙功能需要定位权限,请前往设置开启微信的定位权限后再试', data: {}}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Result.codes.NotAvailableWeChatNearbyDevicesEmpty,
|
||||||
|
{
|
||||||
|
message: '蓝牙功能需要定位服务,请前往设置开启定位服务后再试',
|
||||||
|
data: {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
Result.codes.NotAvailableWeChatBluetoothPermission,
|
||||||
|
{
|
||||||
|
message: '微信的蓝牙权限被禁用,请前往设置开启微信的蓝牙权限后再试',
|
||||||
|
data: {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[Result.codes.DeviceHasBeenReset, {message: '设备已被重置', data: {}}],
|
||||||
|
|
||||||
// 蓝牙未开启
|
[Result.codes.NotRegisteredLock, {message: '用户在锁端未注册', data: {}}],
|
||||||
static get NotAvailableBluetooth() {
|
[Result.codes.NotTokenLock, {message: '用户在锁端token失效', data: {}}],
|
||||||
return new Result(Result.codes.NotAvailableBluetooth)
|
[Result.codes.NotMoreKeyLock, {message: '锁端钥匙数量已达上限', data: {}}],
|
||||||
}
|
[Result.codes.ReadyHasKeyLock, {message: '用户已是锁端用户', data: {}}],
|
||||||
|
[Result.codes.ReadyHasPassword, {message: '该密码已存在,请更换。', data: {}}]
|
||||||
|
])
|
||||||
|
|
||||||
// 小程序蓝牙权限被禁用
|
constructor(code, data, message) {
|
||||||
static get NotAvailableBluetoothPermission() {
|
const result = Result.resultsMap.get(code)
|
||||||
return new Result(Result.codes.NotAvailableBluetoothPermission)
|
if (result) {
|
||||||
}
|
this.code = code
|
||||||
|
this.message = message || result.message
|
||||||
|
this.data = data || result.data
|
||||||
|
} else {
|
||||||
|
this.code = code
|
||||||
|
this.message = message || ''
|
||||||
|
this.data = data || {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 微信附近的设备权限被禁用
|
// 成功
|
||||||
static get NotAvailableWeChatNearbyDevicesPermission() {
|
static get Success() {
|
||||||
return new Result(Result.codes.NotAvailableWeChatNearbyDevicesPermission)
|
return new Result(Result.codes.Success)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信定位权限被禁用
|
// 失败(默认错误)
|
||||||
static get NotAvailableWeChatLocationPermission() {
|
static get Fail() {
|
||||||
return new Result(Result.codes.NotAvailableWeChatLocationPermission)
|
return new Result(Result.codes.Fail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 手机定位服务被关闭
|
// 没有更多数据
|
||||||
static get NotAvailableWeChatNearbyDevicesEmpty() {
|
static get NotMoreData() {
|
||||||
return new Result(Result.codes.NotAvailableWeChatNearbyDevicesEmpty)
|
return new Result(Result.codes.NotMoreData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 微信的蓝牙权限被禁用
|
// 蓝牙未开启
|
||||||
static get NotAvailableWeChatBluetoothPermission() {
|
static get NotAvailableBluetooth() {
|
||||||
return new Result(Result.codes.NotAvailableWeChatBluetoothPermission)
|
return new Result(Result.codes.NotAvailableBluetooth)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设备已被重置
|
// 小程序蓝牙权限被禁用
|
||||||
static get DeviceHasBeenReset() {
|
static get NotAvailableBluetoothPermission() {
|
||||||
return new Result(Result.codes.DeviceHasBeenReset)
|
return new Result(Result.codes.NotAvailableBluetoothPermission)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户在锁端未注册
|
// 微信附近的设备权限被禁用
|
||||||
static get NotRegisteredLock() {
|
static get NotAvailableWeChatNearbyDevicesPermission() {
|
||||||
return new Result(Result.codes.NotRegisteredLock)
|
return new Result(Result.codes.NotAvailableWeChatNearbyDevicesPermission)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户在锁端token失效
|
// 微信定位权限被禁用
|
||||||
static get NotTokenLock() {
|
static get NotAvailableWeChatLocationPermission() {
|
||||||
return new Result(Result.codes.NotTokenLock)
|
return new Result(Result.codes.NotAvailableWeChatLocationPermission)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 锁端钥匙数量已达上限
|
// 手机定位服务被关闭
|
||||||
static get NotMoreKeyLock() {
|
static get NotAvailableWeChatNearbyDevicesEmpty() {
|
||||||
return new Result(Result.codes.NotMoreKeyLock)
|
return new Result(Result.codes.NotAvailableWeChatNearbyDevicesEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 锁端钥匙数量已达上限
|
// 微信的蓝牙权限被禁用
|
||||||
static get ReadyHasKeyLock() {
|
static get NotAvailableWeChatBluetoothPermission() {
|
||||||
return new Result(Result.codes.ReadyHasKeyLock)
|
return new Result(Result.codes.NotAvailableWeChatBluetoothPermission)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 密码已存在
|
// 设备已被重置
|
||||||
static get ReadyHasPassword() {
|
static get DeviceHasBeenReset() {
|
||||||
return new Result(Result.codes.ReadyHasPassword)
|
return new Result(Result.codes.DeviceHasBeenReset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用户在锁端未注册
|
||||||
|
static get NotRegisteredLock() {
|
||||||
|
return new Result(Result.codes.NotRegisteredLock)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户在锁端token失效
|
||||||
|
static get NotTokenLock() {
|
||||||
|
return new Result(Result.codes.NotTokenLock)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 锁端钥匙数量已达上限
|
||||||
|
static get NotMoreKeyLock() {
|
||||||
|
return new Result(Result.codes.NotMoreKeyLock)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 锁端钥匙数量已达上限
|
||||||
|
static get ReadyHasKeyLock() {
|
||||||
|
return new Result(Result.codes.ReadyHasKeyLock)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 密码已存在
|
||||||
|
static get ReadyHasPassword() {
|
||||||
|
return new Result(Result.codes.ReadyHasPassword)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user