Merge branch 'fanpeng' into 'master'

1. 在部分蓝牙操作后断开蓝牙连接

See merge request StarlockTeam/wx-starlock!6
This commit is contained in:
范鹏 2024-09-06 06:22:06 +00:00
commit 99d98cd08d
21 changed files with 338 additions and 111 deletions

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__933D519", "appid" : "__UNI__933D519",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "2", "versionCode" : "7",
"transformPx" : false, "transformPx" : false,
/* */ /* */
"mp-weixin" : { "mp-weixin" : {

View File

@ -33,7 +33,8 @@ export default {
console.log(this.name) console.log(this.name)
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['addLockUser']), ...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName',
'closeAllBluetooth', 'initAndListenBluetooth']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useBasicStore, ['backAndToast']), ...mapActions(useBasicStore, ['backAndToast']),
uopdateName(data) { uopdateName(data) {
@ -73,6 +74,10 @@ export default {
password password
}) })
if(addUserCode === 0) { if(addUserCode === 0) {
this.closeBluetoothConnection()
this.updateBindedDeviceName(this.currentLockInfo.name)
this.closeAllBluetooth()
this.initAndListenBluetooth()
} else if(addUserCode === -1) { } else if(addUserCode === -1) {
uni.hideLoading() uni.hideLoading()
this.backAndToast('添加失败,请重试') this.backAndToast('添加失败,请重试')
@ -120,8 +125,10 @@ export default {
pageNo: 1 pageNo: 1
}) })
this.getLockList(this.lockSearch) this.getLockList(this.lockSearch)
uni.hideLoading() setTimeout(() => {
this.backAndToast('添加成功') uni.hideLoading()
this.backAndToast('添加成功')
}, 1000)
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({

View File

@ -22,12 +22,10 @@
<view class="group-name-text">{{group.groupName}}</view> <view class="group-name-text">{{group.groupName}}</view>
<view class="group-name-line"></view> <view class="group-name-line"></view>
</view> </view>
<up-swipe-action class="lock"> <up-swipe-action>
<up-swipe-action-item class="lock" :ref="'swipeItem' + grounIndex" :options="options" v-for="(lock, <up-swipe-action-item class="lock" :ref="'swipeItem' + grounIndex" :options="options" v-for="(lock,
lockIndex) lockIndex) in group.lockList" :key="lock.lockId" :threshold="50" @click="deleteLock(lock,
in grounIndex, lockIndex)">
group.lockList"
:key="lock.lockId" :threshold="50" @click="deleteLock(lock, grounIndex, lockIndex)">
<view class="lock" @click="toLockDeatil(lock)"> <view class="lock" @click="toLockDeatil(lock)">
<view class="lock-top"> <view class="lock-top">
<image class="lock-image-lock" src="/static/images/icon_lock.png"></image> <image class="lock-image-lock" src="/static/images/icon_lock.png"></image>
@ -50,7 +48,8 @@
</view> </view>
</view> </view>
<view class="lock-time" <view class="lock-time"
:style="{padding: lock.keyStatus === 110401 && !lock.days ? '12rpx 24rpx 0 24rpx' :style="{padding: lock.keyStatus === 110401 && !lock.days &&
lock.lockSetting.remoteUnlock === 0 ? '12rpx 24rpx 0 24rpx'
:'6rpx 24rpx 0 24rpx'}"> :'6rpx 24rpx 0 24rpx'}">
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{ <view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
getTimeLimit(lock.keyType) }}</view> getTimeLimit(lock.keyType) }}</view>
@ -129,25 +128,39 @@
mask: true mask: true
}) })
const accountInfo = uni.getAccountInfoSync() const accountInfo = uni.getAccountInfoSync()
console.log(accountInfo)
getApp().globalData.appid = accountInfo.miniProgram.appId getApp().globalData.appid = accountInfo.miniProgram.appId
getApp().globalData.envVersion = accountInfo.miniProgram.envVersion getApp().globalData.envVersion = accountInfo.miniProgram.envVersion
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
if(token) { if(token) {
this.getLockList(this.lockSearch) await Promise.all([
await this.getUserInfo() this.getLockList(this.lockSearch),
this.getUserInfo()
]).then((res) => {
this.penging = false
uni.hideLoading()
const list = uni.getStorageSync('lockList')
const userInfo = uni.getStorageSync('userInfo')
if(res[0].code === -1 && res[1] === -1 && list && userInfo) {
uni.showToast({
title: '网络访问失败,请检查网络是否正常',
icon: 'none'
})
this.updateLockList(list)
this.updateUserInfo(userInfo)
this.updateLoginStatus(true)
}
})
} else { } else {
await this.homeLogin() await this.homeLogin()
this.penging = false
uni.hideLoading()
} }
this.penging = false
uni.hideLoading()
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']), ...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']),
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']), ...mapActions(useLockStore, ['getLockList', 'updateLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']),
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', ...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo',
'checkSetting', 'updateKeyId', 'resetDevice']), 'checkSetting', 'updateKeyId', 'resetDevice']),
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
@ -186,7 +199,7 @@
authUid: that.userInfo.uid.toString(), authUid: that.userInfo.uid.toString(),
keyId: that.keyId.toString() keyId: that.keyId.toString()
}) })
if(resetDeviceCode === 0) { if(resetDeviceCode === 0 || resetDeviceCode === -2) {
const { code, message } = await deleteLockRequest({ const { code, message } = await deleteLockRequest({
lockId: that.currentLockInfo.lockId lockId: that.currentLockInfo.lockId
}) })
@ -208,14 +221,12 @@
icon: 'none' icon: 'none'
}) })
} }
} else if(code === -1) { } else if(resetDeviceCode === -1) {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
title: '删除失败,请保持在锁附近', title: '删除失败,请保持在锁附近',
icon: 'none' icon: 'none'
}) })
} else {
uni.hideLoading()
} }
} else { } else {
const { code } = await deleteKeyRequest({ const { code } = await deleteKeyRequest({
@ -343,21 +354,33 @@
} }
const { code } = await this.getLockList(search) const { code } = await this.getLockList(search)
if(code !== 0) { if(code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
this.updateLockSearch(search) this.updateLockSearch(search)
} }
} }
}, },
async refresherList() { async refresherList() {
this.refresherTriggered = true this.refresherTriggered = true
this.getUserInfo()
this.updateLockSearch({ this.updateLockSearch({
...this.lockSearch, ...this.lockSearch,
pageNo: 1 pageNo: 1
}) })
await this.getLockList(this.lockSearch) const { code, message } = await this.getLockList(this.lockSearch)
uni.showToast({ if(code === 0) {
title: '刷新成功', uni.showToast({
icon: 'none' title: '刷新成功',
}) icon: 'none'
})
} else {
uni.showToast({
title: message,
icon: 'none'
})
}
this.refresherTriggered = false this.refresherTriggered = false
}, },
async changeSearch(data) { async changeSearch(data) {
@ -391,7 +414,7 @@
} }
}, },
async toLockDeatil(lock) { async toLockDeatil(lock) {
if(this.bluetoothStatus !== 0) { if(!(this.bluetoothStatus === 0 || this.bluetoothStatus === -1)) {
this.getBluetoothStatus() this.getBluetoothStatus()
return return
} }
@ -442,6 +465,11 @@ page {
.u-swipe-action { .u-swipe-action {
overflow: inherit !important; overflow: inherit !important;
padding-bottom: 32rpx;
width: 672rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
} }
.u-swipe-action-item { .u-swipe-action-item {
@ -607,6 +635,7 @@ page {
} }
.lock-status { .lock-status {
margin-top: 5rpx;
margin-left: 24rpx; margin-left: 24rpx;
color: #FFFFFF; color: #FFFFFF;
border-radius: 8rpx; border-radius: 8rpx;

View File

@ -18,7 +18,8 @@
<up-swipe-action-item ref="swipeItem" :options="options" v-for="(key, index) in keyList" <up-swipe-action-item ref="swipeItem" :options="options" v-for="(key, index) in keyList"
:key="key.keyboardPwdId" :threshold="50" @click="deleteKey(key)"> :key="key.keyboardPwdId" :threshold="50" @click="deleteKey(key)">
<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 === '' ? '/static/images/icon_user.png' : key.headUrl"
mode="aspectFill"></image>
<view class="key-right"> <view class="key-right">
<view style="display: flex;"> <view style="display: flex;">
<view class="key-right-top">{{ key.keyName }}</view> <view class="key-right-top">{{ key.keyName }}</view>
@ -95,13 +96,22 @@ export default {
...this.keySearch, ...this.keySearch,
lockId: this.currentLockInfo.lockId lockId: this.currentLockInfo.lockId
}) })
const { code, meesage } = await this.getKeyList(this.keySearch) const { code, message } = await this.getKeyList(this.keySearch)
this.requestFinished = true
uni.hideLoading() uni.hideLoading()
this.requestFinished = true
if(code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
},
onUnload() {
this.clearList('key')
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus']), ...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus', 'clearList']),
changeRadio() { changeRadio() {
this.checked = !this.checked this.checked = !this.checked
}, },
@ -238,12 +248,17 @@ export default {
...this.keySearch, ...this.keySearch,
pageNo: 1 pageNo: 1
}) })
const { code, meesage } = await this.getKeyList(this.keySearch) const { code, message } = await this.getKeyList(this.keySearch)
if(code === 0) { if(code === 0) {
uni.showToast({ uni.showToast({
title: '刷新成功', title: '刷新成功',
icon: 'none' icon: 'none'
}) })
} else {
uni.showToast({
title: message,
icon: 'none'
})
} }
this.refresherTriggered = false this.refresherTriggered = false
}, },
@ -256,12 +271,17 @@ export default {
...this.keySearch, ...this.keySearch,
pageNo pageNo
} }
const { code, meesage } = await this.getKeyList(params) const { code, message } = await this.getKeyList(params)
if(code === 0) { if(code === 0) {
this.updateKeySearch({ this.updateKeySearch({
...this.keySearch, ...this.keySearch,
pageNo pageNo
}) })
} else {
uni.showToast({
title: message,
icon: 'none'
})
} }
}, },
async changeSearch(data) { async changeSearch(data) {
@ -269,7 +289,13 @@ export default {
...this.keySearch, ...this.keySearch,
searchStr: data searchStr: data
}) })
const { code, meesage } = await this.getKeyList(this.keySearch) const { code, message } = await this.getKeyList(this.keySearch)
if(code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}, },
}, },
} }
@ -338,7 +364,7 @@ page {
width: 574rpx; width: 574rpx;
.key-right-top { .key-right-top {
max-width: 450rpx; max-width: 400rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
padding-bottom: 6rpx; padding-bottom: 6rpx;

View File

@ -51,6 +51,17 @@
<view class="setting-text">设置</view> <view class="setting-text">设置</view>
<image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image> <image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image>
</view> </view>
<up-popup :show="show" @close="closePopup" mode="center" :closeOnClickOverlay="true" bgColor="transparent">
<view class="popup" @click="closePopup">
<image class="popup-background" :src="type === 'close' ? '/static/images/background_close_door.png' :
'/static/images/background_open_door.png'"
mode="aspectFill"></image>
<view>
<view class="popup-name">{{ currentLockInfo.lockAlias }}</view>
<view class="popup-time">{{ timeFormat('', 'mm/dd h:M') }}</view>
</view>
</view>
</up-popup>
</view> </view>
</template> </template>
@ -70,7 +81,9 @@ export default {
return { return {
time: 0, time: 0,
onlineToken: '0', onlineToken: '0',
pending: false pending: false,
show: false,
type: ''
} }
}, },
computed: { computed: {
@ -85,9 +98,13 @@ export default {
this.getServeTime() this.getServeTime()
}, },
methods: { methods: {
timeFormat,
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']), ...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']), ...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp', 'closeBluetoothConnection']),
...mapActions(useBasicStore, ['routeJump', 'backAndToast']), ...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
closePopup() {
this.show = false
},
powerTip() { powerTip() {
const that = this const that = this
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M') const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
@ -123,13 +140,25 @@ export default {
if(this.pending) { if(this.pending) {
return return
} }
if(this.currentLockInfo.lockSetting.appUnlockOnline) {
const netWork = await this.getNetworkType()
if(!netWork) {
uni.showToast({
title: '网络访问失败,请检查网络是否正常',
icon: 'none'
})
return
}
}
uni.vibrateLong() uni.vibrateLong()
this.pending = true this.pending = true
this.$refs.loading.open() this.$refs.loading.open()
uni.showToast({ if(type === 'close') {
title: `正在尝试${type === 'close' ? '关' : '开'}锁……`, uni.showToast({
icon: 'none' title: `正在尝试闭锁……`,
}) icon: 'none'
})
}
if(this.currentLockInfo.lockSetting.appUnlockOnline) { if(this.currentLockInfo.lockSetting.appUnlockOnline) {
const result = await this.getNetToken() const result = await this.getNetToken()
if(!result) { if(!result) {
@ -151,11 +180,13 @@ export default {
openTime: parseInt(new Date().getTime() / 1000) + this.time, openTime: parseInt(new Date().getTime() / 1000) + this.time,
onlineToken: this.onlineToken onlineToken: this.onlineToken
}) })
this.closeBluetoothConnection()
if(code === 0) { if(code === 0) {
uni.showToast({ this.show = true
title: `${type === 'close' ? '关' : '开'}锁成功`, this.type = type
icon: 'none' setTimeout(() => {
}) this.show = false
}, 3000)
if(this.currentLockInfo.keyType === 3) { if(this.currentLockInfo.keyType === 3) {
const { code: deleteKeyCode } = await deleteKeyRequest({ const { code: deleteKeyCode } = await deleteKeyRequest({
keyId: this.keyId keyId: this.keyId
@ -188,6 +219,45 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.popup {
display: flex;
position: relative;
width: 400rpx;
height: 389rpx;
text-align: center;
flex-wrap: wrap;
.popup-background {
z-index: -1;
width: 400rpx;
height: 389rpx;
position: absolute;
}
.popup-name {
margin-left: 30rpx;
z-index: 9;
margin-top: 180rpx;
color: #676b6d;
width: 340rpx;
max-height: 80rpx;
line-height: 40rpx;
word-break: break-all;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
white-space: normal;
}
.popup-time {
margin-top: 10rpx;
width: 400rpx;
}
}
.days { .days {
line-height: 60rpx; line-height: 60rpx;
background: #faecc9; background: #faecc9;

View File

@ -102,6 +102,8 @@
uni.setStorageSync('envVersion', env.key) uni.setStorageSync('envVersion', env.key)
uni.removeStorageSync('token') uni.removeStorageSync('token')
uni.removeStorageSync('openid') uni.removeStorageSync('openid')
uni.removeStorageSync('userInfo')
uni.removeStorageSync('lockList')
uni.reLaunch({ uni.reLaunch({
url: '/pages/home/home' url: '/pages/home/home'
}) })
@ -126,6 +128,8 @@
openid openid
}) })
if(code === 0) { if(code === 0) {
uni.removeStorageSync('userInfo')
uni.removeStorageSync('lockList')
uni.setStorageSync('token', data.accessToken) uni.setStorageSync('token', data.accessToken)
this.updateLockSearch({ this.updateLockSearch({
...this.lockSearch, ...this.lockSearch,

View File

@ -52,7 +52,7 @@ export default {
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useBluetoothStore, ['setLockPassword']), ...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']),
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']), ...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
...mapActions(useBasicStore, ['backAndToast']), ...mapActions(useBasicStore, ['backAndToast']),
async deletePassword () { async deletePassword () {
@ -78,6 +78,7 @@ export default {
startTime: timestamp, startTime: timestamp,
endTime: timestamp endTime: timestamp
}) })
that.closeBluetoothConnection()
if(code === 0) { if(code === 0) {
const { code: requestCode, message } = await deletePsaawordRequest({ const { code: requestCode, message } = await deletePsaawordRequest({
lockId: that.currentLockInfo.lockId, lockId: that.currentLockInfo.lockId,
@ -105,8 +106,6 @@ export default {
title: '删除失败,请保持在锁附近', title: '删除失败,请保持在锁附近',
icon: 'none' icon: 'none'
}) })
} else {
uni.hideLoading()
} }
} }
} }

View File

@ -18,7 +18,7 @@
<up-swipe-action-item ref="swipeItem" :options="options" v-for="(password, index) in passwordList" <up-swipe-action-item ref="swipeItem" :options="options" v-for="(password, index) in passwordList"
:key="password.keyboardPwdId" :threshold="50" @click="deletePassword(password)"> :key="password.keyboardPwdId" :threshold="50" @click="deletePassword(password)">
<view class="password" @click="toPasswordDetail(password)"> <view class="password" @click="toPasswordDetail(password)">
<image class="password-left" src="/static/images/icon_lock_transparent.png" mode="aspectFill"></image> <image class="password-left" src="/static/images/icon_password.png" mode="aspectFill"></image>
<view class="password-right"> <view class="password-right">
<view style="display: flex; align-items: center"> <view style="display: flex; align-items: center">
<view class="password-right-top">{{ password.keyboardPwdName }}</view> <view class="password-right-top">{{ password.keyboardPwdName }}</view>
@ -80,14 +80,23 @@ export default {
lockId: this.currentLockInfo.lockId, lockId: this.currentLockInfo.lockId,
lockStatus: this.currentLockInfo.lockStatus lockStatus: this.currentLockInfo.lockStatus
}) })
const { code, meesage } = await this.getPasswordList(this.passwordSearch) const { code, message } = await this.getPasswordList(this.passwordSearch)
this.requestFinished = true this.requestFinished = true
uni.hideLoading() uni.hideLoading()
if(code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
},
onUnload() {
this.clearList('password')
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', 'getPasswordStatus']), ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', 'getPasswordStatus']),
...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword']), ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']),
toPasswordDetail(password) { toPasswordDetail(password) {
this.updateCurrentPasswordInfo(password) this.updateCurrentPasswordInfo(password)
this.routeJump({ this.routeJump({
@ -120,6 +129,7 @@ export default {
startTime: timestamp, startTime: timestamp,
endTime: timestamp endTime: timestamp
}) })
that.closeBluetoothConnection()
if(code === 0) { if(code === 0) {
const { code: requestCode, message } = await deletePsaawordRequest({ const { code: requestCode, message } = await deletePsaawordRequest({
lockId: that.currentLockInfo.lockId, lockId: that.currentLockInfo.lockId,
@ -150,8 +160,6 @@ export default {
title: '删除失败,请保持在锁附近', title: '删除失败,请保持在锁附近',
icon: 'none' icon: 'none'
}) })
} else {
uni.hideLoading()
} }
} }
} }
@ -159,13 +167,6 @@ export default {
}, },
async resetPassword() { async resetPassword() {
const that = this const that = this
if(this.passwordList.length === 0) {
uni.showToast({
title: '暂无密码,无需重置',
icon: 'none'
})
return
}
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要重置密码,该锁的所有密码都将被删除', content: '确定要重置密码,该锁的所有密码都将被删除',
@ -179,6 +180,7 @@ export default {
uid: that.userInfo.uid.toString(), uid: that.userInfo.uid.toString(),
keyId: that.currentLockInfo.keyId.toString() keyId: that.currentLockInfo.keyId.toString()
}) })
that.closeBluetoothConnection()
if(code === 0) { if(code === 0) {
const { code: requestCode, message } = await resetPsaawordListRequest({ const { code: requestCode, message } = await resetPsaawordListRequest({
lockId: that.currentLockInfo.lockId, lockId: that.currentLockInfo.lockId,
@ -209,8 +211,6 @@ export default {
title: '重置密码失败,请保持在锁附近', title: '重置密码失败,请保持在锁附近',
icon: 'none' icon: 'none'
}) })
} else {
uni.hideLoading()
} }
} }
} }
@ -227,12 +227,17 @@ export default {
...this.passwordSearch, ...this.passwordSearch,
pageNo: 1 pageNo: 1
}) })
const { code, meesage } = await this.getPasswordList(this.passwordSearch) const { code, message } = await this.getPasswordList(this.passwordSearch)
if(code === 0) { if(code === 0) {
uni.showToast({ uni.showToast({
title: '刷新成功', title: '刷新成功',
icon: 'none' icon: 'none'
}) })
} else {
uni.showToast({
title: message,
icon: 'none'
})
} }
this.refresherTriggered = false this.refresherTriggered = false
}, },
@ -245,12 +250,17 @@ export default {
...this.passwordSearch, ...this.passwordSearch,
pageNo pageNo
} }
const { code, meesage } = await this.getPasswordList(params) const { code, message } = await this.getPasswordList(params)
if(code === 0) { if(code === 0) {
that.updatePasswordSearch({ that.updatePasswordSearch({
...that.passwordSearch, ...that.passwordSearch,
pageNo pageNo
}) })
} else {
uni.showToast({
title: message,
icon: 'none'
})
} }
}, },
async changeSearch(data) { async changeSearch(data) {
@ -258,7 +268,13 @@ export default {
...this.passwordSearch, ...this.passwordSearch,
searchStr: data searchStr: data
}) })
const { code, meesage } = await this.getPasswordList(this.passwordSearch) const { code, message } = await this.getPasswordList(this.passwordSearch)
if(code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}, },
}, },
} }
@ -326,6 +342,7 @@ page {
width: 574rpx; width: 574rpx;
.password-right-top { .password-right-top {
max-width: 400rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
padding-bottom: 6rpx; padding-bottom: 6rpx;

View File

@ -137,6 +137,7 @@ export default {
} }
}, },
fail (res) { fail (res) {
console.log('获取地理位置信息失败', res)
if(res.errMsg === 'getLocation:fail auth deny') { if(res.errMsg === 'getLocation:fail auth deny') {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
@ -154,6 +155,23 @@ export default {
} }
} }
}) })
} else if(res.errMsg === 'getLocation:fail system permission denied') {
uni.showModal({
title: '提示',
content: '定位失败,请打开微信的位置权限',
confirmText: '去打开',
cancelText: '跳过',
success (res) {
if (res.confirm) {
uni.openAppAuthorizeSetting()
} else {
that.routeJump({
type: 'redirectTo',
name: 'bindLock'
})
}
}
})
} else { } else {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',

View File

@ -38,16 +38,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="view" v-if="currentLockInfo.keyType === 2 || currentLockInfo.keyType === 4"> <view class="view">
<view v-if="currentLockInfo.keyType === 2">
<view class="view-button">
<view>有效期</view>
<view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd h:M') }}{{
timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
</view>
</view>
<view v-if="currentLockInfo.keyType === 4"> <view v-if="currentLockInfo.keyType === 4">
<view class="view-button"> <view class="view-button">
<view>有效期</view> <view>有效期</view>
@ -71,6 +62,19 @@
</view> </view>
</view> </view>
</view> </view>
<view v-else>
<view class="view-button">
<view>有效期</view>
<view class="view-button" style="padding: 10rpx 0">
<view class="info" v-if="currentLockInfo.keyType === 2" style="line-height: 40rpx">
<view>{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd h:M') }}</view>
<view>{{ timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
<view class="info" v-if="currentLockInfo.keyType === 3">单次</view>
<view class="info" v-if="currentLockInfo.keyType === 1">永久</view>
</view>
</view>
</view>
</view> </view>
<view class="button-logout" @click="deleteLock">删除</view> <view class="button-logout" @click="deleteLock">删除</view>
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal" <up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
@ -200,7 +204,7 @@ export default {
authUid: that.userInfo.uid.toString(), authUid: that.userInfo.uid.toString(),
keyId: that.keyId.toString() keyId: that.keyId.toString()
}) })
if(resetDeviceCode === 0) { if(resetDeviceCode === 0 || resetDeviceCode === -2) {
const { code, message } = await deleteLockRequest({ const { code, message } = await deleteLockRequest({
lockId: that.currentLockInfo.lockId lockId: that.currentLockInfo.lockId
}) })
@ -212,7 +216,6 @@ export default {
}) })
that.getLockList(that.lockSearch) that.getLockList(that.lockSearch)
that.backAndToast('删除成功', 2) that.backAndToast('删除成功', 2)
uni.navigateBack()
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
@ -220,14 +223,12 @@ export default {
icon: 'none' icon: 'none'
}) })
} }
} else if(code === -1) { } else if(resetDeviceCode === -1) {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({
title: '删除失败,请保持在锁附近', title: '删除失败,请保持在锁附近',
icon: 'none' icon: 'none'
}) })
} else {
uni.hideLoading()
} }
} else { } else {
const { code } = await deleteKeyRequest({ const { code } = await deleteKeyRequest({

View File

@ -81,9 +81,12 @@ export default {
...mapState(useUserStore, ['userInfo']) ...mapState(useUserStore, ['userInfo'])
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump']), ...mapActions(useBasicStore, ['routeJump', 'getNetworkType']),
...mapActions(useUserStore, ['updateUserInfo', 'checkSession', 'getUserInfo']), ...mapActions(useUserStore, ['updateUserInfo', 'checkSession', 'getUserInfo']),
async rebindPhone(detail) { async rebindPhone(detail) {
if(!(detail.detail.encryptedData && detail.detail.iv)) {
return
}
if(detail.detail.errMsg === 'getPhoneNumber:fail user deny') { if(detail.detail.errMsg === 'getPhoneNumber:fail user deny') {
return return
} }
@ -99,10 +102,6 @@ export default {
}) })
if(code === 0) { if(code === 0) {
this.getUserInfo() this.getUserInfo()
// this.updateUserInfo({
// ...this.userInfo,
// mobile: data.mobile
// })
uni.showToast({ uni.showToast({
title: '更换成功', title: '更换成功',
icon: 'none' icon: 'none'
@ -266,9 +265,8 @@ page {
.name-info { .name-info {
line-height: 40rpx; line-height: 40rpx;
font-size: 30rpx;
text-align: right; text-align: right;
width: 500rpx; width: 520rpx;
overflow: hidden; overflow: hidden;
word-break: break-all; word-break: break-all;
margin-right: 20rpx; margin-right: 20rpx;

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
static/images/icon_password.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
static/images/icon_user.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
static/images/img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -134,6 +134,23 @@ export const useBasicStore = defineStore('basic', {
}) })
} }
}, },
// 获取当前网络状态
getNetworkType() {
return new Promise((resolve) => {
uni.getNetworkType({
success: function (res) {
if(res.networkType === 'none') {
resolve(false)
return
}
resolve(true)
},
fail: function () {
resolve(false)
}
})
})
},
// 获取设备信息 // 获取设备信息
getDeviceInfo() { getDeviceInfo() {
const that = this const that = this

View File

@ -71,10 +71,20 @@ export const useBluetoothStore = defineStore('ble', {
// 服务器时间 // 服务器时间
serverTimestamp: 0, serverTimestamp: 0,
// 设备keyID // 设备keyID
keyId: '0' keyId: '0',
// 刚绑定的设备名称
bindedDeviceName: ''
} }
}, },
actions: { actions: {
// 保存刚绑定的设备名称
updateBindedDeviceName(name) {
this.bindedDeviceName = name
setTimeout(() => {
this.bindedDeviceName = ''
console.log('清空设备名称')
}, 15000)
},
// 更新keyId // 更新keyId
updateKeyId(keyId) { updateKeyId(keyId) {
this.keyId = keyId this.keyId = keyId
@ -97,6 +107,15 @@ export const useBluetoothStore = defineStore('ble', {
} }
return { code, data, message } return { code, data, message }
}, },
// 关闭全部蓝牙监听并关闭蓝牙模拟
closeAllBluetooth() {
uni.offBluetoothAdapterStateChange()
uni.closeBluetoothAdapter({
success(res) {
console.log('关闭蓝牙模块', res)
}
})
},
// 初始化并监听 // 初始化并监听
async initAndListenBluetooth(tipFlag) { async initAndListenBluetooth(tipFlag) {
// 初始化蓝牙 // 初始化蓝牙
@ -590,7 +609,7 @@ export const useBluetoothStore = defineStore('ble', {
}) })
}, },
// 连接蓝牙设备+获取设备服务+获取设备特征值 // 连接蓝牙设备+获取设备服务+获取设备特征值
connectBluetoothDevice() { connectBluetoothDevice(number = 0) {
const that = this const that = this
return new Promise((resolve) => { return new Promise((resolve) => {
if(that.bluetoothStatus !== 0) { if(that.bluetoothStatus !== 0) {
@ -662,11 +681,15 @@ export const useBluetoothStore = defineStore('ble', {
} }
}) })
}, },
fail(res) { async fail(res) {
if(res.errno === 1509007) { if(res.errno === 1509007) {
resolve(true) resolve(true)
return return
} }
if(res.errno === 1509001 && number < 1) {
// 重新连接
resolve(await that.connectBluetoothDevice(number + 1))
}
uni.showToast({ uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态', title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none' icon: 'none'
@ -733,7 +756,7 @@ export const useBluetoothStore = defineStore('ble', {
let timer2 let timer2
return new Promise((resolve) => { return new Promise((resolve) => {
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
success: function (res) { success: function () {
timer2 = setTimeout(() => { timer2 = setTimeout(() => {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
clearInterval(timer1) clearInterval(timer1)
@ -746,7 +769,8 @@ export const useBluetoothStore = defineStore('ble', {
for(let i = 0; i < deviceList.length; i++) { for(let i = 0; i < deviceList.length; i++) {
if(deviceList[i]?.name === that.currentLockInfo.name) { if(deviceList[i]?.name === that.currentLockInfo.name) {
const uuid = deviceList[i]?.advertisServiceUUIDs[0] const uuid = deviceList[i]?.advertisServiceUUIDs[0]
if(uuid && uuid.slice(2,8)==='758824' && uuid.slice(30,32)==='01') { console.log('设备UUID', uuid, uuid.slice(2,8), uuid.slice(30,32))
if(uuid && uuid.slice(2,8)==='758824' && (uuid.slice(30,32)==='01' || that.bindedDeviceName === that.currentLockInfo.name)) {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2) clearTimeout(timer2)
clearInterval(timer1) clearInterval(timer1)
@ -761,6 +785,7 @@ export const useBluetoothStore = defineStore('ble', {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2) clearTimeout(timer2)
clearInterval(timer1) clearInterval(timer1)
uni.hideLoading()
uni.showToast({ uni.showToast({
title: '锁已被重置,请重新绑定', title: '锁已被重置,请重新绑定',
icon: 'none' icon: 'none'
@ -769,6 +794,14 @@ export const useBluetoothStore = defineStore('ble', {
code: -2 code: -2
}) })
break break
} else {
uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2)
clearInterval(timer1)
resolve({
code: -3
})
break
} }
} }
} }

View File

@ -51,6 +51,14 @@ export const useLockStore = defineStore('lock', {
} }
}, },
actions: { actions: {
// 更新锁列表
updateLockList(list) {
this.lockList = list
},
// 清空列表
clearList(type) {
this[type + 'List'] = []
},
// 获取电量icon // 获取电量icon
getPowerIcon(power) { getPowerIcon(power) {
if(power >= 80) { if(power >= 80) {
@ -107,7 +115,7 @@ export const useLockStore = defineStore('lock', {
}, },
getKeyStatus(keyStatus) { getKeyStatus(keyStatus) {
if(keyStatus === 110401) { if(keyStatus === 110401) {
return '正常' return ''
} else if(keyStatus === 110403) { } else if(keyStatus === 110403) {
return '未生效' return '未生效'
} else if(keyStatus === 110402) { } else if(keyStatus === 110402) {
@ -162,12 +170,9 @@ export const useLockStore = defineStore('lock', {
} else { } else {
this.lockList = this.lockList.concat(data.groupList) this.lockList = this.lockList.concat(data.groupList)
} }
uni.setStorageSync('lockList', this.lockList)
return { code } return { code }
} else { } else {
uni.showToast({
title: message,
icon: 'none'
})
return { code, message } return { code, message }
} }
}, },
@ -220,10 +225,6 @@ export const useLockStore = defineStore('lock', {
} }
return { code } return { code }
} else { } else {
uni.showToast({
title: message,
icon: 'none'
})
return { code, message } return { code, message }
} }
}, },
@ -232,7 +233,6 @@ export const useLockStore = defineStore('lock', {
if(code === 0) { if(code === 0) {
this.keyTotal = data.total this.keyTotal = data.total
for(let i = 0; i < data.list.length; i++) { for(let i = 0; i < data.list.length; i++) {
console.log(data.list[i].keyType)
if(data.list[i].keyType === 1) { if(data.list[i].keyType === 1) {
data.list[i].timeText = `${timeFormat(new Date(data.list[i].sendDate), 'yyyy-mm-dd h:M')} 永久` data.list[i].timeText = `${timeFormat(new Date(data.list[i].sendDate), 'yyyy-mm-dd h:M')} 永久`
} else if(data.list[i].keyType === 2) { } else if(data.list[i].keyType === 2) {
@ -250,10 +250,6 @@ export const useLockStore = defineStore('lock', {
} }
return { code } return { code }
} else { } else {
uni.showToast({
title: message,
icon: 'none'
})
return { code, message } return { code, message }
} }
} }

View File

@ -25,6 +25,7 @@ export const useUserStore = defineStore('user', {
async getUserInfo() { async getUserInfo() {
const { code, data } = await getUserInfoRequest() const { code, data } = await getUserInfoRequest()
if(code === 0) { if(code === 0) {
uni.setStorageSync('userInfo', data)
this.updateUserInfo(data) this.updateUserInfo(data)
this.updateLoginStatus(true) this.updateLoginStatus(true)
} }

View File

@ -11,6 +11,7 @@ import env from '@/config/env'
* */ * */
const request = (config) => { const request = (config) => {
let timer
return new Promise((resolve) => { return new Promise((resolve) => {
const baseConfig = env[getApp().globalData.getEnvConfig()] const baseConfig = env[getApp().globalData.getEnvConfig()]
@ -25,14 +26,20 @@ const request = (config) => {
const header = config.header || headerDefault const header = config.header || headerDefault
const data = config.data || {} const data = config.data || {}
const timestamp = new Date().getTime() const timestamp = new Date().getTime()
timer = setTimeout(() => {
resolve({ code: -1, message: '网络访问失败,请检查网络是否正常' })
}, 3200)
uni.request({ uni.request({
url: URL, url: URL,
method, method,
header, header,
data, data,
timeout: 7000, timeout: 3000,
async success(res) { async success(res) {
const { statusCode, data } = res const { statusCode, data } = res
if(timer) {
clearTimeout(timer)
}
if (statusCode === 200) { if (statusCode === 200) {
const code = data.errorCode const code = data.errorCode
const message = data.errorMsg const message = data.errorMsg
@ -58,11 +65,15 @@ const request = (config) => {
}) })
} }
} else { } else {
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' }) resolve({ code: -1, data, message: '网络访问失败,请检查网络是否正常' })
} }
}, },
async fail() { async fail(res) {
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' }) console.log('网络访问失败', res)
if(timer) {
clearTimeout(timer)
}
resolve({ code: -1, message: '网络访问失败,请检查网络是否正常' })
}, },
async complete(res) { async complete(res) {
console.log(URL.substring(baseConfig.baseUrl.length + 1), { console.log(URL.substring(baseConfig.baseUrl.length + 1), {