首页列表显示电子钥匙状态

This commit is contained in:
范鹏 2024-09-03 17:24:03 +08:00
parent 6526c4c120
commit 1a42b7ed25
2 changed files with 45 additions and 1 deletions

View File

@ -34,6 +34,10 @@
</view>
</view>
<view class="lock-name">{{lock.lockAlias}}</view>
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">{{lock.days}}</view>
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view>
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
<view class="lock-time">
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
getTimeLimit(lock.keyType) }}</view>
@ -226,6 +230,20 @@
this.getBluetoothStatus()
return
}
if(lock.keyStatus === 110412) {
uni.showToast({
title: '钥匙已过期',
icon: 'none'
})
return
}
if(lock.keyStatus === 110405) {
uni.showToast({
title: '钥匙已冻结',
icon: 'none'
})
return
}
let result = true
if(!this.isInitBluetooth) {
result = await this.initAndListenBluetooth()
@ -308,6 +326,7 @@ page {
font-size: 32rpx;
font-weight: bold;
word-break: break-all;
line-height: 38rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
@ -318,7 +337,7 @@ page {
}
.lock-time {
padding: 12rpx 24rpx 0 24rpx;
padding: 6rpx 24rpx 0 24rpx;
font-size: 22rpx;
font-weight: bold;
}
@ -398,4 +417,16 @@ page {
font-size: 28rpx;
color: #999999;
}
.lock-status {
margin-left: 24rpx;
color: #FFFFFF;
border-radius: 8rpx;
font-size: 22rpx;
font-weight: bold;
display: inline-block;
padding: 4rpx 8rpx;
background-color: #ecab1f;
text-align: center;
}
</style>

View File

@ -101,6 +101,19 @@ export const useLockStore = defineStore('lock', {
const { code, data, message } = await getLockListRequest(params)
if(code === 0) {
this.lockTotal = data.total
for(let i = 0; i < data.groupList.length; i++) {
for (let j = 0; j < data.groupList[i].lockList.length; j++) {
if(data.groupList[i].lockList[j].keyType === 2 && data.groupList[i].lockList[j].keyStatus === 110401) {
const now = new Date().getTime()
const diffInMilliseconds = data.groupList[i].lockList[j].endDate - now
const millisecondsPerDay = 24 * 60 * 60 * 1000
const diffInDays = Math.floor(diffInMilliseconds / millisecondsPerDay)
if(diffInDays > 0 && diffInDays <= 15) {
data.groupList[i].lockList[j].days = diffInDays
}
}
}
}
if(params.pageNo === 1) {
this.lockList = data.groupList
} else {