1. 添加lint 2. 引入star-cloud-uni

This commit is contained in:
范鹏 2025-02-06 11:37:41 +08:00
parent c66735b8b9
commit 150b1a0e75
47 changed files with 13765 additions and 4621 deletions

36
.commitlintrc.cjs Normal file
View File

@ -0,0 +1,36 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [1, 'always', 100],
'header-max-length': [2, 'always', 100],
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'conflict',
'fonts',
'delete',
'stash'
]
]
}
}

6
.eslintignore Normal file
View File

@ -0,0 +1,6 @@
dist
node_modules
unpackage
public
.idea
*.md

View File

@ -0,0 +1,79 @@
{
"globals": {
"Component": true,
"ComponentPublicInstance": true,
"ComputedRef": true,
"EffectScope": true,
"ExtractDefaultPropTypes": true,
"ExtractPropTypes": true,
"ExtractPublicPropTypes": true,
"InjectionKey": true,
"PropType": true,
"Ref": true,
"VNode": true,
"WritableComputedRef": true,
"computed": true,
"createApp": true,
"customRef": true,
"defineAsyncComponent": true,
"defineComponent": true,
"effectScope": true,
"getCurrentInstance": true,
"getCurrentScope": true,
"h": true,
"inject": true,
"isProxy": true,
"isReactive": true,
"isReadonly": true,
"isRef": true,
"markRaw": true,
"nextTick": true,
"onActivated": true,
"onBeforeMount": true,
"onBeforeRouteLeave": true,
"onBeforeRouteUpdate": true,
"onBeforeUnmount": true,
"onBeforeUpdate": true,
"onDeactivated": true,
"onErrorCaptured": true,
"onMounted": true,
"onRenderTracked": true,
"onRenderTriggered": true,
"onScopeDispose": true,
"onServerPrefetch": true,
"onUnmounted": true,
"onUpdated": true,
"provide": true,
"reactive": true,
"readonly": true,
"ref": true,
"resolveComponent": true,
"shallowReactive": true,
"shallowReadonly": true,
"shallowRef": true,
"toRaw": true,
"toRef": true,
"toRefs": true,
"toValue": true,
"triggerRef": true,
"unref": true,
"useAttrs": true,
"useCssModule": true,
"useCssVars": true,
"useLink": true,
"useRoute": true,
"useRouter": true,
"useSlots": true,
"watch": true,
"watchEffect": true,
"watchPostEffect": true,
"watchSyncEffect": true,
"DirectiveBinding": true,
"MaybeRef": true,
"MaybeRefOrGetter": true,
"onWatcherCleanup": true,
"useId": true,
"useModel": true,
"useTemplateRef": true
}
}

87
.eslintrc.cjs Normal file
View File

@ -0,0 +1,87 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true
},
globals: {
uni: 'writable',
getApp: 'writable',
wx: 'writable'
},
// 指定如何解析语法
parser: 'vue-eslint-parser',
// 优先级低于 parse 的语法解析配置
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: false
}
},
// 继承某些已有的规则
extends: [
'plugin:vue/vue3-recommended', // 使用插件支持vue3
'airbnb-base',
'plugin:prettier/recommended',
'./.eslintrc-auto-import.json'
],
/**
* "off" 0 ==> 关闭规则
* "warn" 1 ==> 打开的规则作为警告不影响代码执行
* "error" 2 ==> 规则作为一个错误代码不能执行界面报错
*/
rules: {
// eslint (http://eslint.cn/docs/rules)
'prettier/prettier': 'error',
'import/extensions': 0,
'prefer-template': 0,
'no-var': 'error', // 要求使用 let 或 const 而不是 var
'no-multiple-empty-lines': ['error', { max: 1 }], // 不允许多个空行
'prefer-const': 'off', // 使用 let 关键字声明但在初始分配后从未重新分配的变量,要求使用 const
'no-use-before-define': 'off', // 禁止在 函数/类/变量 定义之前使用它们
'no-irregular-whitespace': 'off', // 禁止不规则的空白\
'import/no-cycle': 0,
'no-nested-ternary': 0,
'import/prefer-default-export': 0,
'import/no-unresolved': 0,
'prefer-destructuring': 0,
'no-shadow': 0,
'no-param-reassign': 0,
'consistent-return': 0,
'no-case-declarations': 0,
'prefer-promise-reject-errors': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0,
camelcase: 0,
'import/no-extraneous-dependencies': 0,
'no-underscore-dangle': 0,
'no-debugger': 0,
'no-promise-executor-return': 0,
// vue (https://eslint.vuejs.org/rules)
'vue/script-setup-uses-vars': 'error', // 防止<script setup>使用的变量<template>被标记为未使用此规则仅在启用该no-unused-vars规则时有效。
'vue/v-slot-style': 'error', // 强制执行 v-slot 指令样式
'vue/no-mutating-props': 'off', // 不允许组件 prop的改变
'vue/no-v-html': 'off', // 禁止使用 v-html
'vue/custom-event-name-casing': 'off', // 为自定义事件名称强制使用特定大小写
'vue/attributes-order': 'off', // vue api使用顺序强制执行属性顺序
'vue/one-component-per-file': 'off', // 强制每个组件都应该在自己的文件中
'vue/html-closing-bracket-newline': 'off', // 在标签的右括号之前要求或禁止换行
'vue/max-attributes-per-line': 'off', // 强制每行的最大属性数
'vue/multiline-html-element-content-newline': 'off', // 在多行元素的内容之前和之后需要换行符
'vue/singleline-html-element-content-newline': 'off', // 在单行元素的内容之前和之后需要换行符
'vue/attribute-hyphenation': 'off', // 对模板中的自定义组件强制执行属性命名样式
'vue/require-default-prop': 'off', // 此规则要求为每个 prop 为必填时,必须提供默认值
'vue/multi-word-component-names': 'off', // 要求组件名称始终为 “-” 链接的单词
'vue.prefer-template': 'off',
'vuejs-accessibility/click-events-have-key-events': 'off',
'no-console': 'off',
'no-plusplus': 'off',
'no-await-in-loop': 'off',
'no-async-promise-executor': 'off',
'no-return-await': 'off',
'no-loop-func': 'off',
'no-bitwise': 'off'
}
}

9
.lintstagedrc.json Normal file
View File

@ -0,0 +1,9 @@
{
"src/**/*.{vue,js}": [
"npm run prettier",
"npm run eslint"
],
"src/**/*.{vue,scss,css,less}": [
"npm run stylelint:out"
]
}

6
.prettierignore Normal file
View File

@ -0,0 +1,6 @@
dist
unpackage
node_modules
public
.idea
*.md

22
.prettierrc.json Normal file
View File

@ -0,0 +1,22 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"bracketSameLine": false,
"arrowParens": "avoid",
"endOfLine": "auto",
"embeddedLanguageFormatting": "auto",
"vueIndentScriptAndStyle": true,
"singleAttributePerLine": false,
"htmlWhitespaceSensitivity": "css",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve"
}

9
.stylelintignore Normal file
View File

@ -0,0 +1,9 @@
/.husky/*
/.vscode/*
/bin
/node_modules/*
/docs/*
/html/*
/dist/*
/public/*
/scripts/*

47
.stylelintrc.cjs Normal file
View File

@ -0,0 +1,47 @@
// @see https://stylelint.bootcss.com/
module.exports = {
extends: [
'stylelint-config-standard', // 配置stylelint拓展插件
'stylelint-config-html/vue', // 配置 vue 中 template 样式格式化
'stylelint-config-standard-scss', // 配置stylelint scss插件
'stylelint-config-recommended-vue/scss', // 配置 vue 中 scss 样式格式化
'stylelint-config-recess-order' // 配置stylelint css属性书写顺序插件,
// 'stylelint-config-prettier', // 配置stylelint和prettier兼容, 注意stylelint大于等于v15是已经不需要此插件
],
overrides: [
{
files: ['**/*.(scss|css|vue|html)'],
customSyntax: 'postcss-scss'
},
{
files: ['**/*.(html|vue)'],
customSyntax: 'postcss-html'
}
],
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts', '**/*.json', '**/*.md', '**/*.yaml'],
/**
* null => 关闭该规则
* always => 必须
*/
rules: {
'font-family-no-missing-generic-family-keyword': null,
'value-keyword-case': null, // 在 css 中使用 v-bind不报错
'no-descending-specificity': null, // 禁止在具有较高优先级的选择器后出现被其覆盖的较低优先级的选择器
'function-url-quotes': 'always', // 要求或禁止 URL 的引号 "always(必须加上引号)"|"never(没有引号)"
'no-empty-source': null, // 关闭禁止空源码
'selector-class-pattern': null, // 关闭强制选择器类名的格式
'property-no-unknown': null, // 禁止未知的属性(true 为不允许)
// 'block-opening-brace-space-before': 'always', //大括号之前必须有一个空格或不能有空白符
'value-no-vendor-prefix': null, // 关闭 属性值前缀 --webkit-box
'property-no-vendor-prefix': null, // 关闭 属性前缀 -webkit-mask
'scss/dollar-variable-pattern': null,
'scss/at-mixin-pattern': null,
'selector-pseudo-class-no-unknown': [
// 不允许未知的选择器
true,
{
ignorePseudoClasses: ['global', 'v-deep', 'deep'] // 忽略属性修改element默认样式的时候能使用到
}
]
}
}

32
App.vue
View File

@ -1,8 +1,9 @@
<script> <script>
import { mapState, mapActions } from 'pinia'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { mapState, mapActions } from 'pinia'
import { getStorage } from './utils/storage' import { getStorage } from './utils/storage'
let firstCheckSetting = true let firstCheckSetting = true
export default { export default {
@ -20,21 +21,20 @@
const envVersionStorage = getStorage('envVersion') const envVersionStorage = getStorage('envVersion')
if (envVersionStorage) { if (envVersionStorage) {
return envVersionStorage return envVersionStorage
} else { }
if (this.envVersion === 'develop') { if (this.envVersion === 'develop') {
return 'XHJ' return 'XHJ'
} else if (this.envVersion === 'trial') { }
if (this.envVersion === 'trial') {
return 'PRE' return 'PRE'
} else { }
return 'XHJ' return 'XHJ'
} }
}
}
}, },
computed: { computed: {
...mapState(useBluetoothStore, ['bluetoothStatus']), ...mapState(useBluetoothStore, ['bluetoothStatus'])
}, },
onLaunch: async function() { async onLaunch() {
// //
this.updateMiniProgram() this.updateMiniProgram()
// //
@ -54,8 +54,16 @@
} }
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['initBluetooth', 'onBluetoothState', 'updateBluetoothStatus', 'checkSetting', ...mapActions(useBluetoothStore, [
'onBluetoothConnectStatus', 'onBluetoothCharacteristicValueChange', 'updateInitBluetooth', 'initAndListenBluetooth']), 'initBluetooth',
'onBluetoothState',
'updateBluetoothStatus',
'checkSetting',
'onBluetoothConnectStatus',
'onBluetoothCharacteristicValueChange',
'updateInitBluetooth',
'initAndListenBluetooth'
]),
...mapActions(useUserStore, ['updateLoginStatus']), ...mapActions(useUserStore, ['updateLoginStatus']),
// //
updateMiniProgram() { updateMiniProgram() {
@ -65,7 +73,7 @@
title: '更新提示', title: '更新提示',
content: '新版本已经准备好,是否重启应用?', content: '新版本已经准备好,是否重启应用?',
showCancel: false, showCancel: false,
success: function () { success() {
updateManager.applyUpdate() updateManager.applyUpdate()
} }
}) })
@ -76,5 +84,5 @@
</script> </script>
<style lang="scss"> <style lang="scss">
@import "uview-plus/index.scss"; @import 'uview-plus/index.scss';
</style> </style>

View File

@ -6,10 +6,20 @@
{{ timeFormat(time, 'yyyy-mm-dd h:M') }} {{ timeFormat(time, 'yyyy-mm-dd h:M') }}
</view> </view>
</view> </view>
<up-datetime-picker :filter="filter" itemHeight="60" :minDate="minDate" :show="show" <up-datetime-picker
v-model="time" :formatter="formatter" :maxDate="maxDate" :filter="filter"
mode="datetime" @confirm="confirm" :closeOnClickOverlay="true" itemHeight="60"
@close="close" @cancel="close"></up-datetime-picker> :minDate="minDate"
:show="show"
v-model="time"
:formatter="formatter"
:maxDate="maxDate"
mode="datetime"
@confirm="confirm"
:closeOnClickOverlay="true"
@close="close"
@cancel="close"
></up-datetime-picker>
</view> </view>
</template> </template>
@ -41,25 +51,25 @@ export default {
timeFormat, timeFormat,
formatter(type, value) { formatter(type, value) {
if (type === 'year') { if (type === 'year') {
return `${value}`; return `${value}`
} }
if (type === 'month') { if (type === 'month') {
return `${value}`; return `${value}`
} }
if (type === 'day') { if (type === 'day') {
return `${value}`; return `${value}`
} }
if (type === 'hour') { if (type === 'hour') {
return `${value}`; return `${value}`
} }
if (type === 'minute') { if (type === 'minute') {
return `${value}`; return `${value}`
} }
return value; return value
}, },
filter(mode, options) { filter(mode, options) {
if (mode === 'minute' && this.type === 'datehour') { if (mode === 'minute' && this.type === 'datehour') {
return options.filter((option) => option === '00') return options.filter(option => option === '00')
} }
return options return options

View File

@ -2,8 +2,14 @@
<view> <view>
<view class="name"> <view class="name">
<view class="name-text">{{ title }}</view> <view class="name-text">{{ title }}</view>
<input :value="value" class="name-input" :placeholder="placeholder" placeholder-class="placeholder-class" <input
maxlength="50" @input="changeInput"></input> :value="value"
class="name-input"
:placeholder="placeholder"
placeholder-class="placeholder-class"
maxlength="50"
@input="changeInput"
/>
</view> </view>
</view> </view>
</template> </template>
@ -20,7 +26,7 @@ export default {
changeInput(e) { changeInput(e) {
this.$emit('changeInput', e.detail.value) this.$emit('changeInput', e.detail.value)
} }
}, }
} }
</script> </script>

View File

@ -1,12 +1,26 @@
<template> <template>
<view> <view>
<view class="spinner-box" :style="{ width: size + 'rpx', height: size + 'rpx' }"> <view class="spinner-box" :style="{ width: size + 'rpx', height: size + 'rpx' }">
<view v-if="show" class="circle-border" :style="{width: size * 0.75 + 'rpx', height: size * 0.75 + 'rpx'}"> <view
v-if="show"
class="circle-border"
:style="{ width: size * 0.75 + 'rpx', height: size * 0.75 + 'rpx' }"
>
</view> </view>
<view v-else class="circle-border-stop" :style="{width: size * 0.75 + 'rpx', height: size * 0.75 + 'rpx'}"></view> <view
<view class="circle-core" :style="{width: size * 0.75 - 2 + 'rpx', height: size * 0.75 - 2 + 'rpx'}"> v-else
<image src="/static/images/icon_lock_transparent.png" mode="aspectFill" :style="{width: size * 0.35 + 'rpx', class="circle-border-stop"
height: size * 0.35 + 'rpx'}"></image> :style="{ width: size * 0.75 + 'rpx', height: size * 0.75 + 'rpx' }"
></view>
<view
class="circle-core"
:style="{ width: size * 0.75 - 2 + 'rpx', height: size * 0.75 - 2 + 'rpx' }"
>
<image
src="/static/images/icon_lock_transparent.png"
mode="aspectFill"
:style="{ width: size * 0.35 + 'rpx', height: size * 0.35 + 'rpx' }"
></image>
</view> </view>
</view> </view>
</view> </view>
@ -14,9 +28,9 @@
<script> <script>
export default { export default {
name: "SwitchLoading", name: 'SwitchLoading',
props: { props: {
size: Number, size: Number
}, },
data() { data() {
return { return {
@ -31,7 +45,7 @@ export default {
this.show = false this.show = false
} }
} }
}; }
</script> </script>
<style> <style>
@ -60,11 +74,7 @@ export default {
align-items: center; align-items: center;
border-radius: 50%; border-radius: 50%;
background: rgb(99, 184, 175); background: rgb(99, 184, 175);
background: linear-gradient( background: linear-gradient(0deg, rgba(99, 184, 175, 0.1) 33%, rgba(99, 184, 175, 1) 100%);
0deg,
rgba(99, 184, 175, 0.1) 33%,
rgba(99, 184, 175, 1) 100%
);
animation: spin 0.8s linear 0s infinite; animation: spin 0.8s linear 0s infinite;
position: absolute; position: absolute;
@ -86,7 +96,7 @@ export default {
z-index: 1; z-index: 1;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #FFFFFF; background-color: #ffffff;
border-radius: 50%; border-radius: 50%;
display: flex; display: flex;
justify-content: center; justify-content: center;

View File

@ -1,11 +1,11 @@
let version = '-' let version = '-'
let buildNumber = "-" let buildNumber = '-'
uni.getSystemInfo({ uni.getSystemInfo({
success: function (res) { success(res) {
version = res.appVersion version = res.appVersion
buildNumber = res.appVersionCode buildNumber = res.appVersionCode
} }
}); })
const DEV = { const DEV = {
name: 'dev', name: 'dev',

View File

@ -1,14 +1,14 @@
import App from './App'
import * as Pinia from 'pinia' import * as Pinia from 'pinia'
import { createSSRApp } from 'vue' import { createSSRApp } from 'vue'
import { createUnistorage } from 'pinia-plugin-unistorage' import { createUnistorage } from 'pinia-plugin-unistorage'
import uviewPlus, { setConfig } from 'uview-plus' import uviewPlus, { setConfig } from 'uview-plus'
import App from './App'
setConfig({ setConfig({
config: { config: {
// 修改默认单位为rpx // 修改默认单位为rpx
unit: 'rpx' unit: 'rpx'
}, }
}) })
export function createApp() { export function createApp() {

8119
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,27 @@
"pinia": "^2.2.0", "pinia": "^2.2.0",
"pinia-plugin-unistorage": "^0.1.2", "pinia-plugin-unistorage": "^0.1.2",
"sm-crypto": "^0.3.13", "sm-crypto": "^0.3.13",
"star-cloud-uni": "file:../starCloud",
"stylelint": "^16.14.1",
"stylelint-config-recess-order": "^6.0.0",
"stylelint-config-recommended-scss": "^14.1.0",
"stylelint-config-standard": "^37.0.0",
"uview-plus": "^3.3.12" "uview-plus": "^3.3.12"
},
"devDependencies": {
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"commitizen": "^4.3.1",
"cz-git": "^1.11.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-vue": "^9.32.0",
"husky": "^9.1.7",
"lint-staged": "^15.4.3",
"prettier": "^3.4.2",
"vite-plugin-eslint": "^1.8.1"
} }
} }

View File

@ -17,10 +17,14 @@ export default {
return {} return {}
}, },
computed: { computed: {
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']), ...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth'])
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'checkSetting']), ...mapActions(useBluetoothStore, [
'getBluetoothStatus',
'initAndListenBluetooth',
'checkSetting'
]),
...mapActions(useBasicStore, ['routeJump']), ...mapActions(useBasicStore, ['routeJump']),
async toSearchDevice() { async toSearchDevice() {
if (this.bluetoothStatus !== 0) { if (this.bluetoothStatus !== 0) {
@ -39,8 +43,8 @@ export default {
} else { } else {
this.checkSetting() this.checkSetting()
} }
}, }
}, }
} }
</script> </script>

View File

@ -1,17 +1,22 @@
<template> <template>
<view> <view>
<view class="text">如需修改名字请重新命名点击确定添加锁</view> <view class="text">如需修改名字请重新命名点击确定添加锁</view>
<input class="input" :value="name" maxlength="50" placeholder="请输入名称" placeholder-class="input-placeholder" <input
@input="uopdateName" class="input"
></input> :value="name"
maxlength="50"
placeholder="请输入名称"
placeholder-class="input-placeholder"
@input="updateName"
/>
<view class="button" @click="bindLock">确定</view> <view class="button" @click="bindLock">确定</view>
</view> </view>
</template> </template>
<script> <script>
import { mapActions, mapState } from 'pinia'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { mapActions, mapState } from 'pinia'
import { bindLockAdmin } from '@/api/lock' import { bindLockAdmin } from '@/api/lock'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
@ -25,7 +30,7 @@ export default {
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useLockStore, ['lockSearch']), ...mapState(useLockStore, ['lockSearch'])
}, },
onLoad() { onLoad() {
this.name = this.currentLockInfo.name this.name = this.currentLockInfo.name
@ -33,11 +38,16 @@ export default {
console.log(this.name) console.log(this.name)
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName', ...mapActions(useBluetoothStore, [
'closeAllBluetooth', 'initAndListenBluetooth']), 'addLockUser',
'closeBluetoothConnection',
'updateBindedDeviceName',
'closeAllBluetooth',
'initAndListenBluetooth'
]),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']),
uopdateName(data) { updateName(data) {
this.name = data.detail.value this.name = data.detail.value
}, },
async bindLock() { async bindLock() {
@ -57,7 +67,7 @@ export default {
mask: true mask: true
}) })
this.updateBindedDeviceName(this.currentLockInfo.name) this.updateBindedDeviceName(this.currentLockInfo.name)
const timestamp = parseInt(new Date().getTime() / 1000) const timestamp = parseInt(new Date().getTime() / 1000, 10)
const password = (Math.floor(Math.random() * 900000) + 100000).toString() const password = (Math.floor(Math.random() * 900000) + 100000).toString()
const { code: addUserCode } = await this.addLockUser({ const { code: addUserCode } = await this.addLockUser({
name: this.currentLockInfo.name, name: this.currentLockInfo.name,
@ -104,7 +114,7 @@ export default {
bluetoothDeviceId: this.currentLockInfo.deviceId, bluetoothDeviceId: this.currentLockInfo.deviceId,
publicKey: this.currentLockInfo.publicKey, publicKey: this.currentLockInfo.publicKey,
privateKey: this.currentLockInfo.commKey, privateKey: this.currentLockInfo.commKey,
signKey: this.currentLockInfo.signKey, signKey: this.currentLockInfo.signKey
}, },
lockUserNo: this.currentLockInfo.lockUserNo, lockUserNo: this.currentLockInfo.lockUserNo,
pwdTimestamp: this.currentLockInfo.pwdTimestamp, pwdTimestamp: this.currentLockInfo.pwdTimestamp,
@ -144,7 +154,7 @@ export default {
}) })
} }
} }
}, }
} }
</script> </script>
@ -164,7 +174,7 @@ page {
.input { .input {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 24rpx; margin-top: 24rpx;
height: 108rpx; height: 108rpx;
@ -190,6 +200,6 @@ page {
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
} }
</style> </style>

View File

@ -1,36 +1,79 @@
<template> <template>
<view> <view>
<view class="tabs"> <view class="tabs">
<up-tabs :list="tabs" lineWidth="40rpx" lineHeight="5rpx" :current="currnetIndex" lineColor="#63b8af" <up-tabs
@click="clickTab" :inactiveStyle="{color:'#a3a3a3', fontSize: '32rpx', fontWeight: 'bold'}" :list="tabs"
:activeStyle="{color:'#63b8af', fontSize: '32rpx', fontWeight: 'bold'}"> lineWidth="40rpx"
lineHeight="5rpx"
:current="currnetIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs> </up-tabs>
</view> </view>
<swiper :style="{height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px'}" v-if="deviceInfo" <swiper
:list="tabs" :autoplay="false" :style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
:circular="true" :current="currnetIndex" @change="changeSwiper"> v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currnetIndex"
@change="changeSwiper"
>
<swiper-item> <swiper-item>
<LockInput :value="permanentAccount" title="接收者" placeholder="请输入手机号或邮箱" <LockInput
@changeInput="changePermanentAccountInput"></LockInput> :value="permanentAccount"
<LockInput :value="permanentName" title="姓名" placeholder="请输入姓名" title="接收者"
@changeInput="changePermanentNameInput"></LockInput> placeholder="请输入手机号或邮箱"
<view class="text" style="margin-top: 40rpx;">接收者可使用此小程序开关锁</view> @change-input="changePermanentAccountInput"
<view class="text" style="margin-bottom: 50rpx;">小程序暂不支持邮箱登录若接收者账号为邮箱可先使用星星锁APP登录绑定手机号后可使用小程序登录</view> ></LockInput>
<LockInput
:value="permanentName"
title="姓名"
placeholder="请输入姓名"
@change-input="changePermanentNameInput"
></LockInput>
<view class="text" style="margin-top: 40rpx">接收者可使用此小程序开关锁</view>
<view class="text" style="margin-bottom: 50rpx"
>小程序暂不支持邮箱登录若接收者账号为邮箱可先使用星星锁APP登录绑定手机号后可使用小程序登录</view
>
<view class="button" @click="createKey('permanent')">发送</view> <view class="button" @click="createKey('permanent')">发送</view>
</swiper-item> </swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }"> <swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput :value="temporaryAccount" title="接收者" placeholder="请输入手机号或邮箱" <LockInput
@changeInput="changeTemporaryAccountInput"></LockInput> :value="temporaryAccount"
<LockInput :value="temporaryName" title="姓名" placeholder="请输入姓名" title="接收者"
@changeInput="changeTemporaryNameInput"></LockInput> placeholder="请输入手机号或邮箱"
@change-input="changeTemporaryAccountInput"
></LockInput>
<LockInput
:value="temporaryName"
title="姓名"
placeholder="请输入姓名"
@change-input="changeTemporaryNameInput"
></LockInput>
<view style="margin-top: 20rpx"> <view style="margin-top: 20rpx">
<LockDatetimePicker title="生效时间" :value="temporaryValidTime" :minDate="minDate" <LockDatetimePicker
@changeTime="changeTemporaryValidTime" :maxDate="maxDate"></LockDatetimePicker> title="生效时间"
<LockDatetimePicker title="失效时间" :value="temporaryInvalidTime" :minDate="minDate" :value="temporaryValidTime"
@changeTime="changeTemporaryInvalidTime" :maxDate="maxDate"></LockDatetimePicker> :minDate="minDate"
@change-time="changeTemporaryValidTime"
:maxDate="maxDate"
></LockDatetimePicker>
<LockDatetimePicker
title="失效时间"
:value="temporaryInvalidTime"
:minDate="minDate"
@change-time="changeTemporaryInvalidTime"
:maxDate="maxDate"
></LockDatetimePicker>
</view> </view>
<view class="text" style="margin-top: 40rpx;">接收者在有效期内可以不限次数使用</view> <view class="text" style="margin-top: 40rpx">接收者在有效期内可以不限次数使用</view>
<view class="text" style="margin-bottom: 50rpx;">小程序暂不支持邮箱登录若接收者账号为邮箱可先使用星星锁APP登录绑定手机号后可使用小程序登录</view> <view class="text" style="margin-bottom: 50rpx"
>小程序暂不支持邮箱登录若接收者账号为邮箱可先使用星星锁APP登录绑定手机号后可使用小程序登录</view
>
<view class="button" @click="createKey('temporary')">发送</view> <view class="button" @click="createKey('temporary')">发送</view>
</swiper-item> </swiper-item>
</swiper> </swiper>
@ -38,25 +81,30 @@
</template> </template>
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { test } from 'uview-plus'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import LockInput from '@/components/LockInput/LockInput.vue' import LockInput from '@/components/LockInput/LockInput.vue'
import LockDatetimePicker from '@/components/LockDatetimePicker/LockDatetimePicker.vue' import LockDatetimePicker from '@/components/LockDatetimePicker/LockDatetimePicker.vue'
import { createPsaawordRequest } from '@/api/keyboardPwd'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { test } from 'uview-plus'
import { createKeyRequest } from '@/api/key' import { createKeyRequest } from '@/api/key'
export default { export default {
components: {
LockInput,
LockDatetimePicker
},
data() { data() {
return { return {
tabs: [{ tabs: [
{
name: '永久' name: '永久'
}, { },
{
name: '限时' name: '限时'
}], }
],
permanentName: '', permanentName: '',
permanentAccount: '', permanentAccount: '',
temporaryName: '', temporaryName: '',
@ -70,13 +118,9 @@ export default {
pending: false pending: false
} }
}, },
components: {
LockInput,
LockDatetimePicker
},
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo']), ...mapState(useBluetoothStore, ['currentLockInfo']),
...mapState(useLockStore, ['keySearch']), ...mapState(useLockStore, ['keySearch'])
}, },
async onLoad() { async onLoad() {
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
@ -93,9 +137,12 @@ export default {
return now.getTime() return now.getTime()
}, },
async createKey(type, createUser = false) { async createKey(type, createUser = false) {
if (
if ((type === 'temporary' && !(test.email(this.temporaryAccount) || test.mobile(this.temporaryAccount))) || (type === 'temporary' &&
(type === 'permanent' && !(test.email(this.permanentAccount) || test.mobile(this.permanentAccount)))) { !(test.email(this.temporaryAccount) || test.mobile(this.temporaryAccount))) ||
(type === 'permanent' &&
!(test.email(this.permanentAccount) || test.mobile(this.permanentAccount)))
) {
uni.showToast({ uni.showToast({
title: '请输入格式正确的手机号或邮箱', title: '请输入格式正确的手机号或邮箱',
icon: 'none' icon: 'none'
@ -149,8 +196,7 @@ export default {
} }
const { code, message } = await createKeyRequest(params) const { code, message } = await createKeyRequest(params)
if (code === 0) { if (code === 0) {
uni.reportEvent("create_key", { uni.reportEvent('create_key', {})
})
this.updateKeySearch({ this.updateKeySearch({
...this.keySearch, ...this.keySearch,
pageNo: 1 pageNo: 1
@ -162,7 +208,7 @@ export default {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: `是否发送电子钥匙给未注册账号\n${params.receiverUsername}`, content: `是否发送电子钥匙给未注册账号\n${params.receiverUsername}`,
success: async (res) => { success: async res => {
if (res.confirm) { if (res.confirm) {
await this.createKey(type, true) await this.createKey(type, true)
} }

View File

@ -1,26 +1,53 @@
<template> <template>
<view> <view>
<view class="tabs"> <view class="tabs">
<up-tabs :list="tabs" lineWidth="40rpx" lineHeight="5rpx" :current="currnetIndex" lineColor="#63b8af" <up-tabs
@click="clickTab" :inactiveStyle="{color:'#a3a3a3', fontSize: '32rpx', fontWeight: 'bold'}" :list="tabs"
:activeStyle="{color:'#63b8af', fontSize: '32rpx', fontWeight: 'bold'}"> lineWidth="40rpx"
lineHeight="5rpx"
:current="currnetIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs> </up-tabs>
</view> </view>
<swiper :style="{height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px'}" v-if="deviceInfo" <swiper
:list="tabs" :autoplay="false" :style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
:circular="true" :current="currnetIndex" @change="changeSwiper"> v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currnetIndex"
@change="changeSwiper"
>
<swiper-item> <swiper-item>
<LockInput :value="permanentName" title="姓名" placeholder="请给密码命名" <LockInput
@changeInput="changePermanentInput"></LockInput> :value="permanentName"
title="姓名"
placeholder="请给密码命名"
@change-input="changePermanentInput"
></LockInput>
<view class="text">{{ text }}</view> <view class="text">{{ text }}</view>
<view class="button" @click="createPassword('permanent')">获取密码</view> <view class="button" @click="createPassword('permanent')">获取密码</view>
</swiper-item> </swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }"> <swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput :value="temporaryName" title="姓名" placeholder="请给密码命名" <LockInput
@changeInput="changeTemporaryInput"></LockInput> :value="temporaryName"
title="姓名"
placeholder="请给密码命名"
@change-input="changeTemporaryInput"
></LockInput>
<view style="margin-top: 20rpx"> <view style="margin-top: 20rpx">
<LockDatetimePicker title="失效时间" :value="temporaryTime" :minDate="minDate" :maxDate="maxDate" type="datehour" <LockDatetimePicker
@changeTime="changeTemporaryTime"></LockDatetimePicker> title="失效时间"
:value="temporaryTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeTemporaryTime"
></LockDatetimePicker>
</view> </view>
<view class="text">{{ text }}</view> <view class="text">{{ text }}</view>
<view class="button" @click="createPassword('temporary')">获取密码</view> <view class="button" @click="createPassword('temporary')">获取密码</view>
@ -30,7 +57,6 @@
</template> </template>
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import LockInput from '@/components/LockInput/LockInput.vue' import LockInput from '@/components/LockInput/LockInput.vue'
@ -40,13 +66,20 @@ import { useBluetoothStore } from '@/stores/bluetooth'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
export default { export default {
components: {
LockInput,
LockDatetimePicker
},
data() { data() {
return { return {
tabs: [{ tabs: [
{
name: '永久' name: '永久'
}, { },
{
name: '限时' name: '限时'
}], }
],
permanentName: '', permanentName: '',
temporaryName: '', temporaryName: '',
temporaryTime: Number(new Date()), temporaryTime: Number(new Date()),
@ -58,13 +91,9 @@ export default {
text: '密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。' text: '密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。'
} }
}, },
components: {
LockInput,
LockDatetimePicker
},
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo']), ...mapState(useBluetoothStore, ['currentLockInfo']),
...mapState(useLockStore, ['passwordSearch']), ...mapState(useLockStore, ['passwordSearch'])
}, },
async onLoad() { async onLoad() {
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
@ -79,23 +108,23 @@ export default {
getNextFullHour() { getNextFullHour() {
const now = new Date() const now = new Date()
const currentHour = now.getHours() const currentHour = now.getHours()
now.setHours(currentHour); now.setHours(currentHour)
now.setMinutes(0); now.setMinutes(0)
now.setSeconds(0); now.setSeconds(0)
now.setMilliseconds(0); now.setMilliseconds(0)
return now; return now
}, },
getFutureTimestamp() { getFutureTimestamp() {
const currentDate = new Date(); const currentDate = new Date()
const year = currentDate.getFullYear(); const year = currentDate.getFullYear()
const month = currentDate.getMonth(); const month = currentDate.getMonth()
const day = currentDate.getDate(); const day = currentDate.getDate()
const futureDate = new Date(year + 3, month, day, 23, 0, 0); const futureDate = new Date(year + 3, month, day, 23, 0, 0)
return futureDate.getTime(); return futureDate.getTime()
}, },
setTime() { setTime() {
const now = new Date() const now = new Date()
@ -105,7 +134,10 @@ export default {
}, },
async createPassword(type) { async createPassword(type) {
const that = this const that = this
if((type === 'temporary' && this.temporaryName === '') || (type === 'permanent' && this.permanentName === '')) { if (
(type === 'temporary' && this.temporaryName === '') ||
(type === 'permanent' && this.permanentName === '')
) {
uni.showToast({ uni.showToast({
title: '名称不能为空', title: '名称不能为空',
icon: 'none' icon: 'none'
@ -145,9 +177,7 @@ export default {
} }
const { code, data, message } = await createPsaawordRequest(params) const { code, data, message } = await createPsaawordRequest(params)
if (code === 0) { if (code === 0) {
uni.reportEvent("create_password", { uni.reportEvent('create_password', {})
})
this.updatePasswordSearch({ this.updatePasswordSearch({
...this.passwordSearch, ...this.passwordSearch,
pageNo: 1 pageNo: 1
@ -157,7 +187,7 @@ export default {
title: '密码生成成功', title: '密码生成成功',
content: `密码:${data.keyboardPwd}`, content: `密码:${data.keyboardPwd}`,
cancelText: '复制', cancelText: '复制',
success: (res) => { success: res => {
if (res.confirm) { if (res.confirm) {
uni.navigateBack() uni.navigateBack()
} else { } else {

View File

@ -2,18 +2,43 @@
<view> <view>
<view v-if="!penging"> <view v-if="!penging">
<view v-if="isLogin"> <view v-if="isLogin">
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{ height: deviceInfo.windowHeight + 'px' }" <scroll-view
lower-threshold="100" @refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage" v-if="deviceInfo"
:refresher-triggered="refresherTriggered"> scroll-y="true"
<view class="search" v-if="!(lockList.length === 0 && lockSearch.searchStr === '' && !focus)"> :style="{ height: deviceInfo.windowHeight + 'px' }"
<up-search :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" @focus="getFocus" @blur="getBlur" lower-threshold="100"
:height="80" placeholder="搜索" :clearabled="false" @change="changeSearch" @refresherrefresh="refresherList"
v-model="lockSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="50"></up-search> :refresher-enabled="true"
@scrolltolower="nextPage"
:refresher-triggered="refresherTriggered"
>
<view
class="search"
v-if="!(lockList.length === 0 && lockSearch.searchStr === '' && !focus)"
>
<up-search
:searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
@focus="getFocus"
@blur="getBlur"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="lockSearch.searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></up-search>
</view> </view>
<view class="lock-list" v-if="!penging"> <view class="lock-list" v-if="!penging">
<view v-if="lockList.length === 0 && lockSearch.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
@click="toSearchDevice"></image> src="/static/images/icon_add_round.png"
mode="aspectFill"
class="button-add-big"
@click="toSearchDevice"
></image>
<view class="text">添加锁时手机必须在锁旁边</view> <view class="text">添加锁时手机必须在锁旁边</view>
</view> </view>
<view v-else> <view v-else>
@ -23,16 +48,27 @@
<view class="group-name-line"></view> <view class="group-name-line"></view>
</view> </view>
<up-swipe-action> <up-swipe-action>
<up-swipe-action-item class="lock" :ref="'swipeItem' + grounIndex" :options="options" v-for="(lock, <up-swipe-action-item
lockIndex) in group.lockList" :key="lock.lockId" :threshold="50" @click="deleteLock(lock, class="lock"
grounIndex, lockIndex)"> :ref="'swipeItem' + grounIndex"
:options="options"
v-for="(lock, lockIndex) in 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>
<view class="lock-top-right"> <view class="lock-top-right">
<view class="lock-top-right-power"> <view class="lock-top-right-power">
<image class="lock-top-right-power-image" :src="getPowerIcon(lock.electricQuantity)"></image> <image
<view class="lock-top-right-power-text">{{ lock.electricQuantity }}%</view> class="lock-top-right-power-image"
:src="getPowerIcon(lock.electricQuantity)"
></image>
<view class="lock-top-right-power-text"
>{{ lock.electricQuantity }}%</view
>
</view> </view>
<view>{{ getRole(lock.userType, lock.keyRight) }}</view> <view>{{ getRole(lock.userType, lock.keyRight) }}</view>
</view> </view>
@ -40,23 +76,50 @@
<view class="lock-name">{{ lock.lockAlias }}</view> <view class="lock-name">{{ lock.lockAlias }}</view>
<view style="display: flex; align-items: center"> <view style="display: flex; align-items: center">
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view> <view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">{{lock.days}}</view> <view v-if="lock.days" class="lock-status" style="background-color: #63b8af"
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view> >{{ lock.days }}</view
>
<view
v-if="lock.keyStatus === 110403"
class="lock-status"
style="background-color: #63b8af"
>未生效</view
>
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view> <view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
<view v-if="(lock.remoteEnable === 1 && lock.keyRight === 0) || <view
(lock.lockSetting.remoteUnlock === 1 && lock.keyRight === 1)" class="lock-status" v-if="
style="background-color: #63b8af">远程开锁 (lock.remoteEnable === 1 && lock.keyRight === 0) ||
(lock.lockSetting.remoteUnlock === 1 && lock.keyRight === 1)
"
class="lock-status"
style="background-color: #63b8af"
>远程开锁
</view> </view>
</view> </view>
<view class="lock-time" <view
:style="{padding: lock.keyStatus === 110401 && !lock.days && class="lock-time"
!((lock.remoteEnable === 1 && lock.keyRight === 0) || (lock.lockSetting.remoteUnlock === 1 :style="{
&& lock.keyRight === 1)) === 0 ? '12rpx 24rpx 0 24rpx' :'6rpx 24rpx 0 24rpx'}"> padding:
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{ lock.keyStatus === 110401 &&
getTimeLimit(lock.keyType) }}</view> !lock.days &&
!(
(lock.remoteEnable === 1 && lock.keyRight === 0) ||
(lock.lockSetting.remoteUnlock === 1 && lock.keyRight === 1)
) === 0
? '12rpx 24rpx 0 24rpx'
: '6rpx 24rpx 0 24rpx'
}"
>
<view
v-if="lock.keyType === 1 || lock.keyType === 3"
style="font-size: 32rpx"
>{{ getTimeLimit(lock.keyType) }}</view
>
<view v-else> <view v-else>
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view> <view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view> <view>{{
timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType)
}}</view>
</view> </view>
</view> </view>
</view> </view>
@ -66,8 +129,13 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<image v-if="lockList.length !== 0" src="/static/images/icon_add_round.png" mode="aspectFill" <image
class="button-add" @click="toSearchDevice"></image> v-if="lockList.length !== 0"
src="/static/images/icon_add_round.png"
mode="aspectFill"
class="button-add"
@click="toSearchDevice"
></image>
</view> </view>
<view v-else> <view v-else>
<view class="tips">因智能门锁与账号绑定登录为手机号登录</view> <view class="tips">因智能门锁与账号绑定登录为手机号登录</view>
@ -76,11 +144,22 @@
</label> </label>
</view> </view>
</view> </view>
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button> <button
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal" open-type="getPhoneNumber"
@confirm="confirmModal"> style="display: none"
id="phone"
@getphonenumber="getphonenumber"
></button>
<up-modal
:show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio"> <view class="slot-content" @click="changeRadio">
<view style="display: flex;align-items: center;"> <view style="display: flex; align-items: center">
<radio :checked="checked"></radio> <radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view> <view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view> </view>
@ -91,12 +170,12 @@
<script> <script>
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { mapState, mapActions } from 'pinia'
import { getUserInfoRequest, loginRequest } from '@/api/user' import { getUserInfoRequest, loginRequest } from '@/api/user'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { mapState, mapActions } from 'pinia'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { deleteLockRequest } from '@/api/lock' import { deleteLockRequest } from '@/api/lock'
import { setStorage, getStorage } from '../../utils/storage' import { setStorage, getStorage } from '../../utils/storage'
@ -108,12 +187,14 @@
focus: false, focus: false,
penging: true, penging: true,
deviceInfo: null, deviceInfo: null,
options: [{ options: [
{
text: '删除', text: '删除',
style: { style: {
backgroundColor: '#f56c6c' backgroundColor: '#f56c6c'
} }
}], }
],
showModal: false, showModal: false,
checked: false, checked: false,
deleteLockInfo: null deleteLockInfo: null
@ -122,7 +203,12 @@
computed: { computed: {
...mapState(useUserStore, ['userInfo', 'isLogin']), ...mapState(useUserStore, ['userInfo', 'isLogin']),
...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']), ...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']),
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth', 'keyId', 'currentLockInfo']), ...mapState(useBluetoothStore, [
'bluetoothStatus',
'isInitBluetooth',
'keyId',
'currentLockInfo'
])
}, },
async onLoad(data) { async onLoad(data) {
uni.showLoading({ uni.showLoading({
@ -135,10 +221,7 @@
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
const token = getStorage('token') const token = getStorage('token')
if (token) { if (token) {
await Promise.all([ await Promise.all([this.getLockList(this.lockSearch), this.getUserInfo()]).then(res => {
this.getLockList(this.lockSearch),
this.getUserInfo()
]).then((res) => {
this.penging = false this.penging = false
uni.hideLoading() uni.hideLoading()
const list = getStorage('lockList') const list = getStorage('lockList')
@ -163,10 +246,28 @@
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']), ...mapActions(useUserStore, [
...mapActions(useLockStore, ['getLockList', 'updateLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']), 'updateUserInfo',
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', 'updateLoginStatus',
'checkSetting', 'updateKeyId', 'resetDevice']), 'phoneLogin',
'getUserInfo'
]),
...mapActions(useLockStore, [
'getLockList',
'updateLockList',
'getRole',
'getTimeLimit',
'updateLockSearch',
'getPowerIcon'
]),
...mapActions(useBluetoothStore, [
'getBluetoothStatus',
'initAndListenBluetooth',
'updateCurrentLockInfo',
'checkSetting',
'updateKeyId',
'resetDevice'
]),
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType', 'shareJump']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType', 'shareJump']),
async deleteLock(lock, groupIndex, lockIndex) { async deleteLock(lock, groupIndex, lockIndex) {
const that = this const that = this
@ -181,21 +282,24 @@
this.showModal = true this.showModal = true
return return
} }
const message = lock.userType === 110301 ? '删除锁后,所有信息都会一起删除,确定删除锁吗?' : '确定删除该钥匙吗?' const message =
lock.userType === 110301
? '删除锁后,所有信息都会一起删除,确定删除锁吗?'
: '确定删除该钥匙吗?'
const data = { const data = {
...lock, ...lock,
name: lock.bluetooth.bluetoothDeviceName, name: lock.bluetooth.bluetoothDeviceName,
deviceId: lock.bluetooth.bluetoothDeviceId, deviceId: lock.bluetooth.bluetoothDeviceId,
commKey: lock.bluetooth.privateKey, commKey: lock.bluetooth.privateKey,
signKey: lock.bluetooth.signKey, signKey: lock.bluetooth.signKey,
publicKey: lock.bluetooth.publicKey, publicKey: lock.bluetooth.publicKey
} }
this.updateKeyId(lock.keyId.toString()) this.updateKeyId(lock.keyId.toString())
this.updateCurrentLockInfo(data) this.updateCurrentLockInfo(data)
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
success: async function (res) { async success(res) {
if (res.confirm) { if (res.confirm) {
uni.showLoading({ uni.showLoading({
title: '删除中', title: '删除中',
@ -295,10 +399,10 @@
}, },
homeLogin() { homeLogin() {
const that = this const that = this
return new Promise((resolve) => { return new Promise(resolve => {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: async function (loginRes) { async success(loginRes) {
const { code, data } = await loginRequest({ const { code, data } = await loginRequest({
js_code: loginRes.code js_code: loginRes.code
}) })
@ -322,7 +426,7 @@
resolve(false) resolve(false)
} }
}, },
fail: function () { fail() {
uni.showToast({ uni.showToast({
title: '登录失败,请重试', title: '登录失败,请重试',
icon: 'none' icon: 'none'
@ -439,7 +543,7 @@
deviceId: lock.bluetooth.bluetoothDeviceId, deviceId: lock.bluetooth.bluetoothDeviceId,
commKey: lock.bluetooth.privateKey, commKey: lock.bluetooth.privateKey,
signKey: lock.bluetooth.signKey, signKey: lock.bluetooth.signKey,
publicKey: lock.bluetooth.publicKey, publicKey: lock.bluetooth.publicKey
} }
this.updateKeyId(lock.keyId.toString()) this.updateKeyId(lock.keyId.toString())
this.updateCurrentLockInfo(data) this.updateCurrentLockInfo(data)
@ -529,7 +633,7 @@ page {
.lock { .lock {
width: 320rpx; width: 320rpx;
height: 300rpx; height: 300rpx;
background: #FFFFFF; background: #ffffff;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12); box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
border-radius: 32rpx; border-radius: 32rpx;
@ -602,7 +706,7 @@ page {
.group-name-line { .group-name-line {
flex-grow: 1; flex-grow: 1;
height: 3rpx; height: 3rpx;
background: #E5E5E5; background: #e5e5e5;
} }
} }
} }
@ -634,7 +738,7 @@ page {
.lock-status { .lock-status {
margin-top: 5rpx; margin-top: 5rpx;
margin-left: 24rpx; margin-left: 24rpx;
color: #FFFFFF; color: #ffffff;
border-radius: 8rpx; border-radius: 8rpx;
font-size: 22rpx; font-size: 22rpx;
font-weight: bold; font-weight: bold;

View File

@ -13,18 +13,24 @@
<view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd') }}</view> <view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd') }}</view>
</view> </view>
<view v-else> <view v-else>
<view class="item-content">{{ timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd h:M') }}</view> <view class="item-content">{{
timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd h:M')
}}</view>
<view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd h:M') }}</view> <view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
</view> </view>
</view> </view>
<view v-if="currentKeyInfo.keyType === 4" class="item" style="margin-top: 2rpx"> <view v-if="currentKeyInfo.keyType === 4" class="item" style="margin-top: 2rpx">
<view class="item-title">有效日</view> <view class="item-title">有效日</view>
<view class="item-content">{{ convertWeekDaysToChineseString(currentKeyInfo.weekDays) }}</view> <view class="item-content">{{
convertWeekDaysToChineseString(currentKeyInfo.weekDays)
}}</view>
</view> </view>
<view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx"> <view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx">
<view class="item-title">有效时间</view> <view class="item-title">有效时间</view>
<view class="item-content"> <view class="item-content">
{{ timeFormat(currentKeyInfo.startDate, 'h:M') }}{{ timeFormat(currentKeyInfo.endDate, 'h:M') }} {{ timeFormat(currentKeyInfo.startDate, 'h:M') }}{{
timeFormat(currentKeyInfo.endDate, 'h:M')
}}
</view> </view>
</view> </view>
<view class="item" style="margin-top: 20rpx"> <view class="item" style="margin-top: 20rpx">
@ -40,10 +46,16 @@
<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 class="button" @click="deleteKey">删除</view>
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal" <up-modal
@confirm="confirmModal"> :show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio"> <view class="slot-content" @click="changeRadio">
<view style="display: flex;align-items: center;"> <view style="display: flex; align-items: center">
<radio :checked="checked"></radio> <radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view> <view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view> </view>
@ -54,8 +66,8 @@
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useLockStore } from '@/stores/lock'
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { useLockStore } from '@/stores/lock'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
@ -67,11 +79,15 @@ export default {
} }
}, },
computed: { computed: {
...mapState(useLockStore, ['currentKeyInfo', 'keySearch']), ...mapState(useLockStore, ['currentKeyInfo', 'keySearch'])
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useLockStore, ['updateKeySearch', 'getKeyList', 'convertWeekDaysToChineseString']), ...mapActions(useLockStore, [
'updateKeySearch',
'getKeyList',
'convertWeekDaysToChineseString'
]),
...mapActions(useBasicStore, ['backAndToast']), ...mapActions(useBasicStore, ['backAndToast']),
cancelModal() { cancelModal() {
this.showModal = false this.showModal = false
@ -157,7 +173,7 @@ page {
<style lang="scss" scoped> <style lang="scss" scoped>
.item { .item {
padding: 24rpx 32rpx; padding: 24rpx 32rpx;
background-color: #FFFFFF; background-color: #ffffff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;

View File

@ -1,32 +1,74 @@
<template> <template>
<view> <view>
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px'}" lower-threshold="100" <scroll-view
@refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage" v-if="deviceInfo"
:refresher-triggered="refresherTriggered"> scroll-y="true"
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
lower-threshold="100"
@refresherrefresh="refresherList"
:refresher-enabled="true"
@scrolltolower="nextPage"
:refresher-triggered="refresherTriggered"
>
<view class="search"> <view class="search">
<up-search shape="square" :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" :height="80" placeholder="搜索" <up-search
:clearabled="false" @change="changeSearch" shape="square"
v-model="keySearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="50"></up-search> :searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="keySearch.searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></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="keyList.length === 0 && requestFinished"> <view v-if="keyList.length === 0 && requestFinished">
<image class="empty-list" src="/static/images/background_empty_list.png" mode="aspectFill"></image> <image
class="empty-list"
src="/static/images/background_empty_list.png"
mode="aspectFill"
></image>
<view class="empty-list-text">暂无数据</view> <view class="empty-list-text">暂无数据</view>
</view> </view>
<view v-else> <view v-else>
<up-swipe-action> <up-swipe-action>
<up-swipe-action-item ref="swipeItem" :options="options" v-for="(key, index) in keyList" <up-swipe-action-item
:key="key.keyboardPwdId" :threshold="50" @click="deleteKey(key)"> ref="swipeItem"
:options="options"
v-for="key in keyList"
: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 === '' ? '/static/images/icon_user.png' : key.headUrl" <image
mode="aspectFill"></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>
<image class="key-admin" mode="aspectFill" v-if="key.remoteEnable === 1" <image
src="/static/images/icon_remote_unlock.png"></image> class="key-admin"
<image class="key-admin" mode="aspectFill" v-if="key.keyRight === 1" src="/static/images/icon_admin.png"></image> mode="aspectFill"
<view class="key-status" :style="{ color: (key.keyStatus === 110401) ? '#63b8af' : '#df282d' }"> v-if="key.remoteEnable === 1"
src="/static/images/icon_remote_unlock.png"
></image>
<image
class="key-admin"
mode="aspectFill"
v-if="key.keyRight === 1"
src="/static/images/icon_admin.png"
></image>
<view
class="key-status"
:style="{ color: key.keyStatus === 110401 ? '#63b8af' : '#df282d' }"
>
{{ getKeyStatus(key.keyStatus) }} {{ getKeyStatus(key.keyStatus) }}
</view> </view>
</view> </view>
@ -43,10 +85,16 @@
<view class="button-reset" @click="resetKey">重置钥匙</view> <view class="button-reset" @click="resetKey">重置钥匙</view>
<view class="button-create" @click="toCreateKey">发送钥匙</view> <view class="button-create" @click="toCreateKey">发送钥匙</view>
</view> </view>
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal" <up-modal
@confirm="confirmModal"> :show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio"> <view class="slot-content" @click="changeRadio">
<view style="display: flex;align-items: center;"> <view style="display: flex; align-items: center">
<radio :checked="checked"></radio> <radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view> <view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view> </view>
@ -56,12 +104,11 @@
</template> </template>
<script> <script>
import { useBasicStore } from '@/stores/basic'
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useBasicStore } from '@/stores/basic'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { deletePsaawordRequest, resetPsaawordListRequest } from '@/api/keyboardPwd'
import { deleteKeyRequest, resetKeyRequest } from '@/api/key' import { deleteKeyRequest, resetKeyRequest } from '@/api/key'
export default { export default {
@ -72,19 +119,21 @@ export default {
deviceInfo: null, deviceInfo: null,
refresherTriggered: false, refresherTriggered: false,
requestFinished: false, requestFinished: false,
options: [{ options: [
{
text: '删除', text: '删除',
style: { style: {
backgroundColor: '#f56c6c' backgroundColor: '#f56c6c'
} }
}], }
],
deleteKeyId: '' deleteKeyId: ''
} }
}, },
computed: { computed: {
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useLockStore, ['keyTotal', 'keyList', 'keySearch']), ...mapState(useLockStore, ['keyTotal', 'keyList', 'keySearch'])
}, },
async onLoad() { async onLoad() {
uni.showLoading({ uni.showLoading({
@ -111,7 +160,13 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus', 'clearList']), ...mapActions(useLockStore, [
'getKeyList',
'updateCurrentKeyInfo',
'updateKeySearch',
'getKeyStatus',
'clearList'
]),
changeRadio() { changeRadio() {
this.checked = !this.checked this.checked = !this.checked
}, },
@ -214,7 +269,7 @@ export default {
async success(res) { async success(res) {
if (res.confirm) { if (res.confirm) {
const { code: requestCode, message } = await resetKeyRequest({ const { code: requestCode, message } = await resetKeyRequest({
lockId: that.currentLockInfo.lockId, lockId: that.currentLockInfo.lockId
}) })
console.log('重置钥匙返回', requestCode, message) console.log('重置钥匙返回', requestCode, message)
if (requestCode === 0) { if (requestCode === 0) {
@ -296,8 +351,8 @@ export default {
icon: 'none' icon: 'none'
}) })
} }
}, }
}, }
} }
</script> </script>
@ -347,7 +402,7 @@ page {
.key { .key {
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #FFFFFF; background-color: #ffffff;
height: 120rpx; height: 120rpx;
width: 750rpx; width: 750rpx;
@ -397,7 +452,7 @@ page {
.line { .line {
width: 100%; width: 100%;
height: 2rpx; height: 2rpx;
background: #EBEBEB; background: #ebebeb;
} }
.empty-list { .empty-list {

View File

@ -3,10 +3,18 @@
<view class="days" v-if="currentLockInfo.days">钥匙将在{{ currentLockInfo.days }}天后失效</view> <view class="days" v-if="currentLockInfo.days">钥匙将在{{ currentLockInfo.days }}天后失效</view>
<view class="lock-name">{{ currentLockInfo.lockAlias }}</view> <view class="lock-name">{{ currentLockInfo.lockAlias }}</view>
<view class="top"> <view class="top">
<image class="top-background" src="/static/images/background_main.jpg" mode="aspectFill"></image> <image
class="top-background"
src="/static/images/background_main.jpg"
mode="aspectFill"
></image>
<view style="width: 100%; height: 50rpx"> <view style="width: 100%; height: 50rpx">
<view class="power" @click="powerTip"> <view class="power" @click="powerTip">
<image class="power-icon" :src="getPowerIcon(currentLockInfo.electricQuantity)" mode="aspectFill"></image> <image
class="power-icon"
:src="getPowerIcon(currentLockInfo.electricQuantity)"
mode="aspectFill"
></image>
<view class="power-text">{{ currentLockInfo.electricQuantity }}%</view> <view class="power-text">{{ currentLockInfo.electricQuantity }}%</view>
<image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image> <image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image>
</view> </view>
@ -21,10 +29,20 @@
<view>{{ getRole(currentLockInfo.userType, currentLockInfo.keyRight) }}</view> <view>{{ getRole(currentLockInfo.userType, currentLockInfo.keyRight) }}</view>
</view> </view>
<view class="bottom-side"> <view class="bottom-side">
<image class="bottom-icon" :src=" currentLockInfo.lockSetting.appUnlockOnline ? <image
'/static/images/icon_cloud_active.png' : '/static/images/icon_cloud.png' " class="bottom-icon"
mode="aspectFill" style="width: 40rpx;height: 40rpx;"></image> :src="
<view :style="{color: currentLockInfo.lockSetting.appUnlockOnline ? '#63b8af' : '#a3a3a3'}">手机需联网</view> currentLockInfo.lockSetting.appUnlockOnline
? '/static/images/icon_cloud_active.png'
: '/static/images/icon_cloud.png'
"
mode="aspectFill"
style="width: 40rpx; height: 40rpx"
></image>
<view
:style="{ color: currentLockInfo.lockSetting.appUnlockOnline ? '#63b8af' : '#a3a3a3' }"
>手机需联网</view
>
</view> </view>
</view> </view>
</view> </view>
@ -34,13 +52,19 @@
<view>功能</view> <view>功能</view>
</view> </view>
<view class="menu-main"> <view class="menu-main">
<view v-if="currentLockInfo.keyRight === 1" <view
class="menu-main-view" @click="routeJump({ name: 'keyList' })"> v-if="currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'keyList' })"
>
<image class="menu-main-image" src="/static/images/tabbar_key_select.png"></image> <image class="menu-main-image" src="/static/images/tabbar_key_select.png"></image>
<view>电子钥匙</view> <view>电子钥匙</view>
</view> </view>
<view v-if="currentLockInfo.lockFeature.password || currentLockInfo.keyRight === 1" <view
class="menu-main-view" @click="routeJump({ name: 'passwordList' })"> v-if="currentLockInfo.lockFeature.password || currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'passwordList' })"
>
<image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image> <image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image>
<view>密码</view> <view>密码</view>
</view> </view>
@ -51,11 +75,23 @@
<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"> <up-popup
:show="show"
@close="closePopup"
mode="center"
:closeOnClickOverlay="true"
bgColor="transparent"
>
<view class="popup" @click="closePopup"> <view class="popup" @click="closePopup">
<image class="popup-background" :src="type === 'close' ? '/static/images/background_close_door.png' : <image
'/static/images/background_open_door.png'" class="popup-background"
mode="aspectFill"></image> :src="
type === 'close'
? '/static/images/background_close_door.png'
: '/static/images/background_open_door.png'
"
mode="aspectFill"
/>
<view> <view>
<view class="popup-name">{{ currentLockInfo.lockAlias }}</view> <view class="popup-name">{{ currentLockInfo.lockAlias }}</view>
<view class="popup-time">{{ timeFormat('', 'mm/dd h:M') }}</view> <view class="popup-time">{{ timeFormat('', 'mm/dd h:M') }}</view>
@ -66,14 +102,14 @@
</template> </template>
<script> <script>
import { mapState, mapActions } from 'pinia'
import { timeFormat } from 'uview-plus'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { mapState, mapActions } from 'pinia'
import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue' import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { getLockNetTokenRequest } from '@/api/lock' import { getLockNetTokenRequest } from '@/api/lock'
import { timeFormat } from 'uview-plus'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
export default { export default {
@ -89,7 +125,7 @@ export default {
computed: { computed: {
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useLockStore, ['lockSearch']), ...mapState(useLockStore, ['lockSearch'])
}, },
components: { components: {
SwitchLoading SwitchLoading
@ -100,7 +136,11 @@ export default {
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']), ...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp', 'closeBluetoothConnection']), ...mapActions(useBluetoothStore, [
'openDoor',
'updateServerTimestamp',
'closeBluetoothConnection'
]),
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']), ...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
closePopup() { closePopup() {
this.show = false this.show = false
@ -122,25 +162,26 @@ export default {
if (code === 0) { if (code === 0) {
this.onlineToken = data.token this.onlineToken = data.token
return true return true
} else { }
uni.showToast({ uni.showToast({
title: message, title: message,
icon: 'none' icon: 'none'
}) })
return false return false
}
}, },
async getServeTime() { async getServeTime() {
const { code, data } = await this.updateServerTimestamp() const { code, data } = await this.updateServerTimestamp()
if (code === 0) { if (code === 0) {
this.time = parseInt((data.date - new Date().getTime()) / 1000) this.time = parseInt((data.date - new Date().getTime()) / 1000, 10)
} }
}, },
async openDoorOperate(type) { async openDoorOperate(type) {
const timestamp = new Date().getTime() const timestamp = new Date().getTime()
if(this.currentLockInfo.faceAuthentication === 1 && if (
((this.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + this.time * 1000) && this.currentLockInfo.faceAuthentication === 1 &&
this.currentLockInfo.nextFaceValidateTime !== 0)) { this.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + this.time * 1000 &&
this.currentLockInfo.nextFaceValidateTime !== 0
) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '开门前需进行实名认证小程序暂不支持请使用APP认证开门', content: '开门前需进行实名认证小程序暂不支持请使用APP认证开门',
@ -183,18 +224,18 @@ export default {
const { code } = await this.openDoor({ const { code } = await this.openDoor({
name: this.currentLockInfo.name, name: this.currentLockInfo.name,
uid: this.userInfo.uid.toString(), uid: this.userInfo.uid.toString(),
openMode: openMode, openMode,
openTime: parseInt(new Date().getTime() / 1000) + this.time, openTime: parseInt(new Date().getTime() / 1000, 10) + this.time,
onlineToken: this.onlineToken onlineToken: this.onlineToken
}) })
this.closeBluetoothConnection() this.closeBluetoothConnection()
if (type === 'open') { if (type === 'open') {
uni.reportEvent("open_door", { uni.reportEvent('open_door', {
result: code, result: code,
duration: new Date().getTime() - timestamp duration: new Date().getTime() - timestamp
}) })
} else if (type === 'close') { } else if (type === 'close') {
uni.reportEvent("close_door", { uni.reportEvent('close_door', {
result: code, result: code,
duration: new Date().getTime() - timestamp duration: new Date().getTime() - timestamp
}) })
@ -318,7 +359,7 @@ export default {
align-items: center; align-items: center;
width: 250rpx; width: 250rpx;
height: 250rpx; height: 250rpx;
background: #FFFFFF; background: #ffffff;
border-radius: 50%; border-radius: 50%;
box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12); box-shadow: 0 8rpx 36rpx 0 rgba(0, 0, 0, 0.12);
} }

View File

@ -32,7 +32,9 @@
<view class="env" v-if="env"> <view class="env" v-if="env">
<view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view> <view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view>
<view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view> <view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view>
<view v-if="envVersion !== 'release' && env" class="env-button" @click="show=true">切换环境</view> <view v-if="envVersion !== 'release' && env" class="env-button" @click="show = true"
>切换环境</view
>
</view> </view>
<label for="changePhone"> <label for="changePhone">
<view class="switch-account">切换账号</view> <view class="switch-account">切换账号</view>
@ -46,26 +48,47 @@
<view class="env" v-if="env"> <view class="env" v-if="env">
<view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view> <view class="env-text">{{ env.name }} {{ env.version }}+{{ env.buildNumber }}</view>
<view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view> <view>{{ env.baseUrl.split('/').slice(0, 3).join('/') }}</view>
<view v-if="envVersion !== 'release' && env" class="env-button" @click="show=true">切换环境</view> <view v-if="envVersion !== 'release' && env" class="env-button" @click="show = true"
>切换环境</view
>
</view> </view>
</view> </view>
</view> </view>
<button open-type="contact" style="display: none" id="contact"></button> <button open-type="contact" style="display: none" id="contact"></button>
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button> <button
<button open-type="getPhoneNumber" style="display:none" id="changePhone" @getphonenumber="changePhone"></button> open-type="getPhoneNumber"
<up-action-sheet :actions="envList" :closeOnClickOverlay="true" title="切换环境" cancelText="取消" :closeOnClickAction="true" style="display: none"
:show="show" :safeAreaInsetBottom="true" @close="show=false" @select="selectEnv"></up-action-sheet> id="phone"
@getphonenumber="getphonenumber"
></button>
<button
open-type="getPhoneNumber"
style="display: none"
id="changePhone"
@getphonenumber="changePhone"
></button>
<up-action-sheet
:actions="envList"
:closeOnClickOverlay="true"
title="切换环境"
cancelText="取消"
:closeOnClickAction="true"
:show="show"
:safeAreaInsetBottom="true"
@close="show = false"
@select="selectEnv"
></up-action-sheet>
</template> </template>
<script> <script>
import { mapState, mapActions } from 'pinia'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { mapState, mapActions } from 'pinia'
import { phoneLoginRequest } from '@/api/user' import { phoneLoginRequest } from '@/api/user'
import env from '@/config/env' import env from '@/config/env'
import { setStorage, getStorage, removeStorage } from '@/utils/storage' import { setStorage, getStorage, removeStorage } from '@/utils/storage'
import { useNotificationStore } from '../../stores/notification' import { useNotificationStore } from '@/stores/notification'
export default { export default {
data() { data() {
@ -86,10 +109,11 @@
this.buttonInfo = await this.getButtonInfo() this.buttonInfo = await this.getButtonInfo()
this.env = await env[await getApp().globalData.getEnvConfig()] this.env = await env[await getApp().globalData.getEnvConfig()]
this.envVersion = getApp().globalData.envVersion this.envVersion = getApp().globalData.envVersion
// eslint-disable-next-line guard-for-in,no-restricted-syntax
for (let key in env) { for (let key in env) {
this.envList.push({ this.envList.push({
...env[key], ...env[key],
key: key key
}) })
} }
console.log(this.envList) console.log(this.envList)
@ -98,8 +122,13 @@
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']), ...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch']), ...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch']),
...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo', ...mapActions(useUserStore, [
'checkSession']), 'updateLoginStatus',
'phoneLogin',
'updateUserInfo',
'getUserInfo',
'checkSession'
]),
selectEnv(env) { selectEnv(env) {
setStorage('envVersion', env.key) setStorage('envVersion', env.key)
removeStorage('token') removeStorage('token')
@ -148,7 +177,7 @@
icon: 'none' icon: 'none'
}) })
} else if (code === 438) { } else if (code === 438) {
/* empty */
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,
@ -194,7 +223,6 @@ page {
} }
</style> </style>
<style scoped lang="scss"> <style scoped lang="scss">
.background-image { .background-image {
margin-top: 32rpx; margin-top: 32rpx;
@ -209,7 +237,7 @@ page {
border-radius: 32rpx; border-radius: 32rpx;
width: 710rpx; width: 710rpx;
margin-left: 20rpx; margin-left: 20rpx;
background: #FFFFFF; background: #ffffff;
} }
.view-button { .view-button {
@ -231,7 +259,7 @@ page {
.view-line { .view-line {
width: 100%; width: 100%;
height: 3rpx; height: 3rpx;
background: #EBEBEB; background: #ebebeb;
} }
.switch-account { .switch-account {
@ -266,7 +294,7 @@ page {
.env-button { .env-button {
background: inherit; background: inherit;
color: #022b7c; color: #022b7c;
font-size: .8rem; font-size: 0.8rem;
text-align: right; text-align: right;
text-decoration: underline; text-decoration: underline;
} }

View File

@ -19,8 +19,8 @@ export default {
console.log(this.notification) console.log(this.notification)
}, },
methods: { methods: {
timeFormat, timeFormat
}, }
} }
</script> </script>

View File

@ -1,28 +1,63 @@
<template> <template>
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{ height: deviceInfo.windowHeight + 'px' }" <scroll-view
lower-threshold="100" @refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage" v-if="deviceInfo"
:refresher-triggered="refresherTriggered" @scroll="scroll"> scroll-y="true"
:style="{ height: deviceInfo.windowHeight + 'px' }"
lower-threshold="100"
@refresherrefresh="refresherList"
:refresher-enabled="true"
@scrolltolower="nextPage"
:refresher-triggered="refresherTriggered"
@scroll="scroll"
>
<view v-if="isLogin"> <view v-if="isLogin">
<view class="list" v-if="requestFinished"> <view class="list" v-if="requestFinished">
<view v-if="notificationList.length === 0"> <view v-if="notificationList.length === 0">
<image class="empty-list" src="/static/images/background_empty_list.png" mode="aspectFill"></image> <image
class="empty-list"
src="/static/images/background_empty_list.png"
mode="aspectFill"
></image>
<view class="empty-list-text">暂无数据</view> <view class="empty-list-text">暂无数据</view>
</view> </view>
<up-swipe-action v-else> <up-swipe-action v-else>
<up-swipe-action-item class="item" ref="swipeItem" :options="options" <up-swipe-action-item
v-for="(notification,index) in notificationList" :key="notification.id" class="item"
:threshold="50" @click="deleteNotification(notification, index)" :index="index" ref="swipeItem"
:name="index"> :options="options"
v-for="(notification, index) in notificationList"
:key="notification.id"
:threshold="50"
@click="deleteNotification(notification, index)"
:index="index"
:name="index"
>
<view class="notification" @click="toDetail(index, notification)"> <view class="notification" @click="toDetail(index, notification)">
<view v-if="notification.readAt === 0"> <view v-if="notification.readAt === 0">
<image class="icon" src="/static/images/icon_notification_unread.png" mode="aspectFill"></image> <image
class="icon"
src="/static/images/icon_notification_unread.png"
mode="aspectFill"
></image>
<view class="point"></view> <view class="point"></view>
</view> </view>
<image v-else class="icon" src="/static/images/icon_notification_read.png" mode="aspectFill"></image> <image
v-else
class="icon"
src="/static/images/icon_notification_read.png"
mode="aspectFill"
></image>
<view> <view>
<view class="content" :style="{color:notification.readAt === 0?'#000000':'#6c6c6c'}">{{ notification.data <view
}}</view> class="content"
<view class="time" :style="{color:notification.readAt === 0?'#000000':'#6c6c6c'}">{{ timeFormat(notification.createdAt, 'yyyy-mm-dd h:M') }}</view> :style="{ color: notification.readAt === 0 ? '#000000' : '#6c6c6c' }"
>{{ notification.data }}</view
>
<view
class="time"
:style="{ color: notification.readAt === 0 ? '#000000' : '#6c6c6c' }"
>{{ timeFormat(notification.createdAt, 'yyyy-mm-dd h:M') }}</view
>
</view> </view>
</view> </view>
</up-swipe-action-item> </up-swipe-action-item>
@ -36,19 +71,31 @@
</label> </label>
</view> </view>
</scroll-view> </scroll-view>
<view class="delete" @click="deleteAllNotification" v-if="isLogin && requestFinished && notificationList.length !== <view
0"> class="delete"
<image class="delete-image" src="/static/images/icon_delete.png" mode="aspectFill"></image> @click="deleteAllNotification"
v-if="isLogin && requestFinished && notificationList.length !== 0"
>
<image class="delete-image" src="/static/images/icon_delete.png" mode="aspectFill" />
</view> </view>
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button> <button
open-type="getPhoneNumber"
style="display: none"
id="phone"
@getphonenumber="getphonenumber"
></button>
</template> </template>
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { timeFormat } from 'uview-plus'
import { useNotificationStore } from '@/stores/notification' import { useNotificationStore } from '@/stores/notification'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { timeFormat } from 'uview-plus' import {
import { deleteAllNotification, deleteNotification, markAsReadNotification } from '@/api/notification' deleteAllNotification,
deleteNotification,
markAsReadNotification
} from '@/api/notification'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
export default { export default {
@ -57,17 +104,23 @@ export default {
refresherTriggered: false, refresherTriggered: false,
requestFinished: false, requestFinished: false,
deviceInfo: null, deviceInfo: null,
options: [{ options: [
{
text: '删除', text: '删除',
style: { style: {
backgroundColor: '#f56c6c' backgroundColor: '#f56c6c'
} }
}], }
]
} }
}, },
computed: { computed: {
...mapState(useNotificationStore, ['notificationTotal', 'notificationList', 'notificationSearch']), ...mapState(useNotificationStore, [
...mapState(useUserStore, ['isLogin']), 'notificationTotal',
'notificationList',
'notificationSearch'
]),
...mapState(useUserStore, ['isLogin'])
}, },
async onLoad() { async onLoad() {
this.deviceInfo = await this.getDeviceInfo() this.deviceInfo = await this.getDeviceInfo()
@ -78,7 +131,12 @@ export default {
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useNotificationStore, ['getNotificationList', 'updateNotificationSearch', 'updateNotificationItem','deleteNotificationItem']), ...mapActions(useNotificationStore, [
'getNotificationList',
'updateNotificationSearch',
'updateNotificationItem',
'deleteNotificationItem'
]),
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']),
...mapActions(useUserStore, ['phoneLogin']), ...mapActions(useUserStore, ['phoneLogin']),
async getList() { async getList() {
@ -127,7 +185,7 @@ export default {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要删除该通知吗?', content: '确定要删除该通知吗?',
success: async (res) => { success: async res => {
if (res.confirm) { if (res.confirm) {
const { code, message } = await deleteNotification({ const { code, message } = await deleteNotification({
id: notification.id id: notification.id
@ -152,7 +210,7 @@ export default {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要删除所有通知吗?', content: '确定要删除所有通知吗?',
success: async (res) => { success: async res => {
if (res.confirm) { if (res.confirm) {
const { code, message } = await deleteAllNotification() const { code, message } = await deleteAllNotification()
if (code === 0) { if (code === 0) {
@ -209,7 +267,10 @@ export default {
this.refresherTriggered = false this.refresherTriggered = false
}, },
async nextPage() { async nextPage() {
if(this.notificationTotal <= this.notificationSearch.pageNo * this.notificationSearch.pageSize) { if (
this.notificationTotal <=
this.notificationSearch.pageNo * this.notificationSearch.pageSize
) {
return return
} }
const pageNo = this.notificationSearch.pageNo + 1 const pageNo = this.notificationSearch.pageNo + 1
@ -228,8 +289,8 @@ export default {
icon: 'none' icon: 'none'
}) })
} }
}, }
}, }
} }
</script> </script>

View File

@ -12,8 +12,12 @@
<view class="item-title">有效期</view> <view class="item-title">有效期</view>
<view v-if="currentPasswordInfo.keyboardPwdType === 2">永久</view> <view v-if="currentPasswordInfo.keyboardPwdType === 2">永久</view>
<view v-else-if="currentPasswordInfo.keyboardPwdType <= 4"> <view v-else-if="currentPasswordInfo.keyboardPwdType <= 4">
<view class="item-content">{{ timeFormat(currentPasswordInfo.startDate, 'yyyy-mm-dd h:M') }}</view> <view class="item-content">{{
<view class="item-content">{{ timeFormat(currentPasswordInfo.endDate, 'yyyy-mm-dd h:M') }}</view> timeFormat(currentPasswordInfo.startDate, 'yyyy-mm-dd h:M')
}}</view>
<view class="item-content">{{
timeFormat(currentPasswordInfo.endDate, 'yyyy-mm-dd h:M')
}}</view>
</view> </view>
<view v-else> <view v-else>
{{ currentPasswordInfo.timeText.slice(0, -3) }} {{ currentPasswordInfo.timeText.slice(0, -3) }}
@ -25,7 +29,9 @@
</view> </view>
<view class="item" style="margin-top: 2rpx"> <view class="item" style="margin-top: 2rpx">
<view class="item-title">发送时间</view> <view class="item-title">发送时间</view>
<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="button" @click="deletePassword">删除</view> <view class="button" @click="deletePassword">删除</view>
</view> </view>
@ -33,8 +39,8 @@
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useLockStore } from '@/stores/lock'
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { useLockStore } from '@/stores/lock'
import { deletePsaawordRequest } from '@/api/keyboardPwd' import { deletePsaawordRequest } from '@/api/keyboardPwd'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
@ -69,7 +75,7 @@ export default {
title: '删除中', title: '删除中',
mask: true mask: true
}) })
const timestamp = parseInt(new Date().getTime() / 1000) const timestamp = parseInt(new Date().getTime() / 1000, 10)
const { code } = await that.setLockPassword({ const { code } = await that.setLockPassword({
keyId: that.keyId.toString(), keyId: that.keyId.toString(),
uid: that.userInfo.uid.toString(), uid: that.userInfo.uid.toString(),
@ -77,7 +83,7 @@ export default {
operate: 3, operate: 3,
isAdmin: that.currentPasswordInfo.pwdRight, isAdmin: that.currentPasswordInfo.pwdRight,
pwd: that.currentPasswordInfo.keyboardPwd, pwd: that.currentPasswordInfo.keyboardPwd,
userCountLimit: 0xFFFF, userCountLimit: 0xffff,
startTime: timestamp, startTime: timestamp,
endTime: timestamp endTime: timestamp
}) })
@ -125,14 +131,13 @@ page {
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.item-title { .item-title {
width: 350rpx; width: 350rpx;
} }
.item { .item {
padding: 24rpx 32rpx; padding: 24rpx 32rpx;
background-color: #FFFFFF; background-color: #ffffff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;

View File

@ -1,24 +1,55 @@
<template> <template>
<view> <view>
<scroll-view v-if="deviceInfo" scroll-y="true" :style="{height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px'}" lower-threshold="100" <scroll-view
@refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage" v-if="deviceInfo"
:refresher-triggered="refresherTriggered"> scroll-y="true"
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
lower-threshold="100"
@refresherrefresh="refresherList"
:refresher-enabled="true"
@scrolltolower="nextPage"
:refresher-triggered="refresherTriggered"
>
<view class="search"> <view class="search">
<up-search shape="square" :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" :height="80" placeholder="搜索" <up-search
:clearabled="false" @change="changeSearch" shape="square"
v-model="passwordSearch.searchStr" bgColor="#ffffff" :showAction="false" maxlength="50"></up-search> :searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="passwordSearch.searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></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">
<image class="empty-list" src="/static/images/background_empty_list.png" mode="aspectFill"></image> <image
class="empty-list"
src="/static/images/background_empty_list.png"
mode="aspectFill"
></image>
<view class="empty-list-text">暂无数据</view> <view class="empty-list-text">暂无数据</view>
</view> </view>
<view v-else> <view v-else>
<up-swipe-action> <up-swipe-action>
<up-swipe-action-item ref="swipeItem" :options="options" v-for="(password, index) in passwordList" <up-swipe-action-item
:key="password.keyboardPwdId" :threshold="50" @click="deletePassword(password)"> ref="swipeItem"
:options="options"
v-for="password in passwordList"
: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_password.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>
@ -43,8 +74,8 @@
</template> </template>
<script> <script>
import { useBasicStore } from '@/stores/basic'
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useBasicStore } from '@/stores/basic'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
@ -56,18 +87,20 @@ export default {
deviceInfo: null, deviceInfo: null,
refresherTriggered: false, refresherTriggered: false,
requestFinished: false, requestFinished: false,
options: [{ options: [
{
text: '删除', text: '删除',
style: { style: {
backgroundColor: '#f56c6c' backgroundColor: '#f56c6c'
} }
}] }
]
} }
}, },
computed: { computed: {
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo']),
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useLockStore, ['passwordTotal', 'passwordList', 'passwordSearch']), ...mapState(useLockStore, ['passwordTotal', 'passwordList', 'passwordSearch'])
}, },
async onLoad() { async onLoad() {
uni.showLoading({ uni.showLoading({
@ -95,9 +128,18 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']),
...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', ...mapActions(useLockStore, [
'getPasswordStatus', 'clearList']), 'getPasswordList',
...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']), 'updateCurrentPasswordInfo',
'updatePasswordSearch',
'getPasswordStatus',
'clearList'
]),
...mapActions(useBluetoothStore, [
'resetLockPassword',
'setLockPassword',
'closeBluetoothConnection'
]),
toPasswordDetail(password) { toPasswordDetail(password) {
this.updateCurrentPasswordInfo(password) this.updateCurrentPasswordInfo(password)
this.routeJump({ this.routeJump({
@ -111,7 +153,9 @@ export default {
} }
const password = data const password = data
const that = this const that = this
let index = this.passwordList.findIndex(item => item.keyboardPwdId === password.keyboardPwdId) let index = this.passwordList.findIndex(
item => item.keyboardPwdId === password.keyboardPwdId
)
that.$refs.swipeItem[index].closeHandler() that.$refs.swipeItem[index].closeHandler()
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
@ -122,7 +166,7 @@ export default {
title: '删除中', title: '删除中',
mask: true mask: true
}) })
const timestamp = parseInt(new Date().getTime() / 1000) const timestamp = parseInt(new Date().getTime() / 1000, 10)
const { code } = await that.setLockPassword({ const { code } = await that.setLockPassword({
keyId: that.keyId.toString(), keyId: that.keyId.toString(),
uid: that.userInfo.uid.toString(), uid: that.userInfo.uid.toString(),
@ -130,7 +174,7 @@ export default {
operate: 3, operate: 3,
isAdmin: password.pwdRight, isAdmin: password.pwdRight,
pwd: password.keyboardPwd, pwd: password.keyboardPwd,
userCountLimit: 0xFFFF, userCountLimit: 0xffff,
startTime: timestamp, startTime: timestamp,
endTime: timestamp endTime: timestamp
}) })
@ -261,8 +305,8 @@ export default {
} }
const { code, message } = await this.getPasswordList(params) const { code, message } = await this.getPasswordList(params)
if (code === 0) { if (code === 0) {
that.updatePasswordSearch({ this.updatePasswordSearch({
...that.passwordSearch, ...this.passwordSearch,
pageNo pageNo
}) })
} else { } else {
@ -284,8 +328,8 @@ export default {
icon: 'none' icon: 'none'
}) })
} }
}, }
}, }
} }
</script> </script>
@ -335,7 +379,7 @@ page {
.password { .password {
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #FFFFFF; background-color: #ffffff;
height: 120rpx; height: 120rpx;
width: 750rpx; width: 750rpx;
@ -370,7 +414,7 @@ page {
.line { .line {
width: 100%; width: 100%;
height: 2rpx; height: 2rpx;
background: #EBEBEB; background: #ebebeb;
} }
.empty-list { .empty-list {

View File

@ -1,9 +1,19 @@
<template> <template>
<view> <view>
<scroll-view v-if="deviceInfo" class="scroll-view" scroll-y="true" :style="{ height: deviceInfo.screenHeight - deviceInfo.statusBarHeight + 'px' }"> <scroll-view
v-if="deviceInfo"
class="scroll-view"
scroll-y="true"
:style="{ height: deviceInfo.screenHeight - deviceInfo.statusBarHeight + 'px' }"
>
<view style="padding-bottom: calc(env(safe-area-inset-bottom) + 300rpx)"> <view style="padding-bottom: calc(env(safe-area-inset-bottom) + 300rpx)">
<view class="device" v-for="device in deviceList" @click="connect(device)"> <view
<view class="device" style="justify-content:flex-start;"> class="device"
v-for="(device, index) in deviceList"
:key="index"
@click="connect(device)"
>
<view class="device" style="justify-content: flex-start">
<image class="device-lock" src="/static/images/icon_door_lock.png"></image> <image class="device-lock" src="/static/images/icon_door_lock.png"></image>
<view class="device-name">{{ device.name }}</view> <view class="device-name">{{ device.name }}</view>
</view> </view>
@ -12,7 +22,12 @@
</view> </view>
</scroll-view> </scroll-view>
<view class="loading"> <view class="loading">
<up-loading-icon size="80rpx" text="搜索中" :vertical="true" textSize="32rpx"></up-loading-icon> <up-loading-icon
size="80rpx"
text="搜索中"
:vertical="true"
textSize="32rpx"
></up-loading-icon>
</view> </view>
</view> </view>
</template> </template>
@ -41,8 +56,16 @@ export default {
this.stopGetBluetoothDevices() this.stopGetBluetoothDevices()
}, },
methods: { methods: {
...mapActions(useBluetoothStore, ['getBluetoothDevices', 'stopGetBluetoothDevices', 'updateCurrentLockInfo', ...mapActions(useBluetoothStore, [
'getPublicKey', 'getCommKey', 'connectBluetoothDevice', 'updateServerTimestamp', 'getLockStatus']), 'getBluetoothDevices',
'stopGetBluetoothDevices',
'updateCurrentLockInfo',
'getPublicKey',
'getCommKey',
'connectBluetoothDevice',
'updateServerTimestamp',
'getLockStatus'
]),
...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']), ...mapActions(useBasicStore, ['getDeviceInfo', 'routeJump', 'getNetworkType']),
async connect(device) { async connect(device) {
const netWork = await this.getNetworkType() const netWork = await this.getNetworkType()
@ -80,8 +103,12 @@ export default {
}) })
return return
} }
const { code: getCommKeyCode } = await this.getCommKey(this.currentLockInfo.name, this.keyId, const { code: getCommKeyCode } = await this.getCommKey(
this.userInfo.uid.toString(), this.serverTimestamp) this.currentLockInfo.name,
this.keyId,
this.userInfo.uid.toString(),
this.serverTimestamp
)
console.log('获取私钥返回', getCommKeyCode) console.log('获取私钥返回', getCommKeyCode)
if (getCommKeyCode !== 0) { if (getCommKeyCode !== 0) {
uni.hideLoading() uni.hideLoading()
@ -92,7 +119,7 @@ export default {
return return
} }
const date = new Date() const date = new Date()
const timestamp = parseInt(date.getTime() / 1000) - date.getTimezoneOffset() * 60 const timestamp = parseInt(date.getTime() / 1000, 10) - date.getTimezoneOffset() * 60
const { code } = await this.getLockStatus({ const { code } = await this.getLockStatus({
name: this.currentLockInfo.name, name: this.currentLockInfo.name,
uid: this.userInfo.uid, uid: this.userInfo.uid,

View File

@ -2,12 +2,22 @@
<view> <view>
<view class="title">地理位置</view> <view class="title">地理位置</view>
<view v-if="show"> <view v-if="show">
<map class="map" :longitude="longitude" :latitude="latitude" :scale="16" :markers="markers" <map
:enable-zoom="true" :enable-scroll="true"></map> class="map"
:longitude="longitude"
:latitude="latitude"
:scale="16"
:markers="markers"
:enable-zoom="true"
:enable-scroll="true"
></map>
</view> </view>
<view v-else class="map"></view> <view v-else class="map"></view>
<view class="explain">检查以确保以下地址是正确的</view> <view class="explain">检查以确保以下地址是正确的</view>
<view class="view-address" :style="{height: calculateStringTotalWidth(address) > 44 ? '120rpx' : '80rpx'}"> <view
class="view-address"
:style="{ height: calculateStringTotalWidth(address) > 44 ? '120rpx' : '80rpx' }"
>
<view class="address">{{ address }}</view> <view class="address">{{ address }}</view>
</view> </view>
<view class="bottom"> <view class="bottom">
@ -18,9 +28,8 @@
</template> </template>
<script> <script>
import { test } from 'uview-plus'
import { useBasicStore } from '@/stores/basic'
import { mapState, mapActions } from 'pinia' import { mapState, mapActions } from 'pinia'
import { useBasicStore } from '@/stores/basic'
import { getGeocodeAddress } from '@/api/geocode' import { getGeocodeAddress } from '@/api/geocode'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
@ -44,11 +53,9 @@ export default {
onShow() { onShow() {
if (this.first) { if (this.first) {
this.first = false this.first = false
} else { } else if (!this.show) {
if(!this.show) {
this.getLocation() this.getLocation()
} }
}
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'calculateStringTotalWidth']), ...mapActions(useBasicStore, ['routeJump', 'calculateStringTotalWidth']),
@ -60,7 +67,7 @@ export default {
title: '提示', title: '提示',
content: '暂未获取到地理位置信息,请重试', content: '暂未获取到地理位置信息,请重试',
confirmText: '重试', confirmText: '重试',
success: (res) => { success: res => {
if (res.confirm) { if (res.confirm) {
that.getLocation() that.getLocation()
} }
@ -81,7 +88,7 @@ export default {
content: '已获取当前地理位置,确定跳过吗', content: '已获取当前地理位置,确定跳过吗',
confirmText: '跳过', confirmText: '跳过',
cancelText: '取消', cancelText: '取消',
success: (res) => { success: res => {
if (res.confirm) { if (res.confirm) {
const lockInfo = that.currentLockInfo const lockInfo = that.currentLockInfo
delete lockInfo.position delete lockInfo.position
@ -108,14 +115,16 @@ export default {
async success(res) { async success(res) {
that.latitude = res.latitude that.latitude = res.latitude
that.longitude = res.longitude that.longitude = res.longitude
that.markers = [{ that.markers = [
{
id: 1, id: 1,
latitude: res.latitude, latitude: res.latitude,
longitude: res.longitude, longitude: res.longitude,
iconPath: '/static/images/icon_address.png', iconPath: '/static/images/icon_address.png',
width: '48rpx', width: '48rpx',
height: '48rpx' height: '48rpx'
}] }
]
that.show = true that.show = true
const { code, data: result } = await getGeocodeAddress({ const { code, data: result } = await getGeocodeAddress({
latitude: that.latitude, latitude: that.latitude,
@ -193,7 +202,7 @@ export default {
} }
}) })
} }
}, }
} }
</script> </script>
@ -262,7 +271,7 @@ page {
.confirm { .confirm {
border-radius: 64rpx; border-radius: 64rpx;
color: #FFFFFF; color: #ffffff;
background-color: #63b8af; background-color: #63b8af;
width: 225rpx; width: 225rpx;
height: 80rpx; height: 80rpx;

View File

@ -4,7 +4,9 @@
<view class="view-button"> <view class="view-button">
<view style="width: 150rpx">名称</view> <view style="width: 150rpx">名称</view>
<view class="view-button" style="padding: 20rpx 0"> <view class="view-button" style="padding: 20rpx 0">
<view class="info" style="line-height: 40rpx;word-break: break-all;">{{currentLockInfo.lockAlias}}</view> <view class="info" style="line-height: 40rpx; word-break: break-all">{{
currentLockInfo.lockAlias
}}</view>
</view> </view>
</view> </view>
<view class="view-line"></view> <view class="view-line"></view>
@ -33,8 +35,15 @@
<view class="view-button"> <view class="view-button">
<view>开锁时是否需联网</view> <view>开锁时是否需联网</view>
<view class="view-button" style="padding: 0"> <view class="view-button" style="padding: 0">
<up-switch v-model="unlockApp" :size="40" activeColor="#63b8af" :asyncChange="true" <up-switch
@change="changeUnlockApp" :activeValue="1" :inactiveValue="0"></up-switch> v-model="unlockApp"
:size="40"
activeColor="#63b8af"
:asyncChange="true"
@change="changeUnlockApp"
:activeValue="1"
:inactiveValue="0"
></up-switch>
</view> </view>
</view> </view>
</view> </view>
@ -43,7 +52,11 @@
<view class="view-button"> <view class="view-button">
<view>有效期</view> <view>有效期</view>
<view class="view-button" style="padding: 0"> <view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd') }}{{ timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd') }}</view> <view class="info"
>{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd') }}{{
timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd')
}}</view
>
</view> </view>
</view> </view>
<view class="view-line"></view> <view class="view-line"></view>
@ -57,8 +70,11 @@
<view class="view-button"> <view class="view-button">
<view>有效时间</view> <view>有效时间</view>
<view class="view-button" style="padding: 0"> <view class="view-button" style="padding: 0">
<view class="info">{{ timeFormat(currentLockInfo.startDate, 'h:M') }}{{ <view class="info"
timeFormat(currentLockInfo.endDate, 'h:M') }}</view> >{{ timeFormat(currentLockInfo.startDate, 'h:M') }}{{
timeFormat(currentLockInfo.endDate, 'h:M')
}}</view
>
</view> </view>
</view> </view>
</view> </view>
@ -77,10 +93,16 @@
</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
@confirm="confirmModal"> :show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio"> <view class="slot-content" @click="changeRadio">
<view style="display: flex;align-items: center;"> <view style="display: flex; align-items: center">
<radio :checked="checked"></radio> <radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view> <view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view> </view>
@ -90,15 +112,15 @@
</template> </template>
<script> <script>
import { mapActions, mapState } from 'pinia'
import { timeFormat } from 'uview-plus'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { mapActions, mapState } from 'pinia'
import { deleteLockRequest } from '@/api/lock' import { deleteLockRequest } from '@/api/lock'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { updateLockSettingRequest } from '@/api/lockSetting' import { updateLockSettingRequest } from '@/api/lockSetting'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
import { timeFormat } from 'uview-plus'
export default { export default {
data() { data() {
@ -119,7 +141,11 @@ export default {
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch', 'convertWeekDaysToChineseString']), ...mapActions(useLockStore, [
'getLockList',
'updateLockSearch',
'convertWeekDaysToChineseString'
]),
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']), ...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']),
changeRadio() { changeRadio() {
this.checked = !this.checked this.checked = !this.checked
@ -196,11 +222,14 @@ export default {
this.showModal = true this.showModal = true
return return
} }
const message = that.currentLockInfo.userType === 110301 ? '删除锁后,所有信息都会一起删除,确定删除锁吗?' : '确定删除该钥匙吗?' const message =
that.currentLockInfo.userType === 110301
? '删除锁后,所有信息都会一起删除,确定删除锁吗?'
: '确定删除该钥匙吗?'
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: message, content: message,
success: async function (res) { async success(res) {
if (res.confirm) { if (res.confirm) {
uni.showLoading({ uni.showLoading({
title: '删除中', title: '删除中',
@ -213,7 +242,7 @@ export default {
keyId: that.keyId.toString() keyId: that.keyId.toString()
}) })
if (resetDeviceCode === 0 || resetDeviceCode === -2) { if (resetDeviceCode === 0 || resetDeviceCode === -2) {
const { code, message } = await deleteLockRequest({ const { code } = await deleteLockRequest({
lockId: that.currentLockInfo.lockId lockId: that.currentLockInfo.lockId
}) })
if (code === 0) { if (code === 0) {
@ -293,7 +322,7 @@ page {
border-radius: 32rpx; border-radius: 32rpx;
width: 710rpx; width: 710rpx;
margin-left: 20rpx; margin-left: 20rpx;
background: #FFFFFF; background: #ffffff;
} }
.view-button { .view-button {
@ -310,10 +339,9 @@ page {
.view-line { .view-line {
width: 100%; width: 100%;
height: 3rpx; height: 3rpx;
background: #EBEBEB; background: #ebebeb;
} }
radio .wx-radio-input.wx-radio-input-checked { radio .wx-radio-input.wx-radio-input-checked {
border: none; border: none;
background: #c1885a; background: #c1885a;

View File

@ -1,11 +1,24 @@
<template> <template>
<view> <view>
<view class="tips">找回密码和登录新设备时可通过绑定的邮箱验证</view> <view class="tips">找回密码和登录新设备时可通过绑定的邮箱验证</view>
<input class="input-email" :value="email" placeholder="请输入邮箱" <input
placeholder-class="input-placeholder" :focus="true" @input="updateInputEmail"></input> class="input-email"
:value="email"
placeholder="请输入邮箱"
placeholder-class="input-placeholder"
:focus="true"
@input="updateInputEmail"
/>
<view class="view-top"> <view class="view-top">
<input type="number" class="input-verify" :value="verificationCode" maxlength="6" placeholder="请输入验证码" <input
placeholder-class="input-placeholder" @input="updateInputCode"></input> type="number"
class="input-verify"
:value="verificationCode"
maxlength="6"
placeholder="请输入验证码"
placeholder-class="input-placeholder"
@input="updateInputCode"
/>
<view class="button-verify" @click="getEmailCode">{{ text }}</view> <view class="button-verify" @click="getEmailCode">{{ text }}</view>
</view> </view>
<view class="button" @click="toUpdateEmail">确定</view> <view class="button" @click="toUpdateEmail">确定</view>
@ -14,10 +27,10 @@
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user'
import { getEmailCodeRequest, unbindEmailTokenRequest, updateEmailRequest, updateUserInfoRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic'
import { test } from 'uview-plus' import { test } from 'uview-plus'
import { useUserStore } from '@/stores/user'
import { getEmailCodeRequest, updateEmailRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data() { data() {
@ -103,7 +116,7 @@ export default {
if (this.token !== '') { if (this.token !== '') {
params.unbindToken = this.token params.unbindToken = this.token
} }
const { code, data, message } = await updateEmailRequest(params) const { code, message } = await updateEmailRequest(params)
if (code === 0) { if (code === 0) {
this.updateUserInfo({ this.updateUserInfo({
...this.userInfo, ...this.userInfo,
@ -129,7 +142,7 @@ export default {
this.text = `${time} s` this.text = `${time} s`
const now = new Date().getTime() const now = new Date().getTime()
const timer = setInterval(() => { const timer = setInterval(() => {
const second = parseInt((new Date().getTime() - now) / 1000) const second = parseInt((new Date().getTime() - now) / 1000, 10)
this.text = `${time - second} s` this.text = `${time - second} s`
if (time <= second) { if (time <= second) {
clearInterval(timer) clearInterval(timer)
@ -156,7 +169,7 @@ page {
.input-email { .input-email {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -176,7 +189,7 @@ page {
margin-left: 35rpx; margin-left: 35rpx;
background: #63b8af; background: #63b8af;
color: #FFFFFF; color: #ffffff;
} }
.view-top { .view-top {
@ -186,7 +199,7 @@ page {
.input-verify { .input-verify {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -212,6 +225,6 @@ page {
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
} }
</style> </style>

View File

@ -1,7 +1,14 @@
<template> <template>
<view> <view>
<input class="input" :value="nickname" maxlength="50" placeholder="请输入昵称" <input
placeholder-class="input-placeholder" :focus="true" @input="updateInput"></input> class="input"
:value="nickname"
maxlength="50"
placeholder="请输入昵称"
placeholder-class="input-placeholder"
:focus="true"
@input="updateInput"
/>
<view class="button" @click="updateName">保存</view> <view class="button" @click="updateName">保存</view>
</view> </view>
</template> </template>
@ -78,7 +85,7 @@ page {
<style scoped lang="scss"> <style scoped lang="scss">
.input { .input {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -104,6 +111,6 @@ page {
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
} }
</style> </style>

View File

@ -1,10 +1,24 @@
<template> <template>
<view> <view>
<input class="input" :password="true" :value="password" maxlength="20" placeholder="请输入新密码" <input
placeholder-class="input-placeholder" @input="updateNewPassword"></input> class="input"
:password="true"
:value="password"
maxlength="20"
placeholder="请输入新密码"
placeholder-class="input-placeholder"
@input="updateNewPassword"
/>
<view class="view-top"> <view class="view-top">
<input type="number" class="input-verify" :value="verificationCode" maxlength="6" placeholder="请输入验证码" <input
placeholder-class="input-placeholder" @input="updateInputCode"></input> type="number"
class="input-verify"
:value="verificationCode"
maxlength="6"
placeholder="请输入验证码"
placeholder-class="input-placeholder"
@input="updateInputCode"
/>
<view class="button-verify" @click="getPhoneCode">{{ text }}</view> <view class="button-verify" @click="getPhoneCode">{{ text }}</view>
</view> </view>
<view class="text-tips">密码必须是8-20至少包括数字/字母/符号中的2种</view> <view class="text-tips">密码必须是8-20至少包括数字/字母/符号中的2种</view>
@ -14,9 +28,9 @@
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user'
import { changePasswordRequest, getEmailCodeRequest, updatePasswordRequest } from '@/api/user'
import { test } from 'uview-plus' import { test } from 'uview-plus'
import { useUserStore } from '@/stores/user'
import { changePasswordRequest, getEmailCodeRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
export default { export default {
@ -66,7 +80,7 @@ export default {
this.text = `${time} s` this.text = `${time} s`
const now = new Date().getTime() const now = new Date().getTime()
const timer = setInterval(() => { const timer = setInterval(() => {
const second = parseInt((new Date().getTime() - now) / 1000) const second = parseInt((new Date().getTime() - now) / 1000, 10)
this.text = `${time - second} s` this.text = `${time - second} s`
if (time <= second) { if (time <= second) {
clearInterval(timer) clearInterval(timer)
@ -132,7 +146,7 @@ page {
<style scoped lang="scss"> <style scoped lang="scss">
.input { .input {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -158,14 +172,14 @@ page {
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
} }
.text-tips { .text-tips {
text-align: center; text-align: center;
margin-top: 32rpx; margin-top: 32rpx;
font-size: 28rpx; font-size: 28rpx;
color: #9B9B9B; color: #9b9b9b;
} }
.view-top { .view-top {
@ -175,7 +189,7 @@ page {
.input-verify { .input-verify {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -195,6 +209,6 @@ page {
margin-left: 35rpx; margin-left: 35rpx;
background: #63b8af; background: #63b8af;
color: #FFFFFF; color: #ffffff;
} }
</style> </style>

View File

@ -51,8 +51,18 @@
</view> </view>
</view> </view>
</view> </view>
<button open-type="chooseAvatar" style="display:none" id="avatar" @chooseavatar="chooseAvatar"></button> <button
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="rebindPhone"></button> open-type="chooseAvatar"
style="display: none"
id="avatar"
@chooseavatar="chooseAvatar"
></button>
<button
open-type="getPhoneNumber"
style="display: none"
id="phone"
@getphonenumber="rebindPhone"
></button>
</view> </view>
</template> </template>
@ -88,7 +98,7 @@ export default {
this.pending = true this.pending = true
const result = await this.checkSession() const result = await this.checkSession()
if (result) { if (result) {
const { code, data, message } = await rebindPhoneRequest({ const { code, message } = await rebindPhoneRequest({
encryptedData: detail.detail.encryptedData, encryptedData: detail.detail.encryptedData,
iv: detail.detail.iv iv: detail.detail.iv
}) })
@ -104,7 +114,7 @@ export default {
icon: 'none' icon: 'none'
}) })
} else if (code === 438) { } else if (code === 438) {
/* empty */
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,
@ -142,7 +152,7 @@ export default {
filePath: path, filePath: path,
name: 'file', name: 'file',
formData: data.formData, formData: data.formData,
async success (res) { async success() {
const { code: updateCode } = await updateUserInfoRequest({ const { code: updateCode } = await updateUserInfoRequest({
headUrl: data.fileUrl headUrl: data.fileUrl
}) })
@ -214,14 +224,13 @@ page {
} }
</style> </style>
<style scoped lang="scss"> <style scoped lang="scss">
.view { .view {
margin-top: 32rpx; margin-top: 32rpx;
border-radius: 32rpx; border-radius: 32rpx;
width: 710rpx; width: 710rpx;
margin-left: 20rpx; margin-left: 20rpx;
background: #FFFFFF; background: #ffffff;
} }
.view-button { .view-button {
@ -269,7 +278,7 @@ page {
.view-line { .view-line {
width: 100%; width: 100%;
height: 3rpx; height: 3rpx;
background: #EBEBEB; background: #ebebeb;
} }
.avatar { .avatar {

View File

@ -2,8 +2,15 @@
<view> <view>
<view class="tips">为了你的账号安全修改账号前请先使用验证码验证</view> <view class="tips">为了你的账号安全修改账号前请先使用验证码验证</view>
<view class="view-top"> <view class="view-top">
<input type="number" class="input" :value="verificationCode" maxlength="6" placeholder="请输入验证码" <input
placeholder-class="input-placeholder" @input="updateInput"></input> type="number"
class="input"
:value="verificationCode"
maxlength="6"
placeholder="请输入验证码"
placeholder-class="input-placeholder"
@input="updateInput"
/>
<view class="button-verify" @click="getEmailCode">{{ text }}</view> <view class="button-verify" @click="getEmailCode">{{ text }}</view>
</view> </view>
<view class="button" @click="toUpdateEmail">下一步</view> <view class="button" @click="toUpdateEmail">下一步</view>
@ -12,10 +19,10 @@
<script> <script>
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user'
import { getEmailCodeRequest, unbindEmailTokenRequest, updateUserInfoRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic'
import { test } from 'uview-plus' import { test } from 'uview-plus'
import { useUserStore } from '@/stores/user'
import { getEmailCodeRequest, unbindEmailTokenRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data() { data() {
@ -86,7 +93,7 @@ export default {
this.text = `${time} s` this.text = `${time} s`
const now = new Date().getTime() const now = new Date().getTime()
const timer = setInterval(() => { const timer = setInterval(() => {
const second = parseInt((new Date().getTime() - now) / 1000) const second = parseInt((new Date().getTime() - now) / 1000, 10)
this.text = `${time - second} s` this.text = `${time - second} s`
if (time <= second) { if (time <= second) {
clearInterval(timer) clearInterval(timer)
@ -125,7 +132,7 @@ page {
margin-left: 35rpx; margin-left: 35rpx;
background: #63b8af; background: #63b8af;
color: #FFFFFF; color: #ffffff;
} }
.view-top { .view-top {
@ -135,7 +142,7 @@ page {
.input { .input {
border-radius: 16rpx; border-radius: 16rpx;
background: #FFFFFF; background: #ffffff;
margin-left: 35rpx; margin-left: 35rpx;
margin-top: 48rpx; margin-top: 48rpx;
height: 108rpx; height: 108rpx;
@ -161,6 +168,6 @@ page {
line-height: 96rpx; line-height: 96rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
} }
</style> </style>

View File

@ -14,7 +14,7 @@ export default {
env: null env: null
} }
}, },
onLoad: async function (options) { async onLoad(options) {
this.env = await env[await getApp().globalData.getEnvConfig()] this.env = await env[await getApp().globalData.getEnvConfig()]
const officialAccounts = { const officialAccounts = {
default: { default: {
@ -30,11 +30,11 @@ export default {
name: '隐私政策' name: '隐私政策'
} }
} }
const item = officialAccounts[options?.type] || officialAccounts['default'] const item = officialAccounts[options?.type] || officialAccounts.default
this.url = this.env.webviewBaseUrl + item['url'] this.url = this.env.webviewBaseUrl + item.url
console.log(this.url) console.log(this.url)
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: item['name'] title: item.name
}) })
} }
} }

View File

@ -114,7 +114,6 @@ const pages = [
} }
] ]
export const useBasicStore = defineStore('basic', { export const useBasicStore = defineStore('basic', {
state() { state() {
return { return {
@ -131,7 +130,7 @@ export const useBasicStore = defineStore('basic', {
/* data name string type string params object delta number /* data name string type string params object delta number
* 具体入参查看文档 https://www.uviewui.com/js/route.html */ * 具体入参查看文档 https://www.uviewui.com/js/route.html */
routeJump(data) { routeJump(data) {
const page = pages.find((page) => { const page = pages.find(page => {
return page.name === data.name return page.name === data.name
}) })
if (page) { if (page) {
@ -143,9 +142,9 @@ export const useBasicStore = defineStore('basic', {
}, },
// 获取当前网络状态 // 获取当前网络状态
getNetworkType() { getNetworkType() {
return new Promise((resolve) => { return new Promise(resolve => {
uni.getNetworkType({ uni.getNetworkType({
success: function (res) { success(res) {
if (res.networkType === 'none') { if (res.networkType === 'none') {
uni.showToast({ uni.showToast({
title: '网络访问失败,请检查网络是否正常', title: '网络访问失败,请检查网络是否正常',
@ -156,7 +155,7 @@ export const useBasicStore = defineStore('basic', {
} }
resolve(true) resolve(true)
}, },
fail: function () { fail() {
resolve(false) resolve(false)
} }
}) })
@ -165,17 +164,17 @@ export const useBasicStore = defineStore('basic', {
// 获取设备信息 // 获取设备信息
getDeviceInfo() { getDeviceInfo() {
const that = this const that = this
return new Promise((resolve) => { return new Promise(resolve => {
if (that.deviceInfo?.model) { if (that.deviceInfo?.model) {
resolve(that.deviceInfo) resolve(that.deviceInfo)
return return
} }
uni.getSystemInfo({ uni.getSystemInfo({
success: function (res) { success(res) {
that.deviceInfo = res that.deviceInfo = res
resolve(that.deviceInfo) resolve(that.deviceInfo)
}, },
fail: function () { fail() {
resolve({}) resolve({})
} }
}) })
@ -183,14 +182,13 @@ export const useBasicStore = defineStore('basic', {
}, },
// 获取胶囊信息 // 获取胶囊信息
getButtonInfo() { getButtonInfo() {
return new Promise((resolve, reject) => { return new Promise(resolve => {
if (this.buttonInfo?.top) { if (this.buttonInfo?.top) {
resolve(this.buttonInfo) resolve(this.buttonInfo)
return return
} }
this.buttonInfo = uni.getMenuButtonBoundingClientRect() this.buttonInfo = uni.getMenuButtonBoundingClientRect()
resolve(this.buttonInfo) resolve(this.buttonInfo)
return
}) })
}, },
// 计算字符串长度 // 计算字符串长度
@ -212,10 +210,9 @@ export const useBasicStore = defineStore('basic', {
}, },
// 回退页面并弹出toast提示 // 回退页面并弹出toast提示
backAndToast(message, delta = 1) { backAndToast(message, delta = 1) {
const that = this
uni.navigateBack({ uni.navigateBack({
delta: delta, delta,
complete: function () { complete() {
setTimeout(() => { setTimeout(() => {
uni.showToast({ uni.showToast({
title: message, title: message,
@ -234,7 +231,7 @@ export const useBasicStore = defineStore('basic', {
} else { } else {
delete data.path delete data.path
} }
const page = pages.find((page) => { const page = pages.find(page => {
return page.name === target[0] return page.name === target[0]
}) })
if (page) { if (page) {
@ -256,7 +253,7 @@ export const useBasicStore = defineStore('basic', {
function getParams(params) { function getParams(params) {
let paramStr = '' let paramStr = ''
Object.keys(params).forEach((item) => { Object.keys(params).forEach(item => {
if (paramStr === '') { if (paramStr === '') {
paramStr = `${item}=${params[item]}` paramStr = `${item}=${params[item]}`
} else { } else {
@ -265,6 +262,6 @@ export const useBasicStore = defineStore('basic', {
}) })
return paramStr return paramStr
} }
}, }
} }
}) })

View File

@ -37,7 +37,7 @@ const cmdIds = {
// 重置设备 // 重置设备
resetDevice: 0x3004, resetDevice: 0x3004,
// 清理用户 // 清理用户
cleanUser: 0x300C, cleanUser: 0x300c,
// 扩展命令 // 扩展命令
expandCmd: 0x3030 expandCmd: 0x3030
} }
@ -94,7 +94,7 @@ export const useBluetoothStore = defineStore('ble', {
let str = '' let str = ''
for (let i = 0; i < uint8Array.length; i++) { for (let i = 0; i < uint8Array.length; i++) {
if (uint8Array[i] !== 0) { if (uint8Array[i] !== 0) {
str += String.fromCharCode(uint8Array[i]); str += String.fromCharCode(uint8Array[i])
} }
} }
return str return str
@ -103,7 +103,7 @@ export const useBluetoothStore = defineStore('ble', {
async updateServerTimestamp() { async updateServerTimestamp() {
const { code, data, message } = await getServerDatetime({}) const { code, data, message } = await getServerDatetime({})
if (code === 0) { if (code === 0) {
this.serverTimestamp = parseInt(data.date / 1000) this.serverTimestamp = parseInt(data.date / 1000, 10)
} }
return { code, data, message } return { code, data, message }
}, },
@ -129,9 +129,8 @@ export const useBluetoothStore = defineStore('ble', {
this.onBluetoothCharacteristicValueChange() this.onBluetoothCharacteristicValueChange()
return true return true
} else {
return false
} }
return false
}, },
// 更新是否初始化蓝牙字段 // 更新是否初始化蓝牙字段
updateInitBluetooth(value) { updateInitBluetooth(value) {
@ -196,7 +195,7 @@ export const useBluetoothStore = defineStore('ble', {
// 监听蓝牙状态变化 // 监听蓝牙状态变化
onBluetoothState() { onBluetoothState() {
const that = this const that = this
uni.onBluetoothAdapterStateChange((res) => { uni.onBluetoothAdapterStateChange(res => {
console.log('蓝牙状态改变', res) console.log('蓝牙状态改变', res)
if (that.bluetoothStatus === 3 && res.available) { if (that.bluetoothStatus === 3 && res.available) {
that.bluetoothStatus = 2 that.bluetoothStatus = 2
@ -273,7 +272,10 @@ export const useBluetoothStore = defineStore('ble', {
} }
} else { } else {
const cebBinaryData = binaryData.slice(12, binaryData.length - 2) const cebBinaryData = binaryData.slice(12, binaryData.length - 2)
const decrypted = sm4.decrypt(cebBinaryData, that.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const decrypted = sm4.decrypt(cebBinaryData, that.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
console.log('ecb解密后的数据', decrypted) console.log('ecb解密后的数据', decrypted)
const cmdId = decrypted[0] * 256 + decrypted[1] const cmdId = decrypted[0] * 256 + decrypted[1]
@ -302,8 +304,15 @@ export const useBluetoothStore = defineStore('ble', {
that.updateCurrentLockInfo({ that.updateCurrentLockInfo({
...that.currentLockInfo, ...that.currentLockInfo,
featureValue: that.uint8ArrayToString(decrypted.slice(175, 175 + decrypted[174])), featureValue: that.uint8ArrayToString(decrypted.slice(175, 175 + decrypted[174])),
featureSettingValue: that.uint8ArrayToString(decrypted.slice(176 + decrypted[174], 176 + decrypted[174] + decrypted[175 + decrypted[174]])), featureSettingValue: that.uint8ArrayToString(
featureSettingParams: Array.from(decrypted.slice(176 + decrypted[174] + decrypted[175 + decrypted[174]])), decrypted.slice(
176 + decrypted[174],
176 + decrypted[174] + decrypted[175 + decrypted[174]]
)
),
featureSettingParams: Array.from(
decrypted.slice(176 + decrypted[174] + decrypted[175 + decrypted[174]])
),
lockConfig lockConfig
}) })
console.log('获取锁状态成功', that.currentLockInfo.lockConfig) console.log('获取锁状态成功', that.currentLockInfo.lockConfig)
@ -330,6 +339,7 @@ export const useBluetoothStore = defineStore('ble', {
break break
case cmdIds.expandCmd: case cmdIds.expandCmd:
const subCmdId = decrypted[3] const subCmdId = decrypted[3]
// eslint-disable-next-line default-case
switch (subCmdId) { switch (subCmdId) {
case subCmdIds.resetLockPassword: case subCmdIds.resetLockPassword:
that.updateCurrentLockInfo({ that.updateCurrentLockInfo({
@ -408,7 +418,7 @@ export const useBluetoothStore = defineStore('ble', {
}) })
reportOpenDoorRequest({ reportOpenDoorRequest({
lockId: that.currentLockInfo.lockId, lockId: that.currentLockInfo.lockId,
keyId: that.keyId, keyId: that.keyId
}).then(res => { }).then(res => {
console.log('上报开门结果', res) console.log('上报开门结果', res)
}) })
@ -443,17 +453,21 @@ export const useBluetoothStore = defineStore('ble', {
uni.onBLECharacteristicValueChange(function (res) { uni.onBLECharacteristicValueChange(function (res) {
if (res.deviceId === that.currentLockInfo.deviceId) { if (res.deviceId === that.currentLockInfo.deviceId) {
let binaryData = new Uint8Array(res.value) let binaryData = new Uint8Array(res.value)
if(binaryData[0] === 0xEF && binaryData[1] === 0x01 && binaryData[2] === 0xEE && binaryData[3] === 0x02) { if (
binaryData[0] === 0xef &&
binaryData[1] === 0x01 &&
binaryData[2] === 0xee &&
binaryData[3] === 0x02
) {
length = binaryData[8] * 256 + binaryData[9] length = binaryData[8] * 256 + binaryData[9]
if (length + 14 > binaryData.length) { if (length + 14 > binaryData.length) {
completeArray = binaryData completeArray = binaryData
} else { } else {
that.parsingCharacteristicValue(binaryData) that.parsingCharacteristicValue(binaryData)
} }
} else { } else if (completeArray) {
if(completeArray) {
const combinedArray = new Uint8Array(completeArray.length + binaryData.length) const combinedArray = new Uint8Array(completeArray.length + binaryData.length)
combinedArray.set(completeArray, 0); combinedArray.set(completeArray, 0)
combinedArray.set(binaryData, completeArray.length) combinedArray.set(binaryData, completeArray.length)
completeArray = combinedArray completeArray = combinedArray
if (length + 14 === completeArray.length) { if (length + 14 === completeArray.length) {
@ -462,7 +476,6 @@ export const useBluetoothStore = defineStore('ble', {
} }
} }
} }
}
}) })
}, },
// 开始搜索蓝牙设备 // 开始搜索蓝牙设备
@ -475,12 +488,12 @@ export const useBluetoothStore = defineStore('ble', {
} }
this.deviceList = [] this.deviceList = []
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
success: function (res) { success() {
setTimeout(() => { setTimeout(() => {
that.searchBluetoothDevices() that.searchBluetoothDevices()
}, 300) }, 300)
}, },
fail: async function (res) { async fail(res) {
console.log('开始搜索失败', res) console.log('开始搜索失败', res)
if (res.errno === 1509008) { if (res.errno === 1509008) {
uni.showModal({ uni.showModal({
@ -522,7 +535,8 @@ export const useBluetoothStore = defineStore('ble', {
if (searchNumber === 0 && searchTipFlag) { if (searchNumber === 0 && searchTipFlag) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)', content:
'长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)',
showCancel: false, showCancel: false,
success() { success() {
uni.openAppAuthorizeSetting({ uni.openAppAuthorizeSetting({
@ -549,7 +563,7 @@ export const useBluetoothStore = defineStore('ble', {
} }
console.log('设备列表', that.deviceList) console.log('设备列表', that.deviceList)
}, },
fail: async function (res) { async fail(res) {
console.log('获取设备列表失败', res) console.log('获取设备列表失败', res)
if (res.errCode === 10000) { if (res.errCode === 10000) {
// 重新初始化蓝牙适配器 // 重新初始化蓝牙适配器
@ -603,7 +617,7 @@ export const useBluetoothStore = defineStore('ble', {
// 检查小程序设置 // 检查小程序设置
checkSetting() { checkSetting() {
const that = this const that = this
return new Promise((resolve) => { return new Promise(resolve => {
uni.getSetting({ uni.getSetting({
async success(res) { async success(res) {
const bluetooth = res.authSetting['scope.bluetooth'] const bluetooth = res.authSetting['scope.bluetooth']
@ -635,7 +649,7 @@ export const useBluetoothStore = defineStore('ble', {
// 连接蓝牙设备+获取设备服务+获取设备特征值 // 连接蓝牙设备+获取设备服务+获取设备特征值
connectBluetoothDevice(number = 0) { 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) {
console.log('连接未执行', that.bluetoothStatus) console.log('连接未执行', that.bluetoothStatus)
that.getBluetoothStatus() that.getBluetoothStatus()
@ -660,7 +674,7 @@ export const useBluetoothStore = defineStore('ble', {
// 获取设备对应服务的特征值 // 获取设备对应服务的特征值
uni.getBLEDeviceCharacteristics({ uni.getBLEDeviceCharacteristics({
deviceId: that.currentLockInfo.deviceId, deviceId: that.currentLockInfo.deviceId,
serviceId: serviceId, serviceId,
success(res) { success(res) {
let notifyCharacteristicId let notifyCharacteristicId
let writeCharacteristicId let writeCharacteristicId
@ -764,6 +778,7 @@ export const useBluetoothStore = defineStore('ble', {
convertWeekdaysToNumber(weekDay) { convertWeekdaysToNumber(weekDay) {
let weekStr = '00000000' let weekStr = '00000000'
// eslint-disable-next-line no-restricted-syntax
for (const day of weekDay) { for (const day of weekDay) {
const index = day % 7 // 将周日的索引转换为0 const index = day % 7 // 将周日的索引转换为0
weekStr = weekStr.substring(0, index) + '1' + weekStr.substring(index + 1) weekStr = weekStr.substring(0, index) + '1' + weekStr.substring(index + 1)
@ -780,9 +795,9 @@ export const useBluetoothStore = defineStore('ble', {
const that = this const that = this
let timer1 let timer1
let timer2 let timer2
return new Promise((resolve) => { return new Promise(resolve => {
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
success: function () { success() {
let searchFlag = false let searchFlag = false
timer2 = setTimeout(async () => { timer2 = setTimeout(async () => {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
@ -790,7 +805,8 @@ export const useBluetoothStore = defineStore('ble', {
if (!searchFlag) { if (!searchFlag) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)', content:
'长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)',
showCancel: false, showCancel: false,
success() { success() {
uni.openAppAuthorizeSetting({ uni.openAppAuthorizeSetting({
@ -816,7 +832,12 @@ export const useBluetoothStore = defineStore('ble', {
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]
console.log('设备UUID', uuid, uuid.slice(2, 8), uuid.slice(30, 32)) 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.bindedDeviceNameList.includes(that.currentLockInfo.name))) { if (
uuid &&
uuid.slice(2, 8) === '758824' &&
(uuid.slice(30, 32) === '01' ||
that.bindedDeviceNameList.includes(that.currentLockInfo.name))
) {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2) clearTimeout(timer2)
clearInterval(timer1) clearInterval(timer1)
@ -827,7 +848,11 @@ export const useBluetoothStore = defineStore('ble', {
} }
}) })
break break
} else if(uuid && uuid.slice(2,8)==='758824' && uuid.slice(30,32)==='00') { } else if (
uuid &&
uuid.slice(2, 8) === '758824' &&
uuid.slice(30, 32) === '00'
) {
uni.stopBluetoothDevicesDiscovery() uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2) clearTimeout(timer2)
clearInterval(timer1) clearInterval(timer1)
@ -852,7 +877,7 @@ export const useBluetoothStore = defineStore('ble', {
} }
} }
}, },
fail: async function (res) { async fail(res) {
console.log('获取设备列表失败', res) console.log('获取设备列表失败', res)
if (res.errCode === 10000) { if (res.errCode === 10000) {
// 重新初始化蓝牙适配器 // 重新初始化蓝牙适配器
@ -862,7 +887,7 @@ export const useBluetoothStore = defineStore('ble', {
}) })
}, 1000) }, 1000)
}, },
fail: async function (res) { async fail(res) {
console.log('开始搜索失败', res) console.log('开始搜索失败', res)
if (res.errCode === 10000) { if (res.errCode === 10000) {
// 重新初始化蓝牙适配器 // 重新初始化蓝牙适配器
@ -899,7 +924,7 @@ export const useBluetoothStore = defineStore('ble', {
async checkLockUser(flag = false) { async checkLockUser(flag = false) {
console.log('检查是否已添加为用户', this.currentLockInfo.lockUserNo) console.log('检查是否已添加为用户', this.currentLockInfo.lockUserNo)
if (this.currentLockInfo.lockUserNo === 0 || flag) { if (this.currentLockInfo.lockUserNo === 0 || flag) {
const timestamp = parseInt(new Date().getTime() / 1000) const timestamp = parseInt(new Date().getTime() / 1000, 10)
const password = (Math.floor(Math.random() * 900000) + 100000).toString() const password = (Math.floor(Math.random() * 900000) + 100000).toString()
console.log('用户未添加,开始添加用户') console.log('用户未添加,开始添加用户')
const addUserParams = { const addUserParams = {
@ -909,15 +934,36 @@ export const useBluetoothStore = defineStore('ble', {
uid: this.currentLockInfo.uid.toString(), uid: this.currentLockInfo.uid.toString(),
openMode: 1, openMode: 1,
keyType: 0, keyType: 0,
startDate: this.currentLockInfo.startDate === 0 ? timestamp : parseInt(this.currentLockInfo.startDate / 1000), startDate:
expireDate: this.currentLockInfo.endDate === 0 ? 0xffffffff : parseInt(this.currentLockInfo.endDate / 1000), this.currentLockInfo.startDate === 0
? timestamp
: parseInt(this.currentLockInfo.startDate / 1000, 10),
expireDate:
this.currentLockInfo.endDate === 0
? 0xffffffff
: parseInt(this.currentLockInfo.endDate / 1000, 10),
useCountLimit: this.currentLockInfo.keyType === 3 ? 1 : 0xffff, useCountLimit: this.currentLockInfo.keyType === 3 ? 1 : 0xffff,
isRound: this.currentLockInfo.keyType === 4 ? 1 : 0, isRound: this.currentLockInfo.keyType === 4 ? 1 : 0,
weekRound: this.currentLockInfo.keyType === 4 ? this.convertWeekdaysToNumber(this.currentLockInfo.weekDays) : 0, weekRound:
startHour: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.startDate).getHours() : 0, this.currentLockInfo.keyType === 4
startMin: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.startDate).getMinutes() : 0, ? this.convertWeekdaysToNumber(this.currentLockInfo.weekDays)
endHour: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.endDate).getHours() : 0, : 0,
endMin: this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.endDate).getMinutes() : 0, startHour:
this.currentLockInfo.keyType === 4
? new Date(this.currentLockInfo.startDate).getHours()
: 0,
startMin:
this.currentLockInfo.keyType === 4
? new Date(this.currentLockInfo.startDate).getMinutes()
: 0,
endHour:
this.currentLockInfo.keyType === 4
? new Date(this.currentLockInfo.endDate).getHours()
: 0,
endMin:
this.currentLockInfo.keyType === 4
? new Date(this.currentLockInfo.endDate).getMinutes()
: 0,
role: 0, role: 0,
password password
} }
@ -930,7 +976,8 @@ export const useBluetoothStore = defineStore('ble', {
}) })
console.log('添加用户请求结果', code) console.log('添加用户请求结果', code)
return true return true
} else if(addUserCode === 0x0c) { }
if (addUserCode === 0x0c) {
console.log('用户达上限,开始清理用户') console.log('用户达上限,开始清理用户')
const { code: requestCode, data: requestData } = await getUserNoListRequest({ const { code: requestCode, data: requestData } = await getUserNoListRequest({
lockId: this.currentLockInfo.lockId lockId: this.currentLockInfo.lockId
@ -943,22 +990,17 @@ export const useBluetoothStore = defineStore('ble', {
keyId: this.keyId, keyId: this.keyId,
authUid: this.currentLockInfo.senderUserId.toString(), authUid: this.currentLockInfo.senderUserId.toString(),
uid: this.currentLockInfo.uid.toString(), uid: this.currentLockInfo.uid.toString(),
userNoList: userNoList userNoList
}) })
console.log('清理用户蓝牙结果', cleanCode) console.log('清理用户蓝牙结果', cleanCode)
if (cleanCode === 0) { if (cleanCode === 0) {
return await this.checkLockUser() return await this.checkLockUser()
} else { }
return false return false
} }
} else if(addUserCode === 0x0f) { return addUserCode === 0x0f
return true
} else {
return false
} }
} else {
return true return true
}
}, },
// 写入特征值 // 写入特征值
async writeBLECharacteristicValue(binaryData) { async writeBLECharacteristicValue(binaryData) {
@ -973,7 +1015,10 @@ export const useBluetoothStore = defineStore('ble', {
// 次数 // 次数
const count = Math.ceil(binaryData.length / 20) const count = Math.ceil(binaryData.length / 20)
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const writeData = binaryData.slice(i * 20, i === (count - 1) ? binaryData.length : (i + 1) * 20) const writeData = binaryData.slice(
i * 20,
i === count - 1 ? binaryData.length : (i + 1) * 20
)
uni.writeBLECharacteristicValue({ uni.writeBLECharacteristicValue({
deviceId: that.currentLockInfo.deviceId, deviceId: that.currentLockInfo.deviceId,
@ -996,9 +1041,9 @@ export const useBluetoothStore = defineStore('ble', {
let headArray = new Uint8Array(12) let headArray = new Uint8Array(12)
// 固定包头 // 固定包头
headArray[0] = 0xEF headArray[0] = 0xef
headArray[1] = 0x01 headArray[1] = 0x01
headArray[2] = 0xEE headArray[2] = 0xee
headArray[3] = 0x02 headArray[3] = 0x02
// 包类型 发送 // 包类型 发送
@ -1149,11 +1194,18 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[106] = 16 conentArray[106] = 16
const md5Array = this.md5Encrypte(authUid + keyId, conentArray.slice(102, 106), this.currentLockInfo.publicKey) const md5Array = this.md5Encrypte(
authUid + keyId,
conentArray.slice(102, 106),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 107) conentArray.set(md5Array, 107)
const cebArray = sm4.encrypt(conentArray, conentArray.slice(2, 18), { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, conentArray.slice(2, 18), {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
@ -1222,7 +1274,10 @@ export const useBluetoothStore = defineStore('ble', {
conentArray.set(this.timestampToArray(nowTime), 62) conentArray.set(this.timestampToArray(nowTime), 62)
conentArray.set(this.timestampToArray(localTime), 66) conentArray.set(this.timestampToArray(localTime), 66)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
@ -1236,7 +1291,7 @@ export const useBluetoothStore = defineStore('ble', {
array[0] = (timestamp & 0xff000000) >> 24 array[0] = (timestamp & 0xff000000) >> 24
array[1] = (timestamp & 0xff0000) >> 16 array[1] = (timestamp & 0xff0000) >> 16
array[2] = (timestamp & 0xff00) >> 8 array[2] = (timestamp & 0xff00) >> 8
array[3] = (timestamp & 0xff) array[3] = timestamp & 0xff
return array return array
}, },
// 二进制转时间戳 // 二进制转时间戳
@ -1275,9 +1330,27 @@ export const useBluetoothStore = defineStore('ble', {
} }
} }
const { name, authUid, uid, keyId, openMode, keyType, startDate, expireDate, useCountLimit, isRound, weekRound, const {
startHour, startMin, endHour, endMin, role, password } = data name,
const length = 2 + 40 + 20 + 40 + 20 + 1 + 1 + 4 + 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 20 + 4 + 1 + 16 authUid,
uid,
keyId,
openMode,
keyType,
startDate,
expireDate,
useCountLimit,
isRound,
weekRound,
startHour,
startMin,
endHour,
endMin,
role,
password
} = data
const length =
2 + 40 + 20 + 40 + 20 + 1 + 1 + 4 + 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length) const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length) const conentArray = new Uint8Array(length)
@ -1325,11 +1398,18 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[165] = 16 conentArray[165] = 16
const md5Array = this.md5Encrypte(authUid + keyId, this.currentLockInfo.token || this.timestampToArray(startDate), this.currentLockInfo.publicKey) const md5Array = this.md5Encrypte(
authUid + keyId,
this.currentLockInfo.token || this.timestampToArray(startDate),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 166) conentArray.set(md5Array, 166)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
await this.writeBLECharacteristicValue(packageArray, false) await this.writeBLECharacteristicValue(packageArray, false)
@ -1355,7 +1435,7 @@ export const useBluetoothStore = defineStore('ble', {
}) })
resolve({ code: -1 }) resolve({ code: -1 })
}, 20000) }, 20000)
characteristicValueCallback = async (data) => { characteristicValueCallback = async data => {
// code 6 token过期,重新获取 // code 6 token过期,重新获取
if (data.code === 6) { if (data.code === 6) {
log.info({ log.info({
@ -1702,8 +1782,11 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[71] = 16 conentArray[71] = 16
const md5Array = this.md5Encrypte(
const md5Array = this.md5Encrypte(name + uid, this.currentLockInfo.token || this.timestampToArray(openTime), this.currentLockInfo.signKey) name + uid,
this.currentLockInfo.token || this.timestampToArray(openTime),
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 72) conentArray.set(md5Array, 72)
@ -1711,7 +1794,10 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[i + 88] = onlineToken.charCodeAt(i) conentArray[i + 88] = onlineToken.charCodeAt(i)
} }
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
log.info({ log.info({
@ -1803,15 +1889,25 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[i + 124] = userNoList[i] conentArray[i + 124] = userNoList[i]
} }
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 124 + userNoList.length) conentArray.set(
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
124 + userNoList.length
)
conentArray[128 + userNoList.length] = 16 conentArray[128 + userNoList.length] = 16
const md5Array = this.md5Encrypte(authUid + keyId, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.publicKey) const md5Array = this.md5Encrypte(
authUid + keyId,
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 129 + userNoList.length) conentArray.set(md5Array, 129 + userNoList.length)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
@ -1858,7 +1954,7 @@ export const useBluetoothStore = defineStore('ble', {
} }
} }
const { name, authUid, keyId } = data const { name, authUid } = data
const length = 2 + 40 + 20 + 4 + 1 + 16 const length = 2 + 40 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length) const headArray = this.createPackageHeader(3, length)
const conentArray = new Uint8Array(length) const conentArray = new Uint8Array(length)
@ -1876,10 +1972,17 @@ export const useBluetoothStore = defineStore('ble', {
conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62) conentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
conentArray[66] = 16 conentArray[66] = 16
const md5Array = this.md5Encrypte(name, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.publicKey) const md5Array = this.md5Encrypte(
name,
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
this.currentLockInfo.publicKey
)
conentArray.set(md5Array, 67) conentArray.set(md5Array, 67)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
@ -1951,11 +2054,18 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[68] = 16 conentArray[68] = 16
const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.signKey) const md5Array = this.md5Encrypte(
keyId + uid,
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 69) conentArray.set(md5Array, 69)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)
@ -2043,11 +2153,18 @@ export const useBluetoothStore = defineStore('ble', {
conentArray[102] = 16 conentArray[102] = 16
const md5Array = this.md5Encrypte(keyId + uid, this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), this.currentLockInfo.signKey) const md5Array = this.md5Encrypte(
keyId + uid,
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
this.currentLockInfo.signKey
)
conentArray.set(md5Array, 103) conentArray.set(md5Array, 103)
const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, { mode: 'ecb', output: 'array' }) const cebArray = sm4.encrypt(conentArray, this.currentLockInfo.commKey, {
mode: 'ecb',
output: 'array'
})
const packageArray = this.createPackageEnd(headArray, cebArray) const packageArray = this.createPackageEnd(headArray, cebArray)

View File

@ -2,9 +2,9 @@
* @description 锁信息数据持久化 * @description 锁信息数据持久化
*/ */
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { timeFormat } from 'uview-plus'
import { getLockListRequest } from '@/api/lock' import { getLockListRequest } from '@/api/lock'
import { getPsaawordListRequest } from '@/api/keyboardPwd' import { getPsaawordListRequest } from '@/api/keyboardPwd'
import { timeFormat } from 'uview-plus'
import { getKeyListRequest } from '@/api/key' import { getKeyListRequest } from '@/api/key'
import { setStorage } from '@/utils/storage' import { setStorage } from '@/utils/storage'
@ -48,7 +48,7 @@ export const useLockStore = defineStore('lock', {
startDate: '0', startDate: '0',
keyStatus: [110401, 110402, 110412, 110405, 110403], keyStatus: [110401, 110402, 110412, 110405, 110403],
keyRight: 0 keyRight: 0
}, }
} }
}, },
actions: { actions: {
@ -64,15 +64,17 @@ export const useLockStore = defineStore('lock', {
getPowerIcon(power) { getPowerIcon(power) {
if (power >= 80) { if (power >= 80) {
return '/static/images/icon_power_5.png' return '/static/images/icon_power_5.png'
} else if(power >= 60) {
return '/static/images/icon_power_4.png'
} else if(power >= 40) {
return '/static/images/icon_power_3.png'
} else if(power >= 20) {
return '/static/images/icon_power_2.png'
} else {
return '/static/images/icon_power_1.png'
} }
if (power >= 60) {
return '/static/images/icon_power_4.png'
}
if (power >= 40) {
return '/static/images/icon_power_3.png'
}
if (power >= 20) {
return '/static/images/icon_power_2.png'
}
return '/static/images/icon_power_1.png'
}, },
// 将星期转换为中文字符串 // 将星期转换为中文字符串
convertWeekDaysToChineseString(weekDays) { convertWeekDaysToChineseString(weekDays) {
@ -108,46 +110,50 @@ export const useLockStore = defineStore('lock', {
getRole(userType, keyRight) { getRole(userType, keyRight) {
if (userType === 110301) { if (userType === 110301) {
return '超级管理员' return '超级管理员'
} else if(keyRight === 1) {
return '授权管理员'
} else {
return '普通用户'
} }
if (keyRight === 1) {
return '授权管理员'
}
return '普通用户'
}, },
getKeyStatus(keyStatus) { getKeyStatus(keyStatus) {
if (keyStatus === 110401) { if (keyStatus === 110401) {
return '' return ''
} else if(keyStatus === 110403) {
return '未生效'
} else if(keyStatus === 110402) {
return '待接收'
} else if(keyStatus === 110412) {
return '已过期'
} else if(keyStatus === 110405) {
return '已冻结'
} else {
return ''
} }
if (keyStatus === 110403) {
return '未生效'
}
if (keyStatus === 110402) {
return '待接收'
}
if (keyStatus === 110412) {
return '已过期'
}
if (keyStatus === 110405) {
return '已冻结'
}
return ''
}, },
getPasswordStatus(passwordStatus) { getPasswordStatus(passwordStatus) {
if (passwordStatus === 2) { if (passwordStatus === 2) {
return '已过期' return '已过期'
} else if(passwordStatus === 3) {
return '未生效'
} else {
return ''
} }
if (passwordStatus === 3) {
return '未生效'
}
return ''
}, },
getTimeLimit(keyType) { getTimeLimit(keyType) {
if (keyType === 1) { if (keyType === 1) {
return '永久' return '永久'
} else if(keyType === 2) {
return '限时'
} else if(keyType === 3) {
return '单次'
} else {
return '循环'
} }
if (keyType === 2) {
return '限时'
}
if (keyType === 3) {
return '单次'
}
return '循环'
}, },
async getLockList(params) { async getLockList(params) {
const { code, data, message } = await getLockListRequest(params) const { code, data, message } = await getLockListRequest(params)
@ -155,7 +161,11 @@ export const useLockStore = defineStore('lock', {
this.lockTotal = data.total this.lockTotal = data.total
for (let i = 0; i < data.groupList.length; i++) { for (let i = 0; i < data.groupList.length; i++) {
for (let j = 0; j < data.groupList[i].lockList.length; j++) { for (let j = 0; j < data.groupList[i].lockList.length; j++) {
if((data.groupList[i].lockList[j].keyType === 2 || data.groupList[i].lockList[j].keyType === 4) && data.groupList[i].lockList[j].keyStatus === 110401) { if (
(data.groupList[i].lockList[j].keyType === 2 ||
data.groupList[i].lockList[j].keyType === 4) &&
data.groupList[i].lockList[j].keyStatus === 110401
) {
const now = new Date().getTime() const now = new Date().getTime()
const diffInMilliseconds = data.groupList[i].lockList[j].endDate - now const diffInMilliseconds = data.groupList[i].lockList[j].endDate - now
const millisecondsPerDay = 24 * 60 * 60 * 1000 const millisecondsPerDay = 24 * 60 * 60 * 1000
@ -173,9 +183,8 @@ export const useLockStore = defineStore('lock', {
} }
setStorage('lockList', this.lockList) setStorage('lockList', this.lockList)
return { code } return { code }
} else {
return { code, message }
} }
return { code, message }
}, },
async getPasswordList(params) { async getPasswordList(params) {
const { code, data, message } = await getPsaawordListRequest(params) const { code, data, message } = await getPsaawordListRequest(params)
@ -183,13 +192,16 @@ export const useLockStore = defineStore('lock', {
this.passwordTotal = data.total this.passwordTotal = data.total
for (let i = 0; i < data.list.length; i++) { for (let i = 0; i < data.list.length; i++) {
if (data.list[i].keyboardPwdType === 1) { if (data.list[i].keyboardPwdType === 1) {
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 单次` data.list[i].timeText =
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 单次`
} else if (data.list[i].keyboardPwdType === 2) { } else if (data.list[i].keyboardPwdType === 2) {
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久` data.list[i].timeText =
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久`
} else if (data.list[i].keyboardPwdType === 3) { } else if (data.list[i].keyboardPwdType === 3) {
data.list[i].timeText = `${data.list[i].validTimeStr} 限时` data.list[i].timeText = `${data.list[i].validTimeStr} 限时`
} else if (data.list[i].keyboardPwdType === 4) { } else if (data.list[i].keyboardPwdType === 4) {
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 清空码` data.list[i].timeText =
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 清空码`
} else { } else {
let text = '' let text = ''
if (data.list[i].keyboardPwdType === 5) { if (data.list[i].keyboardPwdType === 5) {
@ -213,7 +225,8 @@ export const useLockStore = defineStore('lock', {
} else if (data.list[i].keyboardPwdType === 14) { } else if (data.list[i].keyboardPwdType === 14) {
text = '周日' text = '周日'
} }
data.list[i].timeText = `${text} ${data.list[i].hoursStart}:00-${data.list[i].hoursEnd}:00 循环` data.list[i].timeText =
`${text} ${data.list[i].hoursStart}:00-${data.list[i].hoursEnd}:00 循环`
} }
if (data.list[i].isCustom === 1) { if (data.list[i].isCustom === 1) {
data.list[i].timeText += ' 自定义' data.list[i].timeText += ' 自定义'
@ -225,9 +238,8 @@ export const useLockStore = defineStore('lock', {
this.passwordList = this.passwordList.concat(data.list) this.passwordList = this.passwordList.concat(data.list)
} }
return { code } return { code }
} else {
return { code, message }
} }
return { code, message }
}, },
async getKeyList(params) { async getKeyList(params) {
const { code, data, message } = await getKeyListRequest(params) const { code, data, message } = await getKeyListRequest(params)
@ -235,11 +247,14 @@ export const useLockStore = defineStore('lock', {
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++) {
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) {
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} - ${timeFormat(new Date(data.list[i].endDate), 'yyyy-mm-dd h:M')} 限时` data.list[i].timeText =
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} - ${timeFormat(new Date(data.list[i].endDate), 'yyyy-mm-dd h:M')} 限时`
} else if (data.list[i].keyType === 3) { } else if (data.list[i].keyType === 3) {
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 { } else {
data.list[i].timeText = `循环` data.list[i].timeText = `循环`
} }
@ -250,9 +265,8 @@ export const useLockStore = defineStore('lock', {
this.keyList = this.keyList.concat(data.list) this.keyList = this.keyList.concat(data.list)
} }
return { code } return { code }
} else { }
return { code, message } return { code, message }
} }
} }
}
}) })

View File

@ -11,8 +11,8 @@ export const useNotificationStore = defineStore('notification', {
// 通知列表搜索数据 // 通知列表搜索数据
notificationSearch: { notificationSearch: {
pageNo: 1, pageNo: 1,
pageSize: 50, pageSize: 50
}, }
} }
}, },
actions: { actions: {
@ -30,7 +30,10 @@ export const useNotificationStore = defineStore('notification', {
}, },
// 获取通知列表 // 获取通知列表
async getNotificationList(params) { async getNotificationList(params) {
const { code, data, message } = await getNotificationList({ pageNo: params.pageNo, pageSize: params.pageSize }) const { code, data, message } = await getNotificationList({
pageNo: params.pageNo,
pageSize: params.pageSize
})
if (code === 0) { if (code === 0) {
this.notificationTotal = data.total this.notificationTotal = data.total
if (params.pageNo === 1) { if (params.pageNo === 1) {
@ -39,9 +42,8 @@ export const useNotificationStore = defineStore('notification', {
this.notificationList = this.notificationList.concat(data.list) this.notificationList = this.notificationList.concat(data.list)
} }
return { code } return { code }
} else { }
return { code, message } return { code, message }
} }
},
} }
}) })

View File

@ -54,12 +54,11 @@ export const useUserStore = defineStore('user', {
}) })
useNotificationStore().getNotificationList(useNotificationStore().notificationSearch) useNotificationStore().getNotificationList(useNotificationStore().notificationSearch)
return true return true
} else {
return false
} }
return false
}, },
async checkSession() { async checkSession() {
return new Promise((resolve) => { return new Promise(resolve => {
uni.checkSession({ uni.checkSession({
success() { success() {
resolve(true) resolve(true)
@ -67,7 +66,7 @@ export const useUserStore = defineStore('user', {
fail() { fail() {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: async function (loginRes) { async success(loginRes) {
const { code, data } = await loginRequest({ const { code, data } = await loginRequest({
js_code: loginRes.code js_code: loginRes.code
}) })

View File

@ -1,10 +1,16 @@
uni.addInterceptor({ uni.addInterceptor({
returnValue(res) { returnValue(res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) { if (
return res; !(
!!res &&
(typeof res === 'object' || typeof res === 'function') &&
typeof res.then === 'function'
)
) {
return res
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1])); res.then(res => (res[0] ? reject(res[0]) : resolve(res[1])))
}); })
}, }
}); })

View File

@ -1,4 +1,4 @@
var log = wx.getRealtimeLogManager ? wx.getRealtimeLogManager() : null let log = wx.getRealtimeLogManager ? wx.getRealtimeLogManager() : null
export default { export default {
debug() { debug() {
@ -17,12 +17,14 @@ export default {
if (!log) return if (!log) return
log.error.apply(log, arguments) log.error.apply(log, arguments)
}, },
setFilterMsg(msg) { // 从基础库2.7.3开始支持 setFilterMsg(msg) {
// 从基础库2.7.3开始支持
if (!log || !log.setFilterMsg) return if (!log || !log.setFilterMsg) return
if (typeof msg !== 'string') return if (typeof msg !== 'string') return
log.setFilterMsg(msg) log.setFilterMsg(msg)
}, },
addFilterMsg(msg) { // 从基础库2.8.1开始支持 addFilterMsg(msg) {
// 从基础库2.8.1开始支持
if (!log || !log.addFilterMsg) return if (!log || !log.addFilterMsg) return
if (typeof msg !== 'string') return if (typeof msg !== 'string') return
log.addFilterMsg(msg) log.addFilterMsg(msg)

View File

@ -11,9 +11,9 @@ import { getStorage, removeStorage } from './storage'
* data: 请求参数 * data: 请求参数
* */ * */
const request = (config) => { const request = config => {
let timer let timer
return new Promise(async (resolve) => { return new Promise(async resolve => {
const baseConfig = await env[getApp().globalData.getEnvConfig()] const baseConfig = await env[getApp().globalData.getEnvConfig()]
const token = config?.token ? config.token : getStorage('token') const token = config?.token ? config.token : getStorage('token')