fix: 添加锁状态判断
This commit is contained in:
parent
ddb35d32f9
commit
758363cd10
@ -159,4 +159,10 @@ const data = await $starCloud.updateAdminPassword(params)
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
const data = await $starCloud.syncAllOpenRecord(params)
|
||||
|
||||
/**
|
||||
* 获取服务器时间
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
const data = await $starCloud.getServerTimestamp()
|
||||
```
|
||||
|
||||
24
log.js
24
log.js
@ -1,40 +1,50 @@
|
||||
import { isReportLog } from '@/starCloud/starCloud'
|
||||
import { useStarCloudStore } from '@/starCloud/starCloud'
|
||||
|
||||
const log = wx.getRealtimeLogManager ? wx.getRealtimeLogManager() : null
|
||||
|
||||
export default {
|
||||
debug() {
|
||||
if (!log) return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
||||
log.debug.apply(log, arguments)
|
||||
},
|
||||
info() {
|
||||
if (!log) return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
||||
log.info.apply(log, arguments)
|
||||
},
|
||||
warn() {
|
||||
if (!log) return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
||||
log.warn.apply(log, arguments)
|
||||
},
|
||||
error() {
|
||||
if (!log) return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
||||
log.error.apply(log, arguments)
|
||||
},
|
||||
setFilterMsg(msg) {
|
||||
// 从基础库2.7.3开始支持
|
||||
if (!log || !log.setFilterMsg) return
|
||||
if (typeof msg !== 'string') return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
log.setFilterMsg(msg)
|
||||
},
|
||||
addFilterMsg(msg) {
|
||||
// 从基础库2.8.1开始支持
|
||||
if (!log || !log.addFilterMsg) return
|
||||
if (typeof msg !== 'string') return
|
||||
if (!isReportLog) return
|
||||
const $starCloud = useStarCloudStore()
|
||||
if (!$starCloud.isReportLog) return
|
||||
log.addFilterMsg(msg)
|
||||
}
|
||||
}
|
||||
|
||||
45
starCloud.js
45
starCloud.js
@ -140,9 +140,6 @@ import log from '@/starCloud/log'
|
||||
* @property {String} userNos - 设备ID
|
||||
*/
|
||||
|
||||
// 是否上报日志
|
||||
export const isReportLog = false
|
||||
|
||||
// 命令ID
|
||||
const cmdIds = {
|
||||
// 获取公钥
|
||||
@ -210,7 +207,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
// 账户信息
|
||||
accountInfo: null,
|
||||
// 消息序号
|
||||
messageCount: 1
|
||||
messageCount: 1,
|
||||
// 是否上报日志
|
||||
isReportLog: false
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -227,7 +226,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
const appInfo = uni.getAccountInfoSync()
|
||||
this.envVersion = appInfo.miniProgram.envVersion
|
||||
|
||||
isReportLog = params.isReportLog
|
||||
this.isReportLog = params.isReportLog
|
||||
|
||||
this.env = env || 'XHJ'
|
||||
this.clientId = clientId
|
||||
@ -1013,7 +1012,6 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
|
||||
return this.getWriteResult(this.updateAdminPassword, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 同步全部开门记录
|
||||
* @param params
|
||||
@ -1035,17 +1033,14 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
accountInfo,
|
||||
disconnect
|
||||
})
|
||||
} else {
|
||||
if (disconnect) {
|
||||
await this.disconnectDevice()
|
||||
}
|
||||
return new Result(code, data, message)
|
||||
}
|
||||
} else {
|
||||
if (disconnect) {
|
||||
await this.disconnectDevice()
|
||||
}
|
||||
return new Result(code, data, message)
|
||||
}
|
||||
return new Result(code, data, message)
|
||||
},
|
||||
|
||||
/**
|
||||
* 同步开门记录
|
||||
* @param params
|
||||
@ -1150,6 +1145,15 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
|
||||
return this.getWriteResult(this.syncOpenRecord, params)
|
||||
},
|
||||
// 获取服务器时间
|
||||
async getServerTimestamp() {
|
||||
const { code, data, message } = await getServerDatetimeRequest({})
|
||||
if (code === Result.Success.code) {
|
||||
this.serverTimestamp = Math.ceil(data.date / 1000)
|
||||
this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000)
|
||||
}
|
||||
return new Result(code, data, message)
|
||||
},
|
||||
|
||||
/**
|
||||
* 清理用户
|
||||
@ -1444,15 +1448,6 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
})
|
||||
return new Result(code, data, message)
|
||||
},
|
||||
// 获取服务器时间
|
||||
async getServerTimestamp() {
|
||||
const { code, data, message } = await getServerDatetimeRequest({})
|
||||
if (code === Result.Success.code) {
|
||||
this.serverTimestamp = Math.ceil(data.date / 1000)
|
||||
this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000)
|
||||
}
|
||||
return new Result(code, data, message)
|
||||
},
|
||||
// 添加用户
|
||||
async addLockUser(params) {
|
||||
const { params: data } = params
|
||||
@ -1837,9 +1832,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
lockId: this.lockInfo.lockId
|
||||
})
|
||||
return characteristicValueCallback(new Result(result.code))
|
||||
} else {
|
||||
characteristicValueCallback(new Result(decrypted[2]))
|
||||
}
|
||||
characteristicValueCallback(new Result(decrypted[2]))
|
||||
|
||||
break
|
||||
case subCmdIds.resetLockPassword:
|
||||
this.updateLockInfo({
|
||||
@ -1917,7 +1912,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
||||
date: arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
||||
success: 1,
|
||||
password: password
|
||||
password
|
||||
}
|
||||
records.push(record)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user