完成密码相关功能
This commit is contained in:
parent
9a70aaaff7
commit
b8cfcc33a4
@ -37,3 +37,30 @@ export function deletePsaawordRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 创建自定义密码
|
||||
export function addCustomPasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/add',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新密码
|
||||
export function updatePasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/update',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取密码详情
|
||||
export function getPasswordRequest(data) {
|
||||
return request({
|
||||
url: '/keyboardPwd/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -4,10 +4,11 @@
|
||||
<view class="name-text">{{ title }}</view>
|
||||
<input
|
||||
:value="value"
|
||||
:type="type"
|
||||
class="name-input"
|
||||
:placeholder="placeholder"
|
||||
placeholder-class="placeholder-class"
|
||||
maxlength="50"
|
||||
:maxlength="maxlength"
|
||||
@input="changeInput"
|
||||
/>
|
||||
</view>
|
||||
@ -20,7 +21,15 @@
|
||||
props: {
|
||||
title: String,
|
||||
placeholder: String,
|
||||
value: String
|
||||
value: String,
|
||||
maxlength: {
|
||||
type: Number,
|
||||
default: 50
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'text'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeInput(e) {
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
:focus="show"
|
||||
:placeholder="placeholder"
|
||||
:value="text"
|
||||
:maxlength="maxlength"
|
||||
:type="type"
|
||||
@change="change"
|
||||
/>
|
||||
</view>
|
||||
@ -38,7 +40,9 @@
|
||||
title: { type: String, default: '请输入' },
|
||||
placeholder: { type: String, default: '请输入' },
|
||||
value: { type: String, default: '' },
|
||||
autoClose: { type: Boolean, default: true }
|
||||
autoClose: { type: Boolean, default: true },
|
||||
maxlength: { type: Number, default: 50 },
|
||||
type: { type: String, default: 'text' }
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
@ -196,7 +196,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -228,7 +228,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -200,7 +200,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -228,7 +228,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -229,7 +229,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
:list="tabs"
|
||||
lineWidth="40rpx"
|
||||
lineHeight="5rpx"
|
||||
:current="currnetIndex"
|
||||
:current="currentIndex"
|
||||
lineColor="#63b8af"
|
||||
@click="clickTab"
|
||||
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||
@ -19,7 +19,7 @@
|
||||
:list="tabs"
|
||||
:autoplay="false"
|
||||
:circular="true"
|
||||
:current="currnetIndex"
|
||||
:current="currentIndex"
|
||||
@change="changeSwiper"
|
||||
>
|
||||
<swiper-item>
|
||||
@ -27,17 +27,17 @@
|
||||
:value="permanentName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changePermanentInput"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('permanent')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="temporaryName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeTemporaryInput"
|
||||
@change-input="changeName('temporary', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockDateHourPicker
|
||||
@ -52,59 +52,302 @@
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('temporary')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="singleName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('single', $event)"
|
||||
></LockInput>
|
||||
<view class="text">密码有效期为6个小时,只能使用一次</view>
|
||||
<view class="button" @click="createPassword('single')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="customName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('custom', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="customPassword"
|
||||
title="密码"
|
||||
placeholder="请输入6-9位数字"
|
||||
:maxlength="9"
|
||||
type="number"
|
||||
@change-input="changePassword('custom', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3 border-b-2 border-b-solid border-b-gray-200">
|
||||
<LockSwitch
|
||||
:value="customPermanent"
|
||||
title="永久"
|
||||
@change="changePermanent('custom', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view v-if="!customPermanent" class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<LockDatetimePicker
|
||||
title="生效时间"
|
||||
:value="customStartTime"
|
||||
@change-time="changeDate('customStartTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view v-if="!customPermanent">
|
||||
<LockDatetimePicker
|
||||
title="失效时间"
|
||||
:value="customEndTime"
|
||||
@change-time="changeDate('customEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<LockSwitch
|
||||
:value="customAdmin"
|
||||
title="是否为管理员"
|
||||
@change="changeAdmin('custom', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="text">
|
||||
手动输入6-9位数字作为密码。可在锁旁边通过手机蓝牙添加,也可通过网关远程添加
|
||||
</view>
|
||||
<view class="button" @click="createPassword('custom')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="cycleName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('cycle', $event)"
|
||||
></LockInput>
|
||||
<view style="margin-top: 20rpx" class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<view
|
||||
@click="showCycle = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">有效日</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]"
|
||||
>{{ cycleOptions[0][defaultIndex].name }}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="border-b-2 border-b-solid border-b-gray-200">
|
||||
<view
|
||||
@click="showHoursStart = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">生效时间</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]"
|
||||
>{{ hoursStart }}:00
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view
|
||||
@click="showHoursEnd = true"
|
||||
class="flex items-center bg-white font-bold text-base h-100 w-full"
|
||||
>
|
||||
<view class="w-168 ml-4 leading-[100rpx]">失效时间</view>
|
||||
<view class="ml-a mr-2 flex items-center">
|
||||
<view class="mr-2 text-right w-[518rpx] h-100 leading-[100rpx]">
|
||||
{{ hoursEnd }}:00</view
|
||||
>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text">{{ text }}</view>
|
||||
<view class="button" @click="createPassword('cycle')">获取密码</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="emptyName"
|
||||
title="姓名"
|
||||
placeholder="请给密码命名"
|
||||
@change-input="changeName('empty', $event)"
|
||||
></LockInput>
|
||||
<view class="text">
|
||||
<view>清空密码当日23:59前有效</view>
|
||||
<view>
|
||||
清空内容1:当日0点前生成的所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)
|
||||
</view>
|
||||
<view>清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)</view>
|
||||
<view>如需彻底清除所有密码,请使用重置所有密码功能</view></view
|
||||
>
|
||||
<view class="button" @click="createPassword('empty')">获取密码</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<up-picker
|
||||
:show="showCycle"
|
||||
:columns="cycleOptions"
|
||||
keyName="name"
|
||||
:defaultIndex="[defaultIndex]"
|
||||
@close="showCycle = false"
|
||||
closeOnClickOverlay
|
||||
@cancel="showCycle = false"
|
||||
@confirm="selectCycle"
|
||||
></up-picker>
|
||||
<up-picker
|
||||
:show="showHoursStart"
|
||||
:columns="hours"
|
||||
:defaultIndex="[hoursStart]"
|
||||
closeOnClickOverlay
|
||||
@close="showHoursStart = false"
|
||||
@cancel="showHoursStart = false"
|
||||
@confirm="selectHours('start', $event)"
|
||||
></up-picker>
|
||||
<up-picker
|
||||
:show="showHoursEnd"
|
||||
:columns="hours"
|
||||
:defaultIndex="[hoursEnd]"
|
||||
closeOnClickOverlay
|
||||
@close="showHoursEnd = false"
|
||||
@cancel="showHoursEnd = false"
|
||||
@confirm="selectHours('end', $event)"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import test from 'uview-plus/libs/function/test'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import LockInput from '@/components/LockInput/LockInput.vue'
|
||||
import LockDateHourPicker from '@/components/LockDateHourPicker/LockDateHourPicker.vue'
|
||||
import { createPsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { addCustomPasswordRequest, createPsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LockInput,
|
||||
LockDateHourPicker
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabs: [
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: '永久'
|
||||
},
|
||||
{
|
||||
name: '限时'
|
||||
},
|
||||
{
|
||||
name: '单次'
|
||||
},
|
||||
{
|
||||
name: '自定义'
|
||||
},
|
||||
{
|
||||
name: '循环'
|
||||
},
|
||||
{
|
||||
name: '清空'
|
||||
}
|
||||
],
|
||||
permanentName: '',
|
||||
temporaryName: '',
|
||||
temporaryTime: Number(new Date()),
|
||||
minDate: Number(new Date()),
|
||||
maxDate: Number(4133951940000),
|
||||
currnetIndex: 0,
|
||||
deviceInfo: null,
|
||||
pending: false,
|
||||
text: '密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'
|
||||
]
|
||||
const cycleOptions = ref([
|
||||
[
|
||||
{ type: 5, name: '周末' },
|
||||
{ type: 6, name: '每日' },
|
||||
{ type: 7, name: '工作日' },
|
||||
{ type: 8, name: '星期一' },
|
||||
{ type: 9, name: '星期二' },
|
||||
{ type: 10, name: '星期三' },
|
||||
{ type: 11, name: '星期四' },
|
||||
{ type: 12, name: '星期五' },
|
||||
{ type: 13, name: '星期六' },
|
||||
{ type: 14, name: '星期日' }
|
||||
]
|
||||
])
|
||||
const defaultIndex = ref(0)
|
||||
const showCycle = ref(false)
|
||||
const showHoursStart = ref(false)
|
||||
const showHoursEnd = ref(false)
|
||||
const hours = ref([Array.from({ length: 25 }, (v, k) => `${k}时`)])
|
||||
const permanentName = ref('')
|
||||
const temporaryName = ref('')
|
||||
const singleName = ref('')
|
||||
const customName = ref('')
|
||||
const cycleName = ref('')
|
||||
const emptyName = ref('')
|
||||
const temporaryTime = ref(Number(new Date()))
|
||||
const customPermanent = ref(true)
|
||||
const customStartTime = ref(0)
|
||||
const customEndTime = ref(0)
|
||||
const customAdmin = ref(false)
|
||||
const customPassword = ref('')
|
||||
const hoursStart = ref(0)
|
||||
const hoursEnd = ref(0)
|
||||
const minDate = ref(Number(new Date()))
|
||||
const maxDate = ref(Number(4133951940000))
|
||||
const currentIndex = ref(0)
|
||||
const deviceInfo = ref(null)
|
||||
const pending = ref(false)
|
||||
const text = ref(
|
||||
'密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。'
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
temporaryTime.value = Number(getNextFullHour())
|
||||
hoursStart.value = Number(timeFormat(getNextFullHour(), 'h')) - 1
|
||||
hoursEnd.value = Number(timeFormat(getNextFullHour(), 'h'))
|
||||
minDate.value = Number(getNextFullHour())
|
||||
maxDate.value = Number(getFutureTimestamp())
|
||||
})
|
||||
|
||||
const changePassword = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customPassword.value = e
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useBluetoothStore, ['currentLockInfo']),
|
||||
...mapState(useLockStore, ['passwordSearch'])
|
||||
},
|
||||
async onLoad() {
|
||||
this.deviceInfo = await this.getDeviceInfo()
|
||||
this.temporaryTime = Number(this.getNextFullHour())
|
||||
this.minDate = Number(this.getNextFullHour())
|
||||
this.maxDate = Number(this.getFutureTimestamp())
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']),
|
||||
...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']),
|
||||
getNextFullHour() {
|
||||
}
|
||||
|
||||
const selectCycle = e => {
|
||||
showCycle.value = false
|
||||
defaultIndex.value = e.indexs[0]
|
||||
}
|
||||
|
||||
const changePermanent = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customPermanent.value = e.detail.value
|
||||
if (customPermanent.value) {
|
||||
customStartTime.value = 0
|
||||
customEndTime.value = 0
|
||||
} else {
|
||||
customStartTime.value = new Date().getTime()
|
||||
customEndTime.value = new Date().getTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const changeAdmin = (type, e) => {
|
||||
if (type === 'custom') {
|
||||
customAdmin.value = e.detail.value
|
||||
}
|
||||
}
|
||||
|
||||
const changeDate = (type, e) => {
|
||||
if (type === 'customStartTime') {
|
||||
customStartTime.value = e
|
||||
} else {
|
||||
customEndTime.value = e
|
||||
}
|
||||
}
|
||||
|
||||
const selectHours = (type, e) => {
|
||||
if (type === 'start') {
|
||||
showHoursStart.value = false
|
||||
hoursStart.value = e.indexs[0]
|
||||
} else {
|
||||
showHoursEnd.value = false
|
||||
hoursEnd.value = e.indexs[0]
|
||||
}
|
||||
}
|
||||
|
||||
const getNextFullHour = () => {
|
||||
const now = new Date()
|
||||
const currentHour = now.getHours() + 1
|
||||
now.setHours(currentHour)
|
||||
@ -113,8 +356,9 @@
|
||||
now.setMilliseconds(0)
|
||||
|
||||
return now
|
||||
},
|
||||
getFutureTimestamp() {
|
||||
}
|
||||
|
||||
const getFutureTimestamp = () => {
|
||||
const currentDate = new Date()
|
||||
|
||||
const year = currentDate.getFullYear()
|
||||
@ -124,12 +368,16 @@
|
||||
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
|
||||
|
||||
return futureDate.getTime()
|
||||
},
|
||||
async createPassword(type) {
|
||||
const that = this
|
||||
}
|
||||
|
||||
const createPassword = async type => {
|
||||
if (
|
||||
(type === 'temporary' && this.temporaryName === '') ||
|
||||
(type === 'permanent' && this.permanentName === '')
|
||||
(type === 'temporary' && temporaryName.value === '') ||
|
||||
(type === 'permanent' && permanentName.value === '') ||
|
||||
(type === 'single' && singleName.value === '') ||
|
||||
(type === 'cycle' && cycleName.value === '') ||
|
||||
(type === 'empty' && emptyName.value === '') ||
|
||||
(type === 'custom' && customName.value === '')
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '名称不能为空',
|
||||
@ -138,56 +386,94 @@
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await this.getNetworkType()
|
||||
if (type === 'custom' && !test.rangeLength(customPassword.value, [6, 9])) {
|
||||
uni.showToast({
|
||||
title: '密码为6-9位纯数字',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
type === 'custom' &&
|
||||
customPermanent.value === false &&
|
||||
customStartTime.value >= customEndTime.value
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '失效时间需晚于生效时间',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'cycle' && hoursStart.value >= hoursEnd.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间需晚于生效时间',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.pending) {
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
this.pending = true
|
||||
pending.value = true
|
||||
|
||||
let params = {
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
if (type === 'custom') {
|
||||
uni.showLoading({
|
||||
title: '生成中'
|
||||
})
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: 0,
|
||||
operate: 0,
|
||||
isAdmin: customAdmin.value ? 1 : 0,
|
||||
pwd: customPassword.value,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor(customStartTime.value / 1000),
|
||||
endTime: Math.floor(customEndTime.value / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
if (code === 0 && data.status === 0) {
|
||||
console.log(1111, data)
|
||||
const { code: requestCode, message } = await addCustomPasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
isCoerced: 2,
|
||||
pwdRight: 0
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyboardPwdName = this.temporaryName
|
||||
params.keyboardPwdType = 3
|
||||
params.startDate = new Date().setHours(0, 0, 0, 0)
|
||||
params.endDate = this.temporaryTime
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = this.permanentName
|
||||
params.keyboardPwdType = 2
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
}
|
||||
const { code, data, message } = await createPsaawordRequest(params)
|
||||
if (code === 0) {
|
||||
addType: 1,
|
||||
pwdUserNo: data.no,
|
||||
pwdRight: customAdmin.value ? 1 : 0,
|
||||
keyboardPwdType: customPermanent.value ? 2 : 3,
|
||||
keyboardPwdName: customName.value,
|
||||
keyboardPwd: customPassword.value,
|
||||
startDate: customStartTime.value,
|
||||
endDate: customEndTime.value
|
||||
})
|
||||
uni.hideLoading()
|
||||
if (requestCode === 0) {
|
||||
uni.reportEvent('create_password', {})
|
||||
this.updatePasswordSearch({
|
||||
...this.passwordSearch,
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
this.getPasswordList(this.passwordSearch)
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showModal({
|
||||
title: '密码生成成功',
|
||||
content: `密码:${data.keyboardPwd}`,
|
||||
content: `密码:${customPassword.value}`,
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: data.keyboardPwd,
|
||||
data: customPassword.value,
|
||||
success: () => {
|
||||
that.backAndToast('复制成功')
|
||||
$basic.backAndToast('复制成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -199,24 +485,144 @@
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
this.pending = false
|
||||
},
|
||||
changePermanentInput(e) {
|
||||
this.permanentName = e
|
||||
},
|
||||
changeTemporaryInput(e) {
|
||||
this.temporaryName = e
|
||||
},
|
||||
changeTemporaryTime(e) {
|
||||
this.temporaryTime = e
|
||||
},
|
||||
clickTab(data) {
|
||||
this.currnetIndex = data.index
|
||||
},
|
||||
changeSwiper(e) {
|
||||
this.currnetIndex = e.detail.current
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '创建失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '创建失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let params = {
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
isCoerced: 2,
|
||||
pwdRight: 0
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyboardPwdName = temporaryName.value
|
||||
params.keyboardPwdType = 3
|
||||
params.startDate = new Date().setHours(0, 0, 0, 0)
|
||||
params.endDate = temporaryTime.value
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'permanent') {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = permanentName.value
|
||||
params.keyboardPwdType = 2
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'single') {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = singleName.value
|
||||
params.keyboardPwdType = 1
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
} else if (type === 'cycle') {
|
||||
params.startDate = new Date().getTime()
|
||||
params.endDate = new Date().getTime()
|
||||
params.keyboardPwdName = cycleName.value
|
||||
params.keyboardPwdType = cycleOptions.value[0][defaultIndex.value].type
|
||||
params.hoursStart = hoursStart.value
|
||||
params.hoursEnd = hoursEnd.value
|
||||
} else {
|
||||
params.startDate = 0
|
||||
params.endDate = 0
|
||||
params.keyboardPwdName = emptyName.value
|
||||
params.keyboardPwdType = 4
|
||||
params.hoursStart = 0
|
||||
params.hoursEnd = 0
|
||||
}
|
||||
const { code, data, message } = await createPsaawordRequest(params)
|
||||
if (code === 0) {
|
||||
uni.reportEvent('create_password', {})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showModal({
|
||||
title: '密码生成成功',
|
||||
content: `密码:${data.keyboardPwd}`,
|
||||
cancelText: '复制',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: data.keyboardPwd,
|
||||
success: () => {
|
||||
$basic.backAndToast('复制成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pending.value = false
|
||||
}
|
||||
|
||||
const changeName = (type, e) => {
|
||||
if (type === 'temporary') {
|
||||
temporaryName.value = e
|
||||
} else if (type === 'permanent') {
|
||||
permanentName.value = e
|
||||
} else if (type === 'single') {
|
||||
singleName.value = e
|
||||
} else if (type === 'cycle') {
|
||||
cycleName.value = e
|
||||
} else if (type === 'custom') {
|
||||
customName.value = e
|
||||
} else if (type === 'empty') {
|
||||
emptyName.value = e
|
||||
}
|
||||
}
|
||||
|
||||
const changeTemporaryTime = e => {
|
||||
temporaryTime.value = e
|
||||
}
|
||||
|
||||
const clickTab = data => {
|
||||
currentIndex.value = data.index
|
||||
}
|
||||
|
||||
const changeSwiper = e => {
|
||||
currentIndex.value = e.detail.current
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||
if (type === 'temporary' && temporaryStartTime.value >= temporaryEndTime.value) {
|
||||
uni.showToast({
|
||||
title: '失效时间要大于生效时间',
|
||||
icon: 'none'
|
||||
|
||||
@ -1,85 +1,306 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="item">
|
||||
<view class="item" v-if="$lock.currentPasswordInfo.isCustom === 1">
|
||||
<view class="item-title">密码号</view>
|
||||
<view class="item-content">{{ $lock.currentPasswordInfo.pwdUserNo }}</view>
|
||||
</view>
|
||||
<view
|
||||
class="item"
|
||||
:style="{ marginTop: $lock.currentPasswordInfo.isCustom === 1 ? '2rpx' : '0' }"
|
||||
@click="() => $lock.currentPasswordInfo.isCustom === 1 && $refs.modalPassword.open()"
|
||||
>
|
||||
<view class="item-title">密码</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.keyboardPwd }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentPasswordInfo.keyboardPwd }}</view>
|
||||
<up-icon v-if="$lock.currentPasswordInfo.isCustom === 1" name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.keyboardPwdName }}</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentPasswordInfo.keyboardPwdName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" @click="updateTime">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="currentPasswordInfo.keyboardPwdType === 2">永久</view>
|
||||
<view v-else-if="currentPasswordInfo.keyboardPwdType <= 4">
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">
|
||||
<view v-if="$lock.currentPasswordInfo.keyboardPwdType === 2">永久</view>
|
||||
<view v-else-if="$lock.currentPasswordInfo.keyboardPwdType <= 4">
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
timeFormat($lock.currentPasswordInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
timeFormat($lock.currentPasswordInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
{{ currentPasswordInfo.timeText.slice(0, -3) }}
|
||||
{{ $lock.currentPasswordInfo.timeText.slice(0, -3) }}
|
||||
</view>
|
||||
</view>
|
||||
<up-icon v-if="$lock.currentPasswordInfo.isCustom === 1" name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">发送人</view>
|
||||
<view class="item-content">{{ currentPasswordInfo.senderUsername }}</view>
|
||||
<view class="item-content">{{ $lock.currentPasswordInfo.senderUsername }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{
|
||||
timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
timeFormat($lock.currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
:checked="$lock.currentPasswordInfo.pwdRight"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入姓名"
|
||||
:autoClose="false"
|
||||
placeholder="请输入姓名"
|
||||
:value="$lock.currentPasswordInfo.keyboardPwdName"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
<ModalInput
|
||||
ref="modalPassword"
|
||||
title="修改密码"
|
||||
:autoClose="false"
|
||||
:maxlength="9"
|
||||
type="number"
|
||||
placeholder="密码为6-9位数字"
|
||||
:value="$lock.currentPasswordInfo.keyboardPwd"
|
||||
@confirm="changePassword"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { ref } from 'vue'
|
||||
import test from 'uview-plus/libs/function/test'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
||||
import {
|
||||
deletePsaawordRequest,
|
||||
getPasswordRequest,
|
||||
updatePasswordRequest
|
||||
} from '@/api/keyboardPwd'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useLockStore, ['currentPasswordInfo', 'passwordSearch']),
|
||||
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
||||
...mapState(useUserStore, ['userInfo'])
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']),
|
||||
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType', 'routeJump']),
|
||||
async toRecordList() {
|
||||
this.routeJump({
|
||||
name: 'typeRecordList',
|
||||
const $lock = useLockStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const modalInput = ref(null)
|
||||
const modalPassword = ref(null)
|
||||
const pending = ref(false)
|
||||
|
||||
const disabled = () => {
|
||||
uni.showToast({
|
||||
title: '暂不支持修改',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
const updateTime = () => {
|
||||
if ($lock.currentPasswordInfo.isCustom !== 1) return
|
||||
$basic.routeJump({
|
||||
name: 'temporaryDate',
|
||||
params: {
|
||||
name: this.currentPasswordInfo.keyboardPwdName,
|
||||
key: 'keyboardPwdId',
|
||||
id: this.currentPasswordInfo.keyboardPwdId
|
||||
info: JSON.stringify({ ...$lock.currentPasswordInfo, type: 'password' })
|
||||
},
|
||||
events: {
|
||||
refresh() {
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
getPasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId
|
||||
}).then(res => {
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
...res.data,
|
||||
keyboardPwdType: res.data.type
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async deletePassword() {
|
||||
const netWork = await this.getNetworkType()
|
||||
}
|
||||
|
||||
const changePassword = async password => {
|
||||
if (!test.rangeLength(password, [6, 9])) {
|
||||
uni.showToast({
|
||||
title: '密码为6-9位纯数字',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: $lock.currentPasswordInfo.pwdUserNo,
|
||||
operate: 1,
|
||||
isAdmin: $lock.currentPasswordInfo.pwdRight,
|
||||
pwd: password,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor($lock.currentPasswordInfo.startDate / 1000),
|
||||
endTime: Math.floor($lock.currentPasswordInfo.endDate / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
|
||||
if (code === 0) {
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
startDate: $lock.currentPasswordInfo.startDate,
|
||||
endDate: $lock.currentPasswordInfo.endDate,
|
||||
newKeyboardPwd: password,
|
||||
changeType: 1
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalPassword.value.close()
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
keyboardPwd: password
|
||||
})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入姓名',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
startDate: $lock.currentPasswordInfo.startDate,
|
||||
endDate: $lock.currentPasswordInfo.endDate,
|
||||
keyboardPwdName: name,
|
||||
changeType: 1
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
$lock.updateCurrentPasswordInfo({
|
||||
...$lock.currentPasswordInfo,
|
||||
keyboardPwdName: name
|
||||
})
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: $lock.currentPasswordInfo.keyboardPwdName,
|
||||
key: 'keyboardPwdId',
|
||||
id: $lock.currentPasswordInfo.keyboardPwdId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
const that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该密码',
|
||||
@ -90,32 +311,32 @@
|
||||
mask: true
|
||||
})
|
||||
const timestamp = parseInt(new Date().getTime() / 1000, 10)
|
||||
const { code } = await that.setLockPassword({
|
||||
keyId: that.keyId.toString(),
|
||||
uid: that.userInfo.uid.toString(),
|
||||
pwdNo: that.currentPasswordInfo.pwdUserNo,
|
||||
operate: 3,
|
||||
isAdmin: that.currentPasswordInfo.pwdRight,
|
||||
pwd: that.currentPasswordInfo.keyboardPwd,
|
||||
const { code } = await $bluetooth.setLockPassword({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: $lock.currentPasswordInfo.pwdUserNo,
|
||||
operate: $lock.currentPasswordInfo.isCustom === 1 ? 2 : 3,
|
||||
isAdmin: $lock.currentPasswordInfo.pwdRight,
|
||||
pwd: $lock.currentPasswordInfo.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: timestamp,
|
||||
endTime: timestamp
|
||||
})
|
||||
that.closeBluetoothConnection()
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
||||
lockId: that.currentLockInfo.lockId,
|
||||
keyboardPwdId: that.currentPasswordInfo.keyboardPwdId,
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: $lock.currentPasswordInfo.keyboardPwdId,
|
||||
deleteType: 1
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
that.updatePasswordSearch({
|
||||
...that.passwordSearch,
|
||||
$lock.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getPasswordList(that.passwordSearch)
|
||||
that.backAndToast('删除成功')
|
||||
$lock.getPasswordList($lock.passwordSearch)
|
||||
$basic.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
@ -134,8 +355,6 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
keyId: that.keyId.toString(),
|
||||
uid: that.userInfo.uid.toString(),
|
||||
pwdNo: password.pwdUserNo,
|
||||
operate: 3,
|
||||
operate: password.isCustom === 1 ? 2 : 3,
|
||||
isAdmin: password.pwdRight,
|
||||
pwd: password.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
@ -405,7 +405,7 @@
|
||||
}
|
||||
|
||||
.password-right-bottom {
|
||||
font-size: 24rpx;
|
||||
font-size: 23rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@
|
||||
import { updateFaceRequest } from '@/api/face'
|
||||
import { updatePalmVeinRequest } from '@/api/palmVein'
|
||||
import { updateKeyDateRequest } from '@/api/key'
|
||||
import { updatePasswordRequest } from '@/api/keyboardPwd'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
@ -122,7 +123,7 @@
|
||||
if (!canSubmit.value) {
|
||||
return
|
||||
}
|
||||
if (startDate.value > endDate.value) {
|
||||
if (startDate.value >= endDate.value) {
|
||||
uni.showToast({
|
||||
title: '失效日期需晚于生效日期',
|
||||
icon: 'none'
|
||||
@ -139,8 +140,75 @@
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
if (info.value.type === 'password') {
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
pwdNo: info.value.pwdUserNo,
|
||||
operate: 1,
|
||||
isAdmin: info.value.pwdRight,
|
||||
pwd: info.value.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: Math.floor(startDate.value / 1000),
|
||||
endTime: Math.floor(endDate.value / 1000)
|
||||
}
|
||||
const { code, data } = await $bluetooth.setLockPassword(params)
|
||||
|
||||
if (info.value.type === 'key') {
|
||||
if (code === 0) {
|
||||
const { code, message } = await updatePasswordRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyboardPwdId: info.value.keyboardPwdId,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
keyboardPwdType: 3,
|
||||
changeType: 1
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
if (data.status === 0xff) {
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '密码已满',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '密码已存在',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if (info.value.type === 'key') {
|
||||
const data = await updateKeyDateRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
keyId: info.value.keyId,
|
||||
@ -153,10 +221,6 @@
|
||||
if (data.code === 0) {
|
||||
eventChannel.emit('refresh', {})
|
||||
$basic.backAndToast('更新成功')
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
|
||||
@ -402,6 +402,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2],
|
||||
data: {
|
||||
no: decrypted[9] * 256 + decrypted[10],
|
||||
status: decrypted[11]
|
||||
}
|
||||
})
|
||||
|
||||
@ -196,7 +196,7 @@ export const useLockStore = defineStore('lock', {
|
||||
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 单次`
|
||||
} else if (data.list[i].keyboardPwdType === 2) {
|
||||
data.list[i].timeText =
|
||||
`${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久`
|
||||
`${timeFormat(new Date(data.list[i].created_at), 'yyyy-mm-dd h:M')} 永久`
|
||||
} else if (data.list[i].keyboardPwdType === 3) {
|
||||
data.list[i].timeText = `${data.list[i].validTimeStr} 限时`
|
||||
} else if (data.list[i].keyboardPwdType === 4) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user