From f9669c8d2c15812eff69eddf0752a5b1187a2e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Wed, 28 Aug 2024 16:55:11 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=AE=8C=E6=88=90=E9=94=81=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=202.=20=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E9=94=81=E7=94=B5=E5=AD=90=E9=92=A5=E5=8C=99=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 4 +- api/key.js | 39 +++ api/keyboardPwd.js | 39 +++ .../LockDatetimePicker/LockDatetimePicker.vue | 75 +++++ components/LockInput/LockInput.vue | 60 ++++ pages.json | 16 + pages/createKey/createKey.vue | 225 ++++++++++++- pages/createPassword/createPassword.vue | 196 ++++++++++- pages/home/home.vue | 2 + pages/keyDetail/keyDetail.vue | 70 ++++ pages/keyList/keyList.vue | 288 +++++++++++++++- pages/lockDetail/lockDetail.vue | 2 +- pages/passwordDetail/passwordDetail.vue | 71 ++++ pages/passwordList/passwordList.vue | 311 +++++++++++++++++- pages/searchDevice/searchDevice.vue | 3 +- static/images/background_empty_list.png | Bin 0 -> 1445 bytes stores/basic.js | 10 + stores/bluetooth.js | 8 +- stores/lock.js | 86 ++++- uni.scss | 4 + utils/request.js | 1 + 21 files changed, 1488 insertions(+), 22 deletions(-) create mode 100644 api/key.js create mode 100644 api/keyboardPwd.js create mode 100644 components/LockDatetimePicker/LockDatetimePicker.vue create mode 100644 components/LockInput/LockInput.vue create mode 100644 pages/keyDetail/keyDetail.vue create mode 100644 pages/passwordDetail/passwordDetail.vue create mode 100644 static/images/background_empty_list.png 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 0000000000000000000000000000000000000000..80cdb6320dfc3f8069fb5d161426ded8b778b67a GIT binary patch literal 1445 zcmc(fe>~H99LGQ3?`BweL{=Etu2Pn(6gvGlhSi#4CWPF~gAzCChlGp1m|Uu>LrC+m zL_dg>$IZp2ogX(ByK#QxM`o9cv0@&!$**?1fA6pR@BVndU(d(;{dhlK|GXcsYks~| z6D%GJ05G8)rugd>`KOF9`rhIe(V-XUffmP7ZQ)8sxumMvP-D`v}EwA8FJT+ z@Yn-Ju}DdAMgt(Y+YpA($oA*odWz6wpHyE%VrNW?a52^| z5;m9RsazlwFl*q(x~YlwWp#c=u_)8~;>mF@D9H|zB>0&l;xV&_t@W!Ij|WQW;@c$F zISd{0*ba(1v$u-Sa7%M72C&DEqmYPwWR&Q1S|Et^LeNOx@)YRh00U6BfCH^$)up!O zi$bQmH*-H3h|ai~fL*5fZo9%7368ytsf{pmbrIXO}`(@uYOtC+~OP`@4QOb?vow` zZe$TgN_I*@n(UL}D<#Ppu2vvY?PbemkMwTRScA>(!S~R}A)T4>b*gr?QLf%>XY|yM z;V%-yNUNG#K=6E{lk8IxB}ywT@J(+4AL5qIuix~c*{QF7;+JlmtNzyA5My_YhzCl6 z&OX`3pMT=u6WsS0(LVK)m3QLA>Z4VH04xRKb(fy{V{mkLe+(rEw>RW(o(^ z7XwAtR*6k-{rO}1uNijBzZ3KEuZN-?U`ShWH{)}VFP06nwl60rGWp4kLN0CqE&5q< zr0~1sWr723WPJ_H>!y#Nq3jL9vPWEBV39*tIPW+FT1cHx?@3p%qi7_O3ZoyF50w+@ zh{4Rdg*8Cg5xS7q&}6S{=c}xN!=g0lM6~sJ{_zTz+Y=;}38G23wPT)d;K|0`0KpI3 z=Vf#Ja^-_i2ZJqiDsWz0a!eh(UWBvMlk@1l4Xbqoe^wX&SvX)$HZ6TP1$ghX_g97I z)jp&r3PKHu0%TC|=+C3(cmml1x=qUl?KsDIrHi>Jlsus|nOzw-=Z#xs0WvYRo)P!O zz#{B;c=$5R@$D_bq*$(u0KZ7QB0_x$B}%BwN;yzn*gd)qv_Ii#sz)z}^tItx{r7t; zI6{i9JR}})(n>Jt7q9inYE`LaRB*`1`*TeH8!kcCGoLAK7UZNDumUPtr+H$==p3FE z=eoJVW9HX+0cN11)$HmdswaF)$%@_Vu6Om!j$#WwcXT=hE6?XvZG%Mb4Fz}z6mqLP z{#P!Z^|`MK>LcES14o}zA7qSqqLIisuQvt=I9r3vO*`l#=z;NI(olzr%59q) TYwDfW=PsZf^rh5zvNHY#cb}1< literal 0 HcmV?d00001 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}` }