支持单次和循环电子钥匙的使用与展示
This commit is contained in:
parent
b18c77bb2c
commit
a77d39e19a
@ -35,7 +35,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="lock-name">{{lock.lockAlias}}</view>
|
<view class="lock-name">{{lock.lockAlias}}</view>
|
||||||
<view class="lock-time">
|
<view class="lock-time">
|
||||||
<view v-if="lock.keyType === 1" style="font-size: 32rpx">{{ getTimeLimit(lock.keyType) }}</view>
|
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
|
||||||
|
getTimeLimit(lock.keyType) }}</view>
|
||||||
<view v-else>
|
<view v-else>
|
||||||
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view>
|
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view>
|
||||||
|
|||||||
@ -61,6 +61,7 @@ import { useLockStore } from '@/stores/lock'
|
|||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { getLockNetTokenRequest } from '@/api/lock'
|
import { getLockNetTokenRequest } from '@/api/lock'
|
||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
|
import { deleteKeyRequest } from '@/api/key'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
@ -71,8 +72,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useBluetoothStore, ['currentLockInfo']),
|
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
||||||
...mapState(useUserStore, ['userInfo'])
|
...mapState(useUserStore, ['userInfo']),
|
||||||
|
...mapState(useLockStore, ['lockSearch']),
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
SwitchLoading
|
SwitchLoading
|
||||||
@ -84,9 +86,9 @@ export default {
|
|||||||
this.getServeTime()
|
this.getServeTime()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useLockStore, ['getRole']),
|
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList']),
|
||||||
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']),
|
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']),
|
||||||
...mapActions(useBasicStore, ['routeJump']),
|
...mapActions(useBasicStore, ['routeJump', 'backAndToast']),
|
||||||
powerTip() {
|
powerTip() {
|
||||||
const that = this
|
const that = this
|
||||||
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
||||||
@ -151,12 +153,30 @@ export default {
|
|||||||
title: `${type === 'close' ? '关' : '开'}锁成功`,
|
title: `${type === 'close' ? '关' : '开'}锁成功`,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
} else if(code === 13) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `只能在循环时间内操作门锁`,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
|
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if(this.currentLockInfo.keyType === 3) {
|
||||||
|
const { code: deleteKeyCode } = await deleteKeyRequest({
|
||||||
|
keyId: this.keyId
|
||||||
|
})
|
||||||
|
if(deleteKeyCode === 0) {
|
||||||
|
this.updateLockSearch({
|
||||||
|
...this.lockSearch,
|
||||||
|
pageNo: 1
|
||||||
|
})
|
||||||
|
this.getLockList(this.lockSearch)
|
||||||
|
this.backAndToast('单次钥匙已在被使用后删除', 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
this.$refs.loading.close()
|
this.$refs.loading.close()
|
||||||
this.pending = false
|
this.pending = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,7 +152,6 @@ export default {
|
|||||||
})
|
})
|
||||||
that.getLockList(that.lockSearch)
|
that.getLockList(that.lockSearch)
|
||||||
that.backAndToast('删除成功', 2)
|
that.backAndToast('删除成功', 2)
|
||||||
uni.navigateBack()
|
|
||||||
} else {
|
} else {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|||||||
@ -711,6 +711,21 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 周数组转换
|
||||||
|
convertWeekdaysToNumber(weekDay) {
|
||||||
|
let weekStr = '00000000'
|
||||||
|
|
||||||
|
for (const day of weekDay) {
|
||||||
|
const index = day % 7 // 将周日的索引转换为0
|
||||||
|
weekStr = weekStr.substring(0, index) + '1' + weekStr.substring(index + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 倒序 weekStr
|
||||||
|
weekStr = weekStr.split('').reverse().join('')
|
||||||
|
|
||||||
|
const weekRound = parseInt(weekStr, 2)
|
||||||
|
return weekRound
|
||||||
|
},
|
||||||
// 查找设备并连接
|
// 查找设备并连接
|
||||||
async searchAndConnectDevice() {
|
async searchAndConnectDevice() {
|
||||||
const that = this
|
const that = this
|
||||||
@ -771,26 +786,27 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
const timestamp = parseInt(new Date().getTime() / 1000)
|
const timestamp = parseInt(new Date().getTime() / 1000)
|
||||||
const password = (Math.floor(Math.random() * 900000) + 100000).toString()
|
const password = (Math.floor(Math.random() * 900000) + 100000).toString()
|
||||||
console.log('用户未添加,开始添加用户')
|
console.log('用户未添加,开始添加用户')
|
||||||
const { code: addUserCode } = await this.addLockUser({
|
const addUserParams = {
|
||||||
name: this.currentLockInfo.name,
|
name: this.currentLockInfo.name,
|
||||||
keyId: this.keyId,
|
keyId: this.keyId,
|
||||||
authUid: this.currentLockInfo.senderUserId.toString(),
|
authUid: this.currentLockInfo.senderUserId.toString(),
|
||||||
uid: this.currentLockInfo.uid.toString(),
|
uid: this.currentLockInfo.uid.toString(),
|
||||||
openMode: 1,
|
openMode: 1,
|
||||||
keyType: 0,
|
keyType: 0,
|
||||||
startDate: this.currentLockInfo.startDate === 0 ? timestamp : this.currentLockInfo.startDate,
|
startDate: this.currentLockInfo.startDate === 0 ? timestamp : parseInt(this.currentLockInfo.startDate / 1000),
|
||||||
expireDate: this.currentLockInfo.endDate === 0 ? 0xffffffff : this.currentLockInfo.endDate,
|
expireDate: this.currentLockInfo.endDate === 0 ? 0xffffffff : parseInt(this.currentLockInfo.endDate / 1000),
|
||||||
useCountLimit: this.currentLockInfo.keyType === 3 ? 1 : 0xffff,
|
useCountLimit: this.currentLockInfo.keyType === 3 ? 1 : 0xffff,
|
||||||
isRound: 0,
|
isRound: this.currentLockInfo.keyType === 4 ? 1 : 0,
|
||||||
weekRound: 0,
|
weekRound: this.currentLockInfo.keyType === 4 ? this.convertWeekdaysToNumber(this.currentLockInfo.weekDays) : 0,
|
||||||
startHour: 0,
|
startHour: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.startDate).getHours() : 0,
|
||||||
startMin: 0,
|
startMin: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.startDate).getMinutes() : 0,
|
||||||
endHour: 0,
|
endHour: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.endDate).getHours() : 0,
|
||||||
endMin: 0,
|
endMin: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.endDate).getMinutes() : 0,
|
||||||
role: 0,
|
role: 0,
|
||||||
password
|
password
|
||||||
})
|
}
|
||||||
console.log('添加用户蓝牙结果', addUserCode)
|
const { code: addUserCode } = await this.addLockUser(addUserParams)
|
||||||
|
console.log('添加用户蓝牙结果', addUserCode, addUserParams)
|
||||||
if(addUserCode === 0) {
|
if(addUserCode === 0) {
|
||||||
const { code } = await updateLockUserNoRequest({
|
const { code } = await updateLockUserNoRequest({
|
||||||
keyId: this.keyId,
|
keyId: this.keyId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user