diff --git a/App.vue b/App.vue index 15ddf32..14cd9b0 100644 --- a/App.vue +++ b/App.vue @@ -10,7 +10,9 @@ // 更新登录状态 updateIsLogin(isLogin) { useUserStore().updateLoginStatus(isLogin) - } + }, + // 账号信息 + appid: '' }, computed: { ...mapState(useBluetoothStore, ['bluetoothStatus']), diff --git a/api/key.js b/api/key.js new file mode 100644 index 0000000..e015c7b --- /dev/null +++ b/api/key.js @@ -0,0 +1,39 @@ +import request from '../utils/request' + +// key 电子钥匙模块 + +// 获取电子钥匙列表 +export function getKeyListRequest(data) { + return request({ + url: '/key/listUser', + method: 'POST', + data + }) +} + +// 重置电子钥匙 +export function resetKeyRequest(data) { + return request({ + url: '/key/reset', + method: 'POST', + data + }) +} + +// 创建电子钥匙 +export function createKeyRequest(data) { + return request({ + url: '/v2/key/send', + method: 'POST', + data + }) +} + +// 删除电子钥匙 +export function deleteKeyRequest(data) { + return request({ + url: '/key/delete', + method: 'POST', + data + }) +} diff --git a/api/keyboardPwd.js b/api/keyboardPwd.js new file mode 100644 index 0000000..59afe24 --- /dev/null +++ b/api/keyboardPwd.js @@ -0,0 +1,39 @@ +import request from '../utils/request' + +// keyboardPwd 锁密码模块 + +// 获取密码列表 +export function getPsaawordListRequest(data) { + return request({ + url: '/keyboardPwd/listSendRecords', + method: 'POST', + data + }) +} + +// 重置密码 +export function resetPsaawordListRequest(data) { + return request({ + url: '/keyboardPwd/reset', + method: 'POST', + data + }) +} + +// 创建密码 +export function createPsaawordRequest(data) { + return request({ + url: '/keyboardPwd/get', + method: 'POST', + data + }) +} + +// 删除密码 +export function deletePsaawordRequest(data) { + return request({ + url: '/keyboardPwd/delete', + method: 'POST', + data + }) +} diff --git a/components/LockDatetimePicker/LockDatetimePicker.vue b/components/LockDatetimePicker/LockDatetimePicker.vue new file mode 100644 index 0000000..5a2219e --- /dev/null +++ b/components/LockDatetimePicker/LockDatetimePicker.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/components/LockInput/LockInput.vue b/components/LockInput/LockInput.vue new file mode 100644 index 0000000..056de2d --- /dev/null +++ b/components/LockInput/LockInput.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/pages.json b/pages.json index 7dd24e7..cf0f97f 100644 --- a/pages.json +++ b/pages.json @@ -112,14 +112,30 @@ { "path": "pages/passwordList/passwordList", "style": { + "disableScroll": true, "navigationBarTitleText": "密码" } }, { "path": "pages/createPassword/createPassword", "style": { + "disableScroll": true, "navigationBarTitleText": "获取密码" } + }, + { + "path": "pages/passwordDetail/passwordDetail", + "style": { + "disableScroll": true, + "navigationBarTitleText": "密码详情" + } + }, + { + "path": "pages/keyDetail/keyDetail", + "style": { + "disableScroll": true, + "navigationBarTitleText": "钥匙详情" + } } ], "globalStyle": { diff --git a/pages/createKey/createKey.vue b/pages/createKey/createKey.vue index 608c2be..382e175 100644 --- a/pages/createKey/createKey.vue +++ b/pages/createKey/createKey.vue @@ -1,17 +1,236 @@ + + diff --git a/pages/createPassword/createPassword.vue b/pages/createPassword/createPassword.vue index 608c2be..fef3ce3 100644 --- a/pages/createPassword/createPassword.vue +++ b/pages/createPassword/createPassword.vue @@ -1,17 +1,207 @@ + + diff --git a/pages/home/home.vue b/pages/home/home.vue index 8fc9500..cb8c630 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -91,6 +91,8 @@ uni.showLoading({ title: '加载中' }) + const accountInfo = wx.getAccountInfoSync() + getApp().globalData.appid = accountInfo.miniProgram.appId this.deviceInfo = await this.getDeviceInfo() const token = uni.getStorageSync('token') diff --git a/pages/keyDetail/keyDetail.vue b/pages/keyDetail/keyDetail.vue new file mode 100644 index 0000000..d7993b3 --- /dev/null +++ b/pages/keyDetail/keyDetail.vue @@ -0,0 +1,70 @@ + + + + + + + diff --git a/pages/keyList/keyList.vue b/pages/keyList/keyList.vue index 608c2be..1685d50 100644 --- a/pages/keyList/keyList.vue +++ b/pages/keyList/keyList.vue @@ -1,17 +1,297 @@ + + diff --git a/pages/lockDetail/lockDetail.vue b/pages/lockDetail/lockDetail.vue index 36c4726..ce2de28 100644 --- a/pages/lockDetail/lockDetail.vue +++ b/pages/lockDetail/lockDetail.vue @@ -32,7 +32,7 @@ 功能 - 电子钥匙 diff --git a/pages/passwordDetail/passwordDetail.vue b/pages/passwordDetail/passwordDetail.vue new file mode 100644 index 0000000..de74e75 --- /dev/null +++ b/pages/passwordDetail/passwordDetail.vue @@ -0,0 +1,71 @@ + + + + + + + diff --git a/pages/passwordList/passwordList.vue b/pages/passwordList/passwordList.vue index 608c2be..4a541ae 100644 --- a/pages/passwordList/passwordList.vue +++ b/pages/passwordList/passwordList.vue @@ -1,17 +1,320 @@ + + diff --git a/pages/searchDevice/searchDevice.vue b/pages/searchDevice/searchDevice.vue index 2cc7af6..1445fcb 100644 --- a/pages/searchDevice/searchDevice.vue +++ b/pages/searchDevice/searchDevice.vue @@ -86,7 +86,8 @@ export default { }) return } - const timestamp = parseInt(new Date().getTime() / 1000) + const date = new Date() + const timestamp = parseInt(date.getTime() / 1000) - date.getTimezoneOffset() * 60 const { code } = await this.getLockStatus({ name: this.currentLockInfo.name, uid: this.userInfo.uid, diff --git a/static/images/background_empty_list.png b/static/images/background_empty_list.png new file mode 100644 index 0000000..80cdb63 Binary files /dev/null and b/static/images/background_empty_list.png differ diff --git a/stores/basic.js b/stores/basic.js index 314ed7d..b2e34b6 100644 --- a/stores/basic.js +++ b/stores/basic.js @@ -96,6 +96,16 @@ const pages = [ name: 'createPassword', path: '/pages/createPassword/createPassword', tabBar: false + }, + { + name: 'passwordDetail', + path: '/pages/passwordDetail/passwordDetail', + tabBar: false + }, + { + name: 'keyDetail', + path: '/pages/keyDetail/keyDetail', + tabBar: false } ] diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 1c83539..4698d9f 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -978,11 +978,11 @@ export const useBluetoothStore = defineStore('ble', { conentArray[i + 44] = uid.charCodeAt(i) } - conentArray.set(this.currentLockInfo.token, 64) + conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64) conentArray[68] = 16 - const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token, this.currentLockInfo.signKey) + const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.signKey) conentArray.set(md5Array, 69) @@ -1035,14 +1035,14 @@ export const useBluetoothStore = defineStore('ble', { conentArray[88] = userCountLimit / 256 conentArray[89] = userCountLimit % 256 - conentArray.set(this.currentLockInfo.token, 90) + conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 90) conentArray.set(this.timestampToArray(startTime), 94) conentArray.set(this.timestampToArray(endTime), 98) conentArray[102] = 16 - const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token, this.currentLockInfo.signKey) + const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.signKey) conentArray.set(md5Array, 103) diff --git a/stores/lock.js b/stores/lock.js index 3a67f19..f9da539 100644 --- a/stores/lock.js +++ b/stores/lock.js @@ -3,6 +3,9 @@ */ import { defineStore } from 'pinia' import { getLockListRequest } from '@/api/lock' +import { getPsaawordListRequest } from '@/api/keyboardPwd' +import { timeFormat } from 'uview-plus' +import { getKeyListRequest } from '@/api/key' export const useLockStore = defineStore('lock', { state() { @@ -10,10 +13,41 @@ export const useLockStore = defineStore('lock', { // 锁列表 lockList: [], // 锁总数 - lockTotal: 0 + lockTotal: 0, + // 密码列表 + passwordList: [], + // 密码总数 + passwordTotal: 0, + // 当前密码详情 + currentPasswordInfo: {}, + // 电子钥匙总数 + keyTotal: 0, + // 电子钥匙列表 + keyList: [], + // 当前电子钥匙详情 + currentKeyInfo: {}, + // 电子钥匙列表搜索数据 + keySearch: { + pageNo: 1, + pageSize: 50, + searchStr: '', + endDate: '0', + startDate: '0', + keyStatus: [110401,110402], + keyRight: 0 + }, } }, actions: { + updateKeySearch(search) { + this.keySearch = search + }, + updateCurrentKeyInfo(info) { + this.currentKeyInfo = info + }, + updateCurrentPasswordInfo(info) { + this.currentPasswordInfo = info + }, getRole(userType) { if(userType === 110301) { return '超级管理员' @@ -49,6 +83,56 @@ export const useLockStore = defineStore('lock', { }) return { code, message } } + }, + async getPasswordList(params) { + const { code, data, message } = await getPsaawordListRequest(params) + if(code === 0) { + this.passwordTotal = data.total + for(let i = 0; i < data.list.length; i++) { + if(data.list[i].keyboardPwdType === 2) { + data.list[i].timeText = `${timeFormat(new Date(data.list[i].created_at), 'yyyy-mm-dd h:M')} 永久` + } else if(data.list[i].keyboardPwdType === 3) { + data.list[i].timeText = `${data.list[i].validTimeStr} 限时` + } + } + if(params.pageNo === 1) { + this.passwordList = data.list + } else { + this.passwordList = this.passwordList.concat(data.list) + } + return { code } + } else { + uni.showToast({ + title: message, + icon: 'none' + }) + return { code, message } + } + }, + async getKeyList(params) { + const { code, data, message } = await getKeyListRequest(params) + if(code === 0) { + this.keyTotal = data.total + for(let i = 0; i < data.list.length; i++) { + if(data.list[i].keyType === 2) { + data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} - ${timeFormat(new Date(data.list[i].endDate), 'yyyy-mm-dd h:M')} 限时` + } else { + data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久` + } + } + if(params.pageNo === 1) { + this.keyList = data.list + } else { + this.keyList = this.keyList.concat(data.list) + } + return { code } + } else { + uni.showToast({ + title: message, + icon: 'none' + }) + return { code, message } + } } } }) diff --git a/uni.scss b/uni.scss index 642511a..8410453 100644 --- a/uni.scss +++ b/uni.scss @@ -77,3 +77,7 @@ $uni-color-subtitle: #555555; // 二级标题颜色 $uni-font-size-subtitle:26px; $uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-font-size-paragraph:15px; + +.u-picker__view { + height: 500rpx !important; +} diff --git a/utils/request.js b/utils/request.js index 4cea802..9a9b2af 100644 --- a/utils/request.js +++ b/utils/request.js @@ -14,6 +14,7 @@ const request = (config) => { return new Promise((resolve) => { const token = config?.token ? config.token : uni.getStorageSync('token') const headerDefault = { + appid: getApp().globalData.appid, version: baseConfig.version, authorization: `Bearer ${token}` }