diff --git a/pages/home/home.vue b/pages/home/home.vue index a46fb54..6b71afc 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -34,6 +34,10 @@ {{lock.lockAlias}} + 已过期 + 余{{lock.days}}天 + 未生效 + 已冻结 {{ getTimeLimit(lock.keyType) }} @@ -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; +} diff --git a/stores/lock.js b/stores/lock.js index 1cb2120..22f9482 100644 --- a/stores/lock.js +++ b/stores/lock.js @@ -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 {