diff --git a/pages.json b/pages.json index cf0f97f..e51e3c5 100644 --- a/pages.json +++ b/pages.json @@ -100,7 +100,8 @@ { "path": "pages/keyList/keyList", "style": { - "navigationBarTitleText": "电子钥匙" + "disableScroll": true, + "navigationBarTitleText": "电子钥匙" } }, { diff --git a/pages/bindLock/bindLock.vue b/pages/bindLock/bindLock.vue index bded195..9565c4b 100644 --- a/pages/bindLock/bindLock.vue +++ b/pages/bindLock/bindLock.vue @@ -24,6 +24,7 @@ export default { computed: { ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useUserStore, ['userInfo']), + ...mapState(useLockStore, ['lockSearch']), }, onLoad() { this.name = this.currentLockInfo.name @@ -32,7 +33,7 @@ export default { }, methods: { ...mapActions(useBluetoothStore, ['addLockUser']), - ...mapActions(useLockStore, ['getLockList']), + ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), uopdateName(data) { this.name = data.detail.value }, @@ -45,7 +46,8 @@ export default { return } uni.showLoading({ - title: '添加中' + title: '添加中', + mask: true }) const timestamp = parseInt(new Date().getTime() / 1000) const password = (Math.floor(Math.random() * 900000) + 100000).toString() @@ -114,10 +116,11 @@ export default { const { code, message } = await bindLockAdmin(params) console.log('添加锁返回', code, message) if(code === 0) { - this.getLockList({ - pageNo: 1, - pageSize: 50 + this.updateLockSearch({ + ...this.lockSearch, + pageNo: 1 }) + this.getLockList(this.lockSearch) uni.hideLoading() uni.navigateBack({ complete() { diff --git a/pages/createPassword/createPassword.vue b/pages/createPassword/createPassword.vue index fef3ce3..414a987 100644 --- a/pages/createPassword/createPassword.vue +++ b/pages/createPassword/createPassword.vue @@ -63,6 +63,7 @@ export default { }, computed: { ...mapState(useBluetoothStore, ['currentLockInfo']), + ...mapState(useLockStore, ['passwordSearch']), }, async onLoad() { this.deviceInfo = await this.getDeviceInfo() @@ -70,7 +71,7 @@ export default { }, methods: { ...mapActions(useBasicStore, ['getDeviceInfo']), - ...mapActions(useLockStore, ['getPasswordList']), + ...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']), setTime() { const now = new Date() now.setMinutes(0, 0, 0) @@ -114,13 +115,11 @@ export default { } const { code, data, message } = await createPsaawordRequest(params) if(code === 0) { - const search = { - lockStatus: this.currentLockInfo.lockStatus, - lockId: this.currentLockInfo.lockId, - pageNo: 1, - pageSize: 50 - } - this.getPasswordList(search) + this.updatePasswordSearch({ + ...this.passwordSearch, + pageNo: 1 + }) + this.getPasswordList(this.passwordSearch) uni.showModal({ title: '密码生成成功', content: `密码:${data.keyboardPwd}`, diff --git a/pages/home/home.vue b/pages/home/home.vue index cb8c630..62a817f 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -8,10 +8,10 @@ + v-model="lockSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"> - + 填加锁时,手机必须在锁旁边 @@ -71,11 +71,6 @@ export default { data() { return { - search: { - pageNo: 1, - pageSize: 50, - searchStr: '' - }, refresherTriggered: false, focus: false, penging: true, @@ -84,12 +79,13 @@ }, computed: { ...mapState(useUserStore, ['userInfo', 'isLogin']), - ...mapState(useLockStore, ['lockList', 'lockTotal']), + ...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']), ...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']), }, async onLoad() { uni.showLoading({ - title: '加载中' + title: '加载中', + mask: true }) const accountInfo = wx.getAccountInfoSync() getApp().globalData.appid = accountInfo.miniProgram.appId @@ -98,7 +94,7 @@ const token = uni.getStorageSync('token') if(token) { await this.getUserInfo() - await this.getLockList(this.search) + await this.getLockList(this.lockSearch) } else { await this.homeLogin() } @@ -108,7 +104,7 @@ methods: { timeFormat, ...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']), - ...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit']), + ...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']), ...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', 'checkSetting', 'updateKeyId']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), @@ -126,7 +122,7 @@ if(data.accessToken) { uni.setStorageSync('token', data.accessToken) that.getUserInfo() - that.getLockList(that.search) + that.getLockList(that.lockSearch) that.updateLoginStatus(true) resolve(true) } else { @@ -168,17 +164,23 @@ }, async nextPage() { if(this.lockList.length < this.lockTotal) { - this.search.pageNo++ - const { code } = await this.getLockList(this.search) + const sreach = { + ...this.lockSearch, + pageNo: this.lockSearch.pageNo + 1 + } + const { code } = await this.getLockList(search) if(code !== 0) { - this.search.pageNo-- + this.updateLockSearch(search) } } }, async refresherList() { this.refresherTriggered = true - this.search.pageNo = 1 - await this.getLockList(this.search) + this.updateLockSearch({ + ...this.lockSearch, + pageNo: 1 + }) + await this.getLockList(this.lockSearch) uni.showToast({ title: '刷新成功', icon: 'none' @@ -186,8 +188,11 @@ this.refresherTriggered = false }, async changeSearch(data) { - this.search.searchStr = data - await this.getLockList(this.search) + this.updateLockSearch({ + ...this.lockSearch, + searchStr: data + }) + await this.getLockList(this.lockSearch) }, getFocus() { this.focus = true diff --git a/pages/keyDetail/keyDetail.vue b/pages/keyDetail/keyDetail.vue index d7993b3..4aaf07f 100644 --- a/pages/keyDetail/keyDetail.vue +++ b/pages/keyDetail/keyDetail.vue @@ -24,23 +24,66 @@ 发送时间 {{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }} + 删除钥匙 @@ -67,4 +110,16 @@ page { font-size: 24rpx; color: #999999; } + +.button { + margin: 32rpx; + width: 686rpx; + height: 88rpx; + background-color: #df282d; + color: white; + text-align: center; + line-height: 88rpx; + border-radius: 44rpx; + font-weight: bold; +} diff --git a/pages/keyList/keyList.vue b/pages/keyList/keyList.vue index 1685d50..303b8ce 100644 --- a/pages/keyList/keyList.vue +++ b/pages/keyList/keyList.vue @@ -20,7 +20,12 @@ - {{ key.keyName }} + + {{ key.keyName }} + + {{ getKeyStatus(key.keyStatus) }} + + {{ key.timeText }} @@ -67,7 +72,8 @@ export default { }, async onLoad() { uni.showLoading({ - title: '加载中' + title: '加载中', + mask: true }) this.deviceInfo = await this.getDeviceInfo() this.updateKeySearch({ @@ -80,7 +86,7 @@ export default { }, methods: { ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), - ...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch']), + ...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus']), toKeyDetail(key) { this.updateCurrentKeyInfo(key) this.routeJump({ @@ -195,7 +201,10 @@ export default { } }, async changeSearch(data) { - this.keySearch.searchStr = data + this.updateKeySearch({ + ...this.keySearch, + searchStr: data + }) const { code, meesage } = await this.getKeyList(this.keySearch) }, }, @@ -262,6 +271,7 @@ page { .key-right { margin-left: 32rpx; margin-right: 32rpx; + width: 574rpx; .key-right-top { font-size: 32rpx; @@ -274,6 +284,12 @@ page { color: #999999; } } + + .key-status { + margin-left: auto; + font-size: 26rpx; + color: #63b8af; + } } .line { diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index 4961512..33b64d3 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -61,14 +61,15 @@ } }, computed: { - ...mapState(useUserStore, ['isLogin']) + ...mapState(useUserStore, ['isLogin']), + ...mapState(useLockStore, ['lockSearch']) }, async onLoad() { this.buttonInfo = await this.getButtonInfo() }, methods: { ...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']), - ...mapActions(useLockStore, ['getLockList']), + ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo', 'checkSession']), async changePhone(res) { if(res.detail.errMsg === 'getPhoneNumber:fail user deny') { @@ -91,10 +92,11 @@ }) if(code === 0) { uni.setStorageSync('token', data.accessToken) - this.getLockList({ - pageNo: 1, - pageSize: 50 + this.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 }) + this.getLockList(this.lockSearch) uni.showToast({ title: '账号切换成功', icon: 'none' diff --git a/pages/passwordDetail/passwordDetail.vue b/pages/passwordDetail/passwordDetail.vue index de74e75..7cdc813 100644 --- a/pages/passwordDetail/passwordDetail.vue +++ b/pages/passwordDetail/passwordDetail.vue @@ -25,24 +25,94 @@ {{ timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M') }} 密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。 + 删除密码 @@ -68,4 +138,16 @@ page { font-size: 24rpx; color: #999999; } + +.button { + margin: 32rpx; + width: 686rpx; + height: 88rpx; + background-color: #df282d; + color: white; + text-align: center; + line-height: 88rpx; + border-radius: 44rpx; + font-weight: bold; +} diff --git a/pages/passwordList/passwordList.vue b/pages/passwordList/passwordList.vue index 4a541ae..da16990 100644 --- a/pages/passwordList/passwordList.vue +++ b/pages/passwordList/passwordList.vue @@ -6,7 +6,7 @@ + v-model="passwordSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"> @@ -48,11 +48,6 @@ import { deletePsaawordRequest, resetPsaawordListRequest } from '@/api/keyboardP export default { data () { return { - search: { - pageNo: 1, - pageSize: 50, - searchStr: '' - }, deviceInfo: null, refresherTriggered: false, requestFinished: false, @@ -67,22 +62,26 @@ export default { computed: { ...mapState(useUserStore, ['userInfo']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), - ...mapState(useLockStore, ['passwordTotal', 'passwordList']), + ...mapState(useLockStore, ['passwordTotal', 'passwordList', 'passwordSearch']), }, async onLoad() { uni.showLoading({ - title: '加载中' + title: '加载中', + mask: true }) this.deviceInfo = await this.getDeviceInfo() - this.search.lockStatus = this.currentLockInfo.lockStatus - this.search.lockId = this.currentLockInfo.lockId - const { code, meesage } = await this.getPasswordList(this.search) + this.updatePasswordSearch({ + ...this.passwordSearch, + lockId: this.currentLockInfo.lockId, + lockStatus: this.currentLockInfo.lockStatus + }) + const { code, meesage } = await this.getPasswordList(this.passwordSearch) this.requestFinished = true uni.hideLoading() }, methods: { ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), - ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo']), + ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch']), ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword']), toPasswordDetail(password) { this.updateCurrentPasswordInfo(password) @@ -128,8 +127,11 @@ export default { title: '删除成功', icon: 'none' }) - that.search.pageNo = 1 - await that.getPasswordList(that.search) + that.updatePasswordSearch({ + ...that.passwordSearch, + pageNo: 1 + }) + await that.getPasswordList(that.passwordSearch) } else { uni.hideLoading() uni.showToast({ @@ -170,8 +172,11 @@ export default { title: '重置密码成功', icon: 'none' }) - that.search.pageNo = 1 - that.getPasswordList(that.search) + that.updatePasswordSearch({ + ...that.passwordSearch, + pageNo: 1 + }) + that.getPasswordList(that.passwordSearch) } else { uni.showToast({ title: message, @@ -195,8 +200,11 @@ export default { }, async refresherList() { this.refresherTriggered = true - this.search.pageNo = 1 - const { code, meesage } = await this.getPasswordList(this.search) + this.updatePasswordSearch({ + ...this.passwordSearch, + pageNo: 1 + }) + const { code, meesage } = await this.getPasswordList(this.passwordSearch) if(code === 0) { uni.showToast({ title: '刷新成功', @@ -206,22 +214,28 @@ export default { this.refresherTriggered = false }, async nextPage() { - if(this.passwordTotal <= this.search.pageNo * this.search.pageSize) { + if(this.passwordTotal <= this.passwordSearch.pageNo * this.passwordSearch.pageSize) { return } - const pageNo = this.search.pageNo + 1 + const pageNo = this.passwordSearch.pageNo + 1 const params = { - ...this.search, + ...this.passwordSearch, pageNo } const { code, meesage } = await this.getPasswordList(params) if(code === 0) { - this.search.pageNo = pageNo + that.updatePasswordSearch({ + ...that.passwordSearch, + pageNo + }) } }, async changeSearch(data) { - this.search.searchStr = data - const { code, meesage } = await this.getPasswordList(this.search) + this.updatePasswordSearch({ + ...this.passwordSearch, + searchStr: data + }) + const { code, meesage } = await this.getPasswordList(this.passwordSearch) }, }, } diff --git a/pages/searchDevice/searchDevice.vue b/pages/searchDevice/searchDevice.vue index 1445fcb..3a33715 100644 --- a/pages/searchDevice/searchDevice.vue +++ b/pages/searchDevice/searchDevice.vue @@ -47,7 +47,7 @@ export default { async connect(device) { uni.showLoading({ title: '连接中', - // mask: true + mask: true }) const { code: serverTimestampCode, message } = await this.updateServerTimestamp() if(serverTimestampCode !== 0) { diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index 14aa37d..3b6b6d1 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -58,17 +58,19 @@ export default { }, computed: { ...mapState(useUserStore, ['userInfo']), - ...mapState(useBluetoothStore, ['keyId', 'currentLockInfo']) + ...mapState(useBluetoothStore, ['keyId', 'currentLockInfo']), + ...mapState(useLockStore, ['lockSearch']) }, onLoad() { this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline }, methods: { ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), - ...mapActions(useLockStore, ['getLockList']), + ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), async changeUnlockApp(value) { uni.showLoading({ - title: '更新中' + title: '更新中', + mask: true }) const { code, message } = await updateLockSettingRequest({ lockId: this.currentLockInfo.lockId, @@ -100,7 +102,8 @@ export default { success: async function (res) { if (res.confirm) { uni.showLoading({ - title: '删除中' + title: '删除中', + mask: true }) if(that.currentLockInfo.userType === 110301) { const { code: resetDeviceCode } = await that.resetDevice({ @@ -114,10 +117,11 @@ export default { }) if(code === 0) { uni.hideLoading() - that.getLockList({ - pageNo: 1, - pageSize: 50 + that.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 }) + that.getLockList(that.lockSearch) uni.navigateBack({ delta: 2, complete: () => { @@ -148,10 +152,11 @@ export default { }) if(code === 0) { uni.hideLoading() - that.getLockList({ - pageNo: 1, - pageSize: 50 + that.updateLockSearch({ + ...that.lockSearch, + pageNo: 1 }) + that.getLockList(that.lockSearch) uni.navigateBack({ delta: 2, complete: () => { diff --git a/stores/lock.js b/stores/lock.js index f9da539..8071158 100644 --- a/stores/lock.js +++ b/stores/lock.js @@ -14,12 +14,24 @@ export const useLockStore = defineStore('lock', { lockList: [], // 锁总数 lockTotal: 0, + // 锁列表搜索数据 + lockSearch: { + pageNo: 1, + pageSize: 50, + searchStr: '' + }, // 密码列表 passwordList: [], // 密码总数 passwordTotal: 0, // 当前密码详情 currentPasswordInfo: {}, + // 密码列表搜索数据 + passwordSearch: { + pageNo: 1, + pageSize: 50, + searchStr: '' + }, // 电子钥匙总数 keyTotal: 0, // 电子钥匙列表 @@ -33,12 +45,18 @@ export const useLockStore = defineStore('lock', { searchStr: '', endDate: '0', startDate: '0', - keyStatus: [110401,110402], + keyStatus: [110401,110402,110412], keyRight: 0 }, } }, actions: { + updateLockSearch(search) { + this.lockSearch = search + }, + updatePasswordSearch(search) { + this.passwordSearch = search + }, updateKeySearch(search) { this.keySearch = search }, @@ -55,6 +73,17 @@ export const useLockStore = defineStore('lock', { return '普通用户' } }, + getKeyStatus(keyStatus) { + if(keyStatus === 110401) { + return '正常' + } else if(keyStatus === 110402) { + return '待接收' + } else if(keyStatus === 110412) { + return '已过期' + } else { + return '' + } + }, getTimeLimit(keyType) { if(keyType === 1) { return '永久' diff --git a/stores/user.js b/stores/user.js index 879fdc6..c074d18 100644 --- a/stores/user.js +++ b/stores/user.js @@ -37,10 +37,11 @@ export const useUserStore = defineStore('user', { if(code === 0) { uni.setStorageSync('token', data.accessToken) this.getUserInfo() - useLockStore().getLockList({ - pageNo: 1, - pageSize: 50 + useLockStore().updateLockSearch({ + ...useLockStore().lockSearch, + pageNo: 1 }) + useLockStore().getLockList(useLockStore().lockSearch) return true } else { return false