diff --git a/components/LockDatetimePicker/LockDatetimePicker.vue b/components/LockDatetimePicker/LockDatetimePicker.vue index 5a2219e..911b896 100644 --- a/components/LockDatetimePicker/LockDatetimePicker.vue +++ b/components/LockDatetimePicker/LockDatetimePicker.vue @@ -6,7 +6,8 @@ {{ timeFormat(time, 'yyyy-mm-dd h:M') }} - @@ -21,7 +22,11 @@ export default { title: String, value: Number, minDate: Number, - placeholder: String + placeholder: String, + type: { + type: String, + default: 'datetime' + } }, data() { return { @@ -34,6 +39,13 @@ export default { }, methods: { timeFormat, + filter(mode, options) { + if (mode === 'minute' && this.type === 'datehour') { + return options.filter((option) => option === '00') + } + + return options + }, changeShow() { this.show = !this.show }, diff --git a/pages/createPassword/createPassword.vue b/pages/createPassword/createPassword.vue index dd1dfad..e45b153 100644 --- a/pages/createPassword/createPassword.vue +++ b/pages/createPassword/createPassword.vue @@ -19,7 +19,7 @@ - {{ text }} diff --git a/pages/home/home.vue b/pages/home/home.vue index 74df04d..627264a 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -17,43 +17,51 @@ 填加锁时,手机必须在锁旁边 - + {{group.groupName}} - - - - - - - {{lock.electricQuantity}}% + + + + + + + + + {{ lock.electricQuantity }}% + + {{getRole(lock.userType, lock.keyRight)}} + - {{getRole(lock.userType, lock.keyRight)}} - - - {{lock.lockAlias}} - - 已过期 - 余{{lock.days}}天 - 未生效 - 已冻结 - {{lock.lockAlias}} + + 已过期 + 余{{lock.days}}天 + 未生效 + 已冻结 + 远程开锁 - - - - {{ - getTimeLimit(lock.keyType) }} - - {{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }} - {{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }} + {{ + getTimeLimit(lock.keyType) }} + + {{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }} + {{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }} + + - - + + @@ -69,6 +77,15 @@ + + + + + 同时删除其发送的所有钥匙,钥匙删除后不能恢复 + + + @@ -80,6 +97,8 @@ import { useBluetoothStore } from '@/stores/bluetooth' import { useBasicStore } from '@/stores/basic' import { mapState, mapActions } from 'pinia' + import { deleteKeyRequest } from '@/api/key' + import { deleteLockRequest } from '@/api/lock' export default { data() { @@ -87,13 +106,22 @@ refresherTriggered: false, focus: false, penging: true, - deviceInfo: null + deviceInfo: null, + options: [{ + text: '删除', + style: { + backgroundColor: '#f56c6c' + } + }], + showModal: false, + checked: false, + deleteLockInfo: null } }, computed: { ...mapState(useUserStore, ['userInfo', 'isLogin']), ...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']), - ...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']), + ...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth', 'keyId', 'currentLockInfo']), }, async onLoad() { uni.showLoading({ @@ -119,10 +147,133 @@ methods: { timeFormat, ...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']), - ...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']), + ...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']), ...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', - 'checkSetting', 'updateKeyId']), + 'checkSetting', 'updateKeyId', 'resetDevice']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), + async deleteLock(lock, groupIndex, lockIndex) { + const that = this + + that.$refs['swipeItem' + groupIndex][lockIndex].closeHandler() + if(lock.userType !== 110301 && lock.keyRight === 1) { + this.deleteLockInfo = lock + this.showModal = true + return + } + const message = lock.userType === 110301 ? '删除锁后,所有信息都会一起删除,确定删除锁吗?' : '确定删除该钥匙吗?' + const data = { + ...lock, + name: lock.bluetooth.bluetoothDeviceName, + deviceId: lock.bluetooth.bluetoothDeviceId, + commKey: lock.bluetooth.privateKey, + signKey: lock.bluetooth.signKey, + publicKey: lock.bluetooth.publicKey, + } + this.updateKeyId(lock.keyId.toString()) + this.updateCurrentLockInfo(data) + uni.showModal({ + title: '提示', + content: message, + success: async function (res) { + if (res.confirm) { + uni.showLoading({ + title: '删除中', + mask: true + }) + if(that.currentLockInfo.userType === 110301) { + const { code: resetDeviceCode } = await that.resetDevice({ + name: that.currentLockInfo.name, + authUid: that.userInfo.uid.toString(), + keyId: that.keyId.toString() + }) + if(resetDeviceCode === 0) { + const { code, message } = await deleteLockRequest({ + lockId: that.currentLockInfo.lockId + }) + if(code === 0) { + uni.hideLoading() + that.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 + }) + that.getLockList(that.lockSearch) + uni.showToast({ + title: '删除成功', + icon: 'none' + }) + } else { + uni.hideLoading() + uni.showToast({ + title: 'message', + icon: 'none' + }) + } + } else if(code === -1) { + uni.hideLoading() + uni.showToast({ + title: '删除失败,请保持在锁附近', + icon: 'none' + }) + } else { + uni.hideLoading() + } + } else { + const { code } = await deleteKeyRequest({ + keyId: that.keyId + }) + if(code === 0) { + uni.hideLoading() + that.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 + }) + that.getLockList(that.lockSearch) + uni.showToast({ + title: '删除成功', + icon: 'none' + }) + } else { + uni.hideLoading() + uni.showToast({ + title: 'message', + icon: 'none' + }) + } + } + } + } + }) + }, + async confirmModal() { + uni.showLoading({ + title: '删除中', + mask: true + }) + const that = this + const { code } = await deleteKeyRequest({ + keyId: that.deleteLockInfo.keyId, + includeUnderlings: that.checked ? 1 : 0 + }) + that.showModal = false + if(code === 0) { + uni.hideLoading() + that.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 + }) + that.getLockList(that.lockSearch) + uni.showToast({ + title: '删除成功', + icon: 'none' + }) + } else { + uni.hideLoading() + uni.showToast({ + title: 'message', + icon: 'none' + }) + } + }, homeLogin() { const that = this return new Promise((resolve) => { @@ -162,6 +313,13 @@ }) }) }, + changeRadio() { + this.checked = !this.checked + }, + cancelModal() { + this.showModal = false + this.checked = false + }, async getphonenumber(data) { if(data.detail.errMsg === 'getPhoneNumber:fail user deny') { return @@ -281,6 +439,30 @@ page { background-color: $uni-bg-color-grey; } + +.u-swipe-action { + overflow: inherit !important; +} + +.u-swipe-action-item { + margin-top: 32rpx; + overflow: inherit !important; + border-radius: 32rpx !important; + width: 320rpx; + height: 300rpx; +} + +.u-swipe-action-item__right { + border-radius: 32rpx !important; +} + +.u-swipe-action-item__content { + border-radius: 32rpx !important; +} + +.u-swipe-action-item__right__button { + border-radius: 32rpx !important; +}