完成锁设置页相关功能
This commit is contained in:
parent
6bcda7adb9
commit
673598e564
@ -28,3 +28,12 @@ export function getLockNetTokenRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除智能门锁
|
||||
export function deleteLockRequest(data) {
|
||||
return request({
|
||||
url: '/lock/delete',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
12
api/lockSetting.js
Normal file
12
api/lockSetting.js
Normal file
@ -0,0 +1,12 @@
|
||||
import request from '../utils/request'
|
||||
|
||||
// lockSetting 锁设置模块
|
||||
|
||||
// 更新锁设置
|
||||
export function updateLockSettingRequest(data) {
|
||||
return request({
|
||||
url: '/lockSetting/updateLockSetting',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
110
pages.json
110
pages.json
@ -9,32 +9,17 @@
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/home/home",
|
||||
"style": {
|
||||
"navigationBarTitleText": "星星锁",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
"path": "pages/home/home"
|
||||
},
|
||||
{
|
||||
"path": "pages/selectAddress/selectAddress",
|
||||
"style": {
|
||||
"navigationBarTitleText": "锁地址",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/mine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "星星锁",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
}
|
||||
"path": "pages/mine/mine"
|
||||
},
|
||||
{
|
||||
"path": "pages/index/index"
|
||||
@ -42,110 +27,107 @@
|
||||
{
|
||||
"path": "pages/userInfo/userInfo",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人信息",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "个人信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/updateName/updateName",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改昵称",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "修改昵称"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/updatePassword/updatePassword",
|
||||
"style": {
|
||||
"navigationBarTitleText": "重置密码",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "重置密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/updateEmail/updateEmail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改邮箱",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "修改邮箱"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/verifyEmail/verifyEmail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "验证邮箱",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "验证邮箱"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/safeQuestion/safeQuestion",
|
||||
"style": {
|
||||
"navigationBarTitleText": "安全问题",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "安全问题"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/updateSafeQuestion/updateSafeQuestion",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改安全问题",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "修改安全问题"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/webview/webview",
|
||||
"style": {
|
||||
"navigationBarTitleText": "介绍",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "介绍"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/lockDetail/lockDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "星星锁",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "星星锁"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/bindLock/bindLock",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加锁",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "添加锁"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/searchDevice/searchDevice",
|
||||
"style": {
|
||||
"disableScroll": true,
|
||||
"navigationBarTitleText": "附近设备",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"navigationStyle": "default"
|
||||
"navigationBarTitleText": "附近设备"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/setting/setting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/keyList/keyList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "电子钥匙"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/createKey/createKey",
|
||||
"style": {
|
||||
"navigationBarTitleText": "发送钥匙"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/passwordList/passwordList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/createPassword/createPassword",
|
||||
"style": {
|
||||
"navigationBarTitleText": "获取密码"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "星星锁",
|
||||
"navigationBarBackgroundColor": "#F3F3F3",
|
||||
"navigationBarBackgroundColor": "#63b8af",
|
||||
"backgroundColor": "#F3F3F3",
|
||||
"navigationStyle": "custom"
|
||||
"navigationStyle": "default"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#a3a3a3",
|
||||
|
||||
17
pages/createKey/createKey.vue
Normal file
17
pages/createKey/createKey.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
17
pages/createPassword/createPassword.vue
Normal file
17
pages/createPassword/createPassword.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
@ -239,7 +239,7 @@
|
||||
signKey: lock.bluetooth.signKey,
|
||||
publicKey: lock.bluetooth.publicKey,
|
||||
}
|
||||
this.updateKeyId(lock.keyId)
|
||||
this.updateKeyId(lock.keyId.toString())
|
||||
this.updateCurrentLockInfo(data)
|
||||
this.routeJump({
|
||||
name: 'lockDetail'
|
||||
|
||||
17
pages/keyList/keyList.vue
Normal file
17
pages/keyList/keyList.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
@ -33,17 +33,18 @@
|
||||
</view>
|
||||
<view class="menu-main">
|
||||
<view v-if="currentLockInfo.lockFeature.bluetoothRemoteControl || currentLockInfo.userType === 110301"
|
||||
class="menu-main-view">
|
||||
class="menu-main-view" @click="routeJump({ name: 'keyList' })">
|
||||
<image class="menu-main-image" src="/static/images/tabbar_key_select.png"></image>
|
||||
<view>电子钥匙</view>
|
||||
</view>
|
||||
<view v-if="currentLockInfo.lockFeature.password || currentLockInfo.userType === 110301" class="menu-main-view">
|
||||
<view v-if="currentLockInfo.lockFeature.password || currentLockInfo.userType === 110301"
|
||||
class="menu-main-view" @click="routeJump({ name: 'passwordList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image>
|
||||
<view>密码</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="setting">
|
||||
<view class="setting" @click="routeJump({ name: 'setting' })">
|
||||
<image class="setting-image" src="/static/images/icon_setting.png"></image>
|
||||
<view class="setting-text">设置</view>
|
||||
<image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image>
|
||||
@ -53,6 +54,7 @@
|
||||
|
||||
<script>
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { mapState, mapActions } from 'pinia'
|
||||
import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
@ -84,6 +86,7 @@ export default {
|
||||
methods: {
|
||||
...mapActions(useLockStore, ['getRole']),
|
||||
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']),
|
||||
...mapActions(useBasicStore, ['routeJump']),
|
||||
powerTip() {
|
||||
const that = this
|
||||
uni.showModal({
|
||||
@ -94,13 +97,13 @@ export default {
|
||||
},
|
||||
async getNetToken(){
|
||||
const { code, data, message } = await getLockNetTokenRequest({
|
||||
lockId: this.currentLockInfo.keyId
|
||||
lockId: this.currentLockInfo.lockId
|
||||
})
|
||||
if(code === 0) {
|
||||
this.onlineToken = data.token
|
||||
return true
|
||||
} else {
|
||||
uni.toast({
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
@ -155,7 +158,7 @@ export default {
|
||||
this.$refs.loading.close()
|
||||
this.pending = false
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
17
pages/passwordList/passwordList.vue
Normal file
17
pages/passwordList/passwordList.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
198
pages/setting/setting.vue
Normal file
198
pages/setting/setting.vue
Normal file
@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="view">
|
||||
<view class="view-button">
|
||||
<view>名称</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{currentLockInfo.lockAlias}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-button">
|
||||
<view>锁编号</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{currentLockInfo.name}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>MAC/ID</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{currentLockInfo.mac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>电量</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{currentLockInfo.electricQuantity}}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view">
|
||||
<view class="view-button">
|
||||
<view>开锁时是否需联网</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<up-switch v-model="unlockApp" :size="40" activeColor="#63b8af" :asyncChange="true"
|
||||
@change="changeUnlockApp" :activeValue="1" :inactiveValue="0"></up-switch>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="button-logout" @click="deleteLock">删除</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
import { deleteLockRequest } from '@/api/lock'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { updateLockSettingRequest } from '@/api/lockSetting'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
unlockApp: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useUserStore, ['userInfo']),
|
||||
...mapState(useBluetoothStore, ['keyId', 'currentLockInfo'])
|
||||
},
|
||||
onLoad() {
|
||||
this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
|
||||
...mapActions(useLockStore, ['getLockList']),
|
||||
async changeUnlockApp(value) {
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
appUnlockOnline: value
|
||||
})
|
||||
if(code === 0) {
|
||||
this.unlockApp = value
|
||||
const data = this.currentLockInfo
|
||||
data.lockSetting.appUnlockOnline = value
|
||||
this.updateCurrentLockInfo(data)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteLock() {
|
||||
const that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定删除该门锁吗?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中'
|
||||
})
|
||||
console.log(that.currentLockInfo.name, that.userInfo.uid.toString(), that.keyId.toString())
|
||||
const { code: resetDeviceCode } = await that.resetDevice({
|
||||
name: that.currentLockInfo.name,
|
||||
authUid: that.userInfo.uid.toString(),
|
||||
keyId: that.keyId.toString()
|
||||
})
|
||||
if(resetDeviceCode === 0) {
|
||||
const { code, message } = await deleteLockRequest({
|
||||
lockId: that.currentLockInfo.lockId
|
||||
})
|
||||
if(code === 0) {
|
||||
uni.hideLoading()
|
||||
that.getLockList({
|
||||
pageNo: 1,
|
||||
pageSize: 50
|
||||
})
|
||||
uni.navigateBack({
|
||||
delta: 2,
|
||||
complete: () => {
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.button-logout {
|
||||
position: absolute;
|
||||
border-radius: 46rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 30rpx);
|
||||
width: 600rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
margin-left: 75rpx;
|
||||
background: #ec433c;
|
||||
color: #ffffff;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.view {
|
||||
margin-top: 32rpx;
|
||||
border-radius: 32rpx;
|
||||
width: 710rpx;
|
||||
margin-left: 20rpx;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
.view-button {
|
||||
padding: 0 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #292826;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
.view-line {
|
||||
width: 100%;
|
||||
height: 3rpx;
|
||||
background: #EBEBEB;
|
||||
}
|
||||
</style>
|
||||
@ -71,6 +71,31 @@ const pages = [
|
||||
name: 'bindLock',
|
||||
path: '/pages/bindLock/bindLock',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'setting',
|
||||
path: '/pages/setting/setting',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'keyList',
|
||||
path: '/pages/keyList/keyList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'createKey',
|
||||
path: '/pages/createKey/createKey',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'passwordList',
|
||||
path: '/pages/passwordList/passwordList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'createPassword',
|
||||
path: '/pages/createPassword/createPassword',
|
||||
tabBar: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -941,10 +941,10 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
for(let i = 0; i < authUid.length; i++) {
|
||||
conentArray[i + 42] = authUid.charCodeAt(i)
|
||||
}
|
||||
conentArray.set(this.currentLockInfo.token, 62)
|
||||
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
|
||||
conentArray[66] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(name, this.currentLockInfo.token, this.currentLockInfo.publicKey)
|
||||
const md5Array = this.md5Encrypte(name, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.publicKey)
|
||||
conentArray.set(md5Array, 67)
|
||||
|
||||
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user