1. 修复全局列表刷新bug

2. 所有loading添加蒙层不可点击穿透
3. 密码和电子钥匙详情页添加删除功能
This commit is contained in:
范鹏 2024-08-29 14:42:16 +08:00
parent 13f45e1c26
commit 5129d3624a
13 changed files with 300 additions and 88 deletions

View File

@ -100,7 +100,8 @@
{ {
"path": "pages/keyList/keyList", "path": "pages/keyList/keyList",
"style": { "style": {
"navigationBarTitleText": "电子钥匙" "disableScroll": true,
"navigationBarTitleText": "电子钥匙"
} }
}, },
{ {

View File

@ -24,6 +24,7 @@ export default {
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useLockStore, ['lockSearch']),
}, },
onLoad() { onLoad() {
this.name = this.currentLockInfo.name this.name = this.currentLockInfo.name
@ -32,7 +33,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['addLockUser']), ...mapActions(useBluetoothStore, ['addLockUser']),
...mapActions(useLockStore, ['getLockList']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
uopdateName(data) { uopdateName(data) {
this.name = data.detail.value this.name = data.detail.value
}, },
@ -45,7 +46,8 @@ export default {
return return
} }
uni.showLoading({ uni.showLoading({
title: '添加中' title: '添加中',
mask: true
}) })
const timestamp = parseInt(new Date().getTime() / 1000) const timestamp = parseInt(new Date().getTime() / 1000)
const password = (Math.floor(Math.random() * 900000) + 100000).toString() const password = (Math.floor(Math.random() * 900000) + 100000).toString()
@ -114,10 +116,11 @@ export default {
const { code, message } = await bindLockAdmin(params) const { code, message } = await bindLockAdmin(params)
console.log('添加锁返回', code, message) console.log('添加锁返回', code, message)
if(code === 0) { if(code === 0) {
this.getLockList({ this.updateLockSearch({
pageNo: 1, ...this.lockSearch,
pageSize: 50 pageNo: 1
}) })
this.getLockList(this.lockSearch)
uni.hideLoading() uni.hideLoading()
uni.navigateBack({ uni.navigateBack({
complete() { complete() {

View File

@ -63,6 +63,7 @@ export default {
}, },
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo']), ...mapState(useBluetoothStore, ['currentLockInfo']),
...mapState(useLockStore, ['passwordSearch']),
}, },
async onLoad() { async onLoad() {
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
@ -70,7 +71,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['getDeviceInfo']), ...mapActions(useBasicStore, ['getDeviceInfo']),
...mapActions(useLockStore, ['getPasswordList']), ...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']),
setTime() { setTime() {
const now = new Date() const now = new Date()
now.setMinutes(0, 0, 0) now.setMinutes(0, 0, 0)
@ -114,13 +115,11 @@ export default {
} }
const { code, data, message } = await createPsaawordRequest(params) const { code, data, message } = await createPsaawordRequest(params)
if(code === 0) { if(code === 0) {
const search = { this.updatePasswordSearch({
lockStatus: this.currentLockInfo.lockStatus, ...this.passwordSearch,
lockId: this.currentLockInfo.lockId, pageNo: 1
pageNo: 1, })
pageSize: 50 this.getPasswordList(this.passwordSearch)
}
this.getPasswordList(search)
uni.showModal({ uni.showModal({
title: '密码生成成功', title: '密码生成成功',
content: `密码:${data.keyboardPwd}`, content: `密码:${data.keyboardPwd}`,

View File

@ -8,10 +8,10 @@
<view class="search"> <view class="search">
<up-search :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" @focus="getFocus" @blur="getBlur" <up-search :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" @focus="getFocus" @blur="getBlur"
:height="80" placeholder="搜索" :clearabled="false" @change="changeSearch" :height="80" placeholder="搜索" :clearabled="false" @change="changeSearch"
v-model="search.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"></up-search> v-model="lockSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"></up-search>
</view> </view>
<view class="lock-list" v-if="!penging"> <view class="lock-list" v-if="!penging">
<view v-if="lockList.length === 0 && search.searchStr === '' && !focus"> <view v-if="lockList.length === 0 && lockSearch.searchStr === '' && !focus">
<image src="/static/images/icon_add_round.png" mode="aspectFill" class="button-add-big" <image src="/static/images/icon_add_round.png" mode="aspectFill" class="button-add-big"
@click="toSearchDevice"></image> @click="toSearchDevice"></image>
<view class="text">填加锁时手机必须在锁旁边</view> <view class="text">填加锁时手机必须在锁旁边</view>
@ -71,11 +71,6 @@
export default { export default {
data() { data() {
return { return {
search: {
pageNo: 1,
pageSize: 50,
searchStr: ''
},
refresherTriggered: false, refresherTriggered: false,
focus: false, focus: false,
penging: true, penging: true,
@ -84,12 +79,13 @@
}, },
computed: { computed: {
...mapState(useUserStore, ['userInfo', 'isLogin']), ...mapState(useUserStore, ['userInfo', 'isLogin']),
...mapState(useLockStore, ['lockList', 'lockTotal']), ...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']),
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']), ...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']),
}, },
async onLoad() { async onLoad() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中',
mask: true
}) })
const accountInfo = wx.getAccountInfoSync() const accountInfo = wx.getAccountInfoSync()
getApp().globalData.appid = accountInfo.miniProgram.appId getApp().globalData.appid = accountInfo.miniProgram.appId
@ -98,7 +94,7 @@
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
if(token) { if(token) {
await this.getUserInfo() await this.getUserInfo()
await this.getLockList(this.search) await this.getLockList(this.lockSearch)
} else { } else {
await this.homeLogin() await this.homeLogin()
} }
@ -108,7 +104,7 @@
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']), ...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']),
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit']), ...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']),
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', ...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo',
'checkSetting', 'updateKeyId']), 'checkSetting', 'updateKeyId']),
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
@ -126,7 +122,7 @@
if(data.accessToken) { if(data.accessToken) {
uni.setStorageSync('token', data.accessToken) uni.setStorageSync('token', data.accessToken)
that.getUserInfo() that.getUserInfo()
that.getLockList(that.search) that.getLockList(that.lockSearch)
that.updateLoginStatus(true) that.updateLoginStatus(true)
resolve(true) resolve(true)
} else { } else {
@ -168,17 +164,23 @@
}, },
async nextPage() { async nextPage() {
if(this.lockList.length < this.lockTotal) { if(this.lockList.length < this.lockTotal) {
this.search.pageNo++ const sreach = {
const { code } = await this.getLockList(this.search) ...this.lockSearch,
pageNo: this.lockSearch.pageNo + 1
}
const { code } = await this.getLockList(search)
if(code !== 0) { if(code !== 0) {
this.search.pageNo-- this.updateLockSearch(search)
} }
} }
}, },
async refresherList() { async refresherList() {
this.refresherTriggered = true this.refresherTriggered = true
this.search.pageNo = 1 this.updateLockSearch({
await this.getLockList(this.search) ...this.lockSearch,
pageNo: 1
})
await this.getLockList(this.lockSearch)
uni.showToast({ uni.showToast({
title: '刷新成功', title: '刷新成功',
icon: 'none' icon: 'none'
@ -186,8 +188,11 @@
this.refresherTriggered = false this.refresherTriggered = false
}, },
async changeSearch(data) { async changeSearch(data) {
this.search.searchStr = data this.updateLockSearch({
await this.getLockList(this.search) ...this.lockSearch,
searchStr: data
})
await this.getLockList(this.lockSearch)
}, },
getFocus() { getFocus() {
this.focus = true this.focus = true

View File

@ -24,23 +24,66 @@
<view class="item-title">发送时间</view> <view class="item-title">发送时间</view>
<view class="item-content">{{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }}</view> <view class="item-content">{{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }}</view>
</view> </view>
<view class="button" @click="deleteKey">删除钥匙</view>
</view> </view>
</template> </template>
<script> <script>
import { mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { deleteKeyRequest } from '@/api/key'
export default { export default {
data () { data () {
return {} return {}
}, },
computed: { computed: {
...mapState(useLockStore, ['currentKeyInfo']), ...mapState(useLockStore, ['currentKeyInfo', 'keySearch']),
}, },
methods: { methods: {
timeFormat timeFormat,
...mapActions(useLockStore, ['updateKeySearch', 'getKeyList']),
async deleteKey () {
const that = this
uni.showModal({
title: '提示',
content: '确定要删除该钥匙',
async success(res) {
if(res.confirm) {
uni.showLoading({
title: '删除中',
mask: true
})
const { code: requestCode, message } = await deleteKeyRequest({
keyId: that.currentKeyInfo.keyId
})
if(requestCode === 0) {
uni.hideLoading()
that.updateKeySearch({
...that.keySearch,
pageNo: 1
})
await that.getKeyList(that.keySearch)
uni.navigateBack({
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
} else {
uni.hideLoading()
uni.showToast({
title: message,
icon: 'none'
})
}
}
}
})
}
}, },
} }
</script> </script>
@ -67,4 +110,16 @@ page {
font-size: 24rpx; font-size: 24rpx;
color: #999999; 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;
}
</style> </style>

View File

@ -20,7 +20,12 @@
<view class="key" @click="toKeyDetail(key)"> <view class="key" @click="toKeyDetail(key)">
<image class="key-left" :src="key.headUrl" mode="aspectFill"></image> <image class="key-left" :src="key.headUrl" mode="aspectFill"></image>
<view class="key-right"> <view class="key-right">
<view class="key-right-top">{{ key.keyName }}</view> <view style="display: flex; align-items: center">
<view class="key-right-top">{{ key.keyName }}</view>
<view class="key-status" :style="{ color: (key.keyStatus === 110401) ? '#63b8af' : '#df282d' }">
{{ getKeyStatus(key.keyStatus) }}
</view>
</view>
<view class="key-right-bottom">{{ key.timeText }}</view> <view class="key-right-bottom">{{ key.timeText }}</view>
</view> </view>
</view> </view>
@ -67,7 +72,8 @@ export default {
}, },
async onLoad() { async onLoad() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中',
mask: true
}) })
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
this.updateKeySearch({ this.updateKeySearch({
@ -80,7 +86,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch']), ...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus']),
toKeyDetail(key) { toKeyDetail(key) {
this.updateCurrentKeyInfo(key) this.updateCurrentKeyInfo(key)
this.routeJump({ this.routeJump({
@ -195,7 +201,10 @@ export default {
} }
}, },
async changeSearch(data) { async changeSearch(data) {
this.keySearch.searchStr = data this.updateKeySearch({
...this.keySearch,
searchStr: data
})
const { code, meesage } = await this.getKeyList(this.keySearch) const { code, meesage } = await this.getKeyList(this.keySearch)
}, },
}, },
@ -262,6 +271,7 @@ page {
.key-right { .key-right {
margin-left: 32rpx; margin-left: 32rpx;
margin-right: 32rpx; margin-right: 32rpx;
width: 574rpx;
.key-right-top { .key-right-top {
font-size: 32rpx; font-size: 32rpx;
@ -274,6 +284,12 @@ page {
color: #999999; color: #999999;
} }
} }
.key-status {
margin-left: auto;
font-size: 26rpx;
color: #63b8af;
}
} }
.line { .line {

View File

@ -61,14 +61,15 @@
} }
}, },
computed: { computed: {
...mapState(useUserStore, ['isLogin']) ...mapState(useUserStore, ['isLogin']),
...mapState(useLockStore, ['lockSearch'])
}, },
async onLoad() { async onLoad() {
this.buttonInfo = await this.getButtonInfo() this.buttonInfo = await this.getButtonInfo()
}, },
methods: { methods: {
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']), ...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
...mapActions(useLockStore, ['getLockList']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo', 'checkSession']), ...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo', 'checkSession']),
async changePhone(res) { async changePhone(res) {
if(res.detail.errMsg === 'getPhoneNumber:fail user deny') { if(res.detail.errMsg === 'getPhoneNumber:fail user deny') {
@ -91,10 +92,11 @@
}) })
if(code === 0) { if(code === 0) {
uni.setStorageSync('token', data.accessToken) uni.setStorageSync('token', data.accessToken)
this.getLockList({ this.updateLockSearch({
pageNo: 1, ...that.lockSearch,
pageSize: 50 pageNo: 1
}) })
this.getLockList(this.lockSearch)
uni.showToast({ uni.showToast({
title: '账号切换成功', title: '账号切换成功',
icon: 'none' icon: 'none'

View File

@ -25,24 +25,94 @@
<view class="item-content">{{ timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M') }}</view> <view class="item-content">{{ timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M') }}</view>
</view> </view>
<view class="tips">密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效</view> <view class="tips">密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效</view>
<view class="button" @click="deletePassword">删除密码</view>
</view> </view>
</template> </template>
<script> <script>
import { mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { deletePsaawordRequest } from '@/api/keyboardPwd'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user'
export default { export default {
data () { data () {
return {} return {}
}, },
computed: { computed: {
...mapState(useLockStore, ['currentPasswordInfo']), ...mapState(useLockStore, ['currentPasswordInfo', 'passwordSearch']),
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useUserStore, ['userInfo']),
}, },
methods: { methods: {
timeFormat timeFormat,
}, ...mapActions(useBluetoothStore, ['setLockPassword']),
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
async deletePassword () {
const that = this
uni.showModal({
title: '提示',
content: '确定要删除该密码',
async success(res) {
if(res.confirm) {
uni.showLoading({
title: '删除中',
mask: true
})
const timestamp = parseInt(new Date().getTime() / 1000)
const { code } = await that.setLockPassword({
keyId: that.keyId.toString(),
uid: that.userInfo.uid.toString(),
pwdNo: that.currentPasswordInfo.pwdUserNo,
operate: 3,
isAdmin: that.currentPasswordInfo.pwdRight,
pwd: that.currentPasswordInfo.keyboardPwd,
userCountLimit: 0xFFFF,
startTime: timestamp,
endTime: timestamp
})
if(code === 0) {
const { code: requestCode, message } = await deletePsaawordRequest({
lockId: that.currentLockInfo.lockId,
keyboardPwdId: that.currentPasswordInfo.keyboardPwdId,
deleteType: 1
})
if(requestCode === 0) {
uni.hideLoading()
that.updatePasswordSearch({
...that.passwordSearch,
pageNo: 1
})
that.getPasswordList(that.passwordSearch)
uni.navigateBack({
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
} else {
uni.hideLoading()
uni.showToast({
title: message,
icon: 'none'
})
}
} else {
uni.hideLoading()
uni.showToast({
title: '删除失败,请保持在锁附近',
icon: 'none'
})
}
}
}
})
}
}
} }
</script> </script>
@ -68,4 +138,16 @@ page {
font-size: 24rpx; font-size: 24rpx;
color: #999999; 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;
}
</style> </style>

View File

@ -6,7 +6,7 @@
<view class="search"> <view class="search">
<up-search shape="square" :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" :height="80" placeholder="搜索" <up-search shape="square" :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" :height="80" placeholder="搜索"
:clearabled="false" @change="changeSearch" :clearabled="false" @change="changeSearch"
v-model="search.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"></up-search> v-model="passwordSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"></up-search>
</view> </view>
<view style="padding: 32rpx 0 calc(env(safe-area-inset-bottom) + 250rpx) 0"> <view style="padding: 32rpx 0 calc(env(safe-area-inset-bottom) + 250rpx) 0">
<view v-if="passwordList.length === 0 && requestFinished"> <view v-if="passwordList.length === 0 && requestFinished">
@ -48,11 +48,6 @@ import { deletePsaawordRequest, resetPsaawordListRequest } from '@/api/keyboardP
export default { export default {
data () { data () {
return { return {
search: {
pageNo: 1,
pageSize: 50,
searchStr: ''
},
deviceInfo: null, deviceInfo: null,
refresherTriggered: false, refresherTriggered: false,
requestFinished: false, requestFinished: false,
@ -67,22 +62,26 @@ export default {
computed: { computed: {
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useLockStore, ['passwordTotal', 'passwordList']), ...mapState(useLockStore, ['passwordTotal', 'passwordList', 'passwordSearch']),
}, },
async onLoad() { async onLoad() {
uni.showLoading({ uni.showLoading({
title: '加载中' title: '加载中',
mask: true
}) })
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
this.search.lockStatus = this.currentLockInfo.lockStatus this.updatePasswordSearch({
this.search.lockId = this.currentLockInfo.lockId ...this.passwordSearch,
const { code, meesage } = await this.getPasswordList(this.search) lockId: this.currentLockInfo.lockId,
lockStatus: this.currentLockInfo.lockStatus
})
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
this.requestFinished = true this.requestFinished = true
uni.hideLoading() uni.hideLoading()
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo']), ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch']),
...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword']), ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword']),
toPasswordDetail(password) { toPasswordDetail(password) {
this.updateCurrentPasswordInfo(password) this.updateCurrentPasswordInfo(password)
@ -128,8 +127,11 @@ export default {
title: '删除成功', title: '删除成功',
icon: 'none' icon: 'none'
}) })
that.search.pageNo = 1 that.updatePasswordSearch({
await that.getPasswordList(that.search) ...that.passwordSearch,
pageNo: 1
})
await that.getPasswordList(that.passwordSearch)
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@ -170,8 +172,11 @@ export default {
title: '重置密码成功', title: '重置密码成功',
icon: 'none' icon: 'none'
}) })
that.search.pageNo = 1 that.updatePasswordSearch({
that.getPasswordList(that.search) ...that.passwordSearch,
pageNo: 1
})
that.getPasswordList(that.passwordSearch)
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,
@ -195,8 +200,11 @@ export default {
}, },
async refresherList() { async refresherList() {
this.refresherTriggered = true this.refresherTriggered = true
this.search.pageNo = 1 this.updatePasswordSearch({
const { code, meesage } = await this.getPasswordList(this.search) ...this.passwordSearch,
pageNo: 1
})
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
if(code === 0) { if(code === 0) {
uni.showToast({ uni.showToast({
title: '刷新成功', title: '刷新成功',
@ -206,22 +214,28 @@ export default {
this.refresherTriggered = false this.refresherTriggered = false
}, },
async nextPage() { async nextPage() {
if(this.passwordTotal <= this.search.pageNo * this.search.pageSize) { if(this.passwordTotal <= this.passwordSearch.pageNo * this.passwordSearch.pageSize) {
return return
} }
const pageNo = this.search.pageNo + 1 const pageNo = this.passwordSearch.pageNo + 1
const params = { const params = {
...this.search, ...this.passwordSearch,
pageNo pageNo
} }
const { code, meesage } = await this.getPasswordList(params) const { code, meesage } = await this.getPasswordList(params)
if(code === 0) { if(code === 0) {
this.search.pageNo = pageNo that.updatePasswordSearch({
...that.passwordSearch,
pageNo
})
} }
}, },
async changeSearch(data) { async changeSearch(data) {
this.search.searchStr = data this.updatePasswordSearch({
const { code, meesage } = await this.getPasswordList(this.search) ...this.passwordSearch,
searchStr: data
})
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
}, },
}, },
} }

View File

@ -47,7 +47,7 @@ export default {
async connect(device) { async connect(device) {
uni.showLoading({ uni.showLoading({
title: '连接中', title: '连接中',
// mask: true mask: true
}) })
const { code: serverTimestampCode, message } = await this.updateServerTimestamp() const { code: serverTimestampCode, message } = await this.updateServerTimestamp()
if(serverTimestampCode !== 0) { if(serverTimestampCode !== 0) {

View File

@ -58,17 +58,19 @@ export default {
}, },
computed: { computed: {
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useBluetoothStore, ['keyId', 'currentLockInfo']) ...mapState(useBluetoothStore, ['keyId', 'currentLockInfo']),
...mapState(useLockStore, ['lockSearch'])
}, },
onLoad() { onLoad() {
this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
...mapActions(useLockStore, ['getLockList']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
async changeUnlockApp(value) { async changeUnlockApp(value) {
uni.showLoading({ uni.showLoading({
title: '更新中' title: '更新中',
mask: true
}) })
const { code, message } = await updateLockSettingRequest({ const { code, message } = await updateLockSettingRequest({
lockId: this.currentLockInfo.lockId, lockId: this.currentLockInfo.lockId,
@ -100,7 +102,8 @@ export default {
success: async function (res) { success: async function (res) {
if (res.confirm) { if (res.confirm) {
uni.showLoading({ uni.showLoading({
title: '删除中' title: '删除中',
mask: true
}) })
if(that.currentLockInfo.userType === 110301) { if(that.currentLockInfo.userType === 110301) {
const { code: resetDeviceCode } = await that.resetDevice({ const { code: resetDeviceCode } = await that.resetDevice({
@ -114,10 +117,11 @@ export default {
}) })
if(code === 0) { if(code === 0) {
uni.hideLoading() uni.hideLoading()
that.getLockList({ that.updateLockSearch({
pageNo: 1, ...that.lockSearch,
pageSize: 50 pageNo: 1
}) })
that.getLockList(that.lockSearch)
uni.navigateBack({ uni.navigateBack({
delta: 2, delta: 2,
complete: () => { complete: () => {
@ -148,10 +152,11 @@ export default {
}) })
if(code === 0) { if(code === 0) {
uni.hideLoading() uni.hideLoading()
that.getLockList({ that.updateLockSearch({
pageNo: 1, ...that.lockSearch,
pageSize: 50 pageNo: 1
}) })
that.getLockList(that.lockSearch)
uni.navigateBack({ uni.navigateBack({
delta: 2, delta: 2,
complete: () => { complete: () => {

View File

@ -14,12 +14,24 @@ export const useLockStore = defineStore('lock', {
lockList: [], lockList: [],
// 锁总数 // 锁总数
lockTotal: 0, lockTotal: 0,
// 锁列表搜索数据
lockSearch: {
pageNo: 1,
pageSize: 50,
searchStr: ''
},
// 密码列表 // 密码列表
passwordList: [], passwordList: [],
// 密码总数 // 密码总数
passwordTotal: 0, passwordTotal: 0,
// 当前密码详情 // 当前密码详情
currentPasswordInfo: {}, currentPasswordInfo: {},
// 密码列表搜索数据
passwordSearch: {
pageNo: 1,
pageSize: 50,
searchStr: ''
},
// 电子钥匙总数 // 电子钥匙总数
keyTotal: 0, keyTotal: 0,
// 电子钥匙列表 // 电子钥匙列表
@ -33,12 +45,18 @@ export const useLockStore = defineStore('lock', {
searchStr: '', searchStr: '',
endDate: '0', endDate: '0',
startDate: '0', startDate: '0',
keyStatus: [110401,110402], keyStatus: [110401,110402,110412],
keyRight: 0 keyRight: 0
}, },
} }
}, },
actions: { actions: {
updateLockSearch(search) {
this.lockSearch = search
},
updatePasswordSearch(search) {
this.passwordSearch = search
},
updateKeySearch(search) { updateKeySearch(search) {
this.keySearch = search this.keySearch = search
}, },
@ -55,6 +73,17 @@ export const useLockStore = defineStore('lock', {
return '普通用户' return '普通用户'
} }
}, },
getKeyStatus(keyStatus) {
if(keyStatus === 110401) {
return '正常'
} else if(keyStatus === 110402) {
return '待接收'
} else if(keyStatus === 110412) {
return '已过期'
} else {
return ''
}
},
getTimeLimit(keyType) { getTimeLimit(keyType) {
if(keyType === 1) { if(keyType === 1) {
return '永久' return '永久'

View File

@ -37,10 +37,11 @@ export const useUserStore = defineStore('user', {
if(code === 0) { if(code === 0) {
uni.setStorageSync('token', data.accessToken) uni.setStorageSync('token', data.accessToken)
this.getUserInfo() this.getUserInfo()
useLockStore().getLockList({ useLockStore().updateLockSearch({
pageNo: 1, ...useLockStore().lockSearch,
pageSize: 50 pageNo: 1
}) })
useLockStore().getLockList(useLockStore().lockSearch)
return true return true
} else { } else {
return false return false