feat: 添加插件日志
This commit is contained in:
commit
45fafd9693
13
README.md
13
README.md
@ -88,11 +88,12 @@ const { code, data, message } = await $starCloud.openDoor(params)
|
||||
|
||||
/**
|
||||
* 获取离线密码
|
||||
* @param {AccountInfo} accountInfo 账号信息
|
||||
* @param {OfflinePassword} password 密码信息
|
||||
* @param params
|
||||
* @param {AccountInfo} params.accountInfo 账号信息
|
||||
* @param {OfflinePassword} params.password 密码信息
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
const data = await $starCloud.getOfflinePassword(accountInfo, password)
|
||||
const data = await $starCloud.getOfflinePassword(params)
|
||||
|
||||
/**
|
||||
* 自定义密码
|
||||
@ -159,4 +160,10 @@ const data = await $starCloud.updateAdminPassword(params)
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
const data = await $starCloud.syncAllOpenRecord(params)
|
||||
|
||||
/**
|
||||
* 获取服务器时间
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
const data = await $starCloud.getServerTimestamp()
|
||||
```
|
||||
|
||||
4
env.js
4
env.js
@ -13,6 +13,10 @@ export const configs = {
|
||||
name: 'PRE',
|
||||
baseUrl: 'https://pre.cloud.star-lock.cn/sdk'
|
||||
},
|
||||
PRE_SKY: {
|
||||
name: 'PRE_SKY',
|
||||
baseUrl: 'https://pre.cloud.star-lock.cn/sdk'
|
||||
},
|
||||
XHJ: {
|
||||
name: 'XHJ',
|
||||
baseUrl: 'https://cloud.xhjcn.ltd/sdk'
|
||||
|
||||
62
starCloud.js
62
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
|
||||
@ -521,11 +520,13 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
},
|
||||
/**
|
||||
* 获取离线密码
|
||||
* @param {AccountInfo} accountInfo 账号信息
|
||||
* @param {OfflinePassword} password 密码信息
|
||||
* @param params
|
||||
* @param {AccountInfo} params.accountInfo 账号信息
|
||||
* @param {OfflinePassword} params.password 密码信息
|
||||
* @returns {Promise<Result>}
|
||||
*/
|
||||
async getOfflinePassword(accountInfo, password) {
|
||||
async getOfflinePassword(params) {
|
||||
const { accountInfo, password } = params
|
||||
// 设置执行账号
|
||||
const result = await this.login(accountInfo)
|
||||
if (result.code !== Result.Success.code) {
|
||||
@ -1020,7 +1021,6 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
|
||||
return this.getWriteResult(this.updateAdminPassword, params)
|
||||
},
|
||||
|
||||
/**
|
||||
* 同步全部开门记录
|
||||
* @param params
|
||||
@ -1042,17 +1042,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
|
||||
@ -1157,6 +1154,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)
|
||||
},
|
||||
|
||||
/**
|
||||
* 清理用户
|
||||
@ -1451,15 +1457,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
|
||||
@ -1966,6 +1963,21 @@ export const useStarCloudStore = defineStore('starCloud', {
|
||||
}
|
||||
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||
break
|
||||
case cmdIds.resetDevice:
|
||||
this.updateLockInfo({
|
||||
token: decrypted.slice(2, 6),
|
||||
electricQuantity: decrypted[7],
|
||||
electricQuantityStandby: decrypted[9]
|
||||
})
|
||||
if (decrypted[6] === Result.Success.code) {
|
||||
updateElectricQuantityRequest({
|
||||
lockId: this.lockInfo.lockId,
|
||||
electricQuantity: decrypted[7],
|
||||
electricQuantityStandby: decrypted[9]
|
||||
})
|
||||
}
|
||||
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||
break
|
||||
case cmdIds.resetDevice:
|
||||
this.updateLockInfo({
|
||||
token: decrypted.slice(2, 6)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user