完成卡片相关UI及部分逻辑
This commit is contained in:
parent
30aa70ae38
commit
2f9bd54361
12
api/card.js
Normal file
12
api/card.js
Normal file
@ -0,0 +1,12 @@
|
||||
import request from '../utils/request'
|
||||
|
||||
// card 卡片模块
|
||||
|
||||
// 获取卡片列表
|
||||
export function getCardList(data) {
|
||||
return request({
|
||||
url: '/identityCard/list',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
48
components/LockSwitch/LockSwitch.vue
Normal file
48
components/LockSwitch/LockSwitch.vue
Normal file
@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<view class="bg-white">
|
||||
<view class="name">
|
||||
<view class="name-text">{{ title }}</view>
|
||||
<switch :checked="checked" class="mr-4 transform-scale-90" @change="change" color="#002ce5" />
|
||||
</view>
|
||||
<view class="px-3 text-sm whitespace-pre-line pb-2" v-if="placeholder">{{ placeholder }}</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
const checked = ref(false)
|
||||
|
||||
const props = defineProps({
|
||||
title: String,
|
||||
placeholder: String,
|
||||
value: Boolean
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
checked.value = props.value
|
||||
})
|
||||
|
||||
const change = e => {
|
||||
console.log(111, e)
|
||||
// this.$emit('changeInput', e.detail.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.name {
|
||||
height: 100rpx;
|
||||
width: 750rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: #ffffff;
|
||||
|
||||
.name-text {
|
||||
margin-left: 32rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
42
pages.json
42
pages.json
@ -141,6 +141,48 @@
|
||||
"navigationBarTitleText": "添加锁",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cardList/cardList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "卡",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/createCard/createCard",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加卡",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/cardDetail/cardDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "卡详情",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/fingerprintList/fingerprintList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "指纹",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/createFingerprint/createFingerprint",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加指纹",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/fingerprintDetail/fingerprintDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "指纹详情",
|
||||
"disableScroll": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
166
pages/cardDetail/cardDetail.vue
Normal file
166
pages/cardDetail/cardDetail.vue
Normal file
@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<view>
|
||||
<view v-if="info">
|
||||
<view class="item">
|
||||
<view class="item-title">卡号</view>
|
||||
<view class="item-content">{{ info.cardNumber }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="item-content">{{ info.cardName }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="info.cardType === 1">永久</view>
|
||||
<view v-else-if="info.cardType === 2">
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx" v-if="info.cardType === 4">
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">添加者</view>
|
||||
<view class="item-content">{{ info.senderUsername }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
|
||||
const $lock = useLockStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
console.log(info.value)
|
||||
}
|
||||
})
|
||||
|
||||
const deletePassword = async () => {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
const that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该密码',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const timestamp = parseInt(new Date().getTime() / 1000, 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,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: timestamp,
|
||||
endTime: timestamp
|
||||
})
|
||||
that.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
||||
lockId: that.currentLockInfo.lockId,
|
||||
keyboardPwdId: that.currentPasswordInfo.keyboardPwdId,
|
||||
deleteType: 1
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
that.updatePasswordSearch({
|
||||
...that.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getPasswordList(that.passwordSearch)
|
||||
that.backAndToast('删除成功')
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (code === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item-title {
|
||||
width: 350rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: 24rpx 32rpx;
|
||||
background-color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.tips {
|
||||
padding: 24rpx 32rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin: 32rpx;
|
||||
width: 686rpx;
|
||||
height: 88rpx;
|
||||
background-color: #df282d;
|
||||
color: white;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
412
pages/cardList/cardList.vue
Normal file
412
pages/cardList/cardList.vue
Normal file
@ -0,0 +1,412 @@
|
||||
<template>
|
||||
<view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
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">
|
||||
<up-search
|
||||
shape="square"
|
||||
:searchIconSize="48"
|
||||
:inputStyle="{ fontSize: '32rpx' }"
|
||||
:height="80"
|
||||
placeholder="搜索"
|
||||
:clearabled="false"
|
||||
@change="changeSearch"
|
||||
v-model="searchStr"
|
||||
bgColor="#ffffff"
|
||||
:showAction="false"
|
||||
maxlength="50"
|
||||
></up-search>
|
||||
</view>
|
||||
<view style="padding: 0 0 calc(env(safe-area-inset-bottom) + 250rpx) 0">
|
||||
<view v-if="list.length === 0 && requestFinished">
|
||||
<image
|
||||
class="empty-list"
|
||||
src="/static/images/background_empty_list.png"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="empty-list-text">暂无数据</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<up-swipe-action>
|
||||
<up-swipe-action-item
|
||||
ref="swipeItem"
|
||||
:options="options"
|
||||
v-for="item in list"
|
||||
:key="item.keyboardPwdId"
|
||||
:threshold="50"
|
||||
@click="deleteItem(item)"
|
||||
>
|
||||
<view class="item" @click="toDetail(item)">
|
||||
<image
|
||||
class="item-left"
|
||||
src="/static/images/icon_card_white.png"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="item-right">
|
||||
<view style="display: flex; align-items: center">
|
||||
<view class="item-right-top">{{ item.cardName }}</view>
|
||||
<view class="status">
|
||||
{{ item.statusText }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-right-bottom">{{ item.timeText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="line"></view>
|
||||
</up-swipe-action-item>
|
||||
</up-swipe-action>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="button">
|
||||
<view class="button-reset" @click="toCreate">重置卡片</view>
|
||||
<view class="button-create" @click="toCreate">添加卡片</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { getCardList } from '@/api/card'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
const $lock = useLockStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const searchStr = ref('')
|
||||
const list = ref([])
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 50
|
||||
const total = ref(0)
|
||||
const lockId = ref(null)
|
||||
|
||||
const deviceInfo = ref(null)
|
||||
const requestFinished = ref(false)
|
||||
const refresherTriggered = ref(false)
|
||||
const options = ref([
|
||||
{
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: '#f56c6c'
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
onMounted(async () => {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
console.log(deviceInfo.value)
|
||||
lockId.value = $bluetooth.currentLockInfo.lockId
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
requestFinished.value = true
|
||||
uni.hideLoading()
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const deleteItem = async data => {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
const password = data
|
||||
const that = this
|
||||
let index = this.passwordList.findIndex(item => item.keyboardPwdId === password.keyboardPwdId)
|
||||
that.$refs.swipeItem[index].closeHandler()
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该密码',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
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: password.pwdUserNo,
|
||||
operate: 3,
|
||||
isAdmin: password.pwdRight,
|
||||
pwd: password.keyboardPwd,
|
||||
userCountLimit: 0xffff,
|
||||
startTime: timestamp,
|
||||
endTime: timestamp
|
||||
})
|
||||
that.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
||||
lockId: that.currentLockInfo.lockId,
|
||||
keyboardPwdId: password.keyboardPwdId,
|
||||
deleteType: 1
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
that.updatePasswordSearch({
|
||||
...$lock.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
await that.getPasswordList($lock.passwordSearch)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (code === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const refresherList = async () => {
|
||||
refresherTriggered.value = true
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value,
|
||||
searchStr: searchStr.value
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
refresherTriggered.value = false
|
||||
}
|
||||
|
||||
const nextPage = async () => {
|
||||
if (total.value <= pageNo.value * pageSize) {
|
||||
return
|
||||
}
|
||||
const page = pageNo.value + 1
|
||||
const params = {
|
||||
searchStr: searchStr.value,
|
||||
pageNo: page
|
||||
}
|
||||
const { code, message } = await getList(params)
|
||||
if (code === 0) {
|
||||
pageNo.value = page
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const getList = async params => {
|
||||
const {
|
||||
data: { timestamp }
|
||||
} = await $bluetooth.updateServerTimestamp()
|
||||
const { code, data, message } = await getCardList({
|
||||
...params,
|
||||
lockId: lockId.value,
|
||||
pageSize
|
||||
})
|
||||
if (code === 0) {
|
||||
total.value = data.total
|
||||
for (let i = 0; i < data.list.length; i++) {
|
||||
if (data.list[i].cardStatus === 1 && data.list[i].startDate > timestamp) {
|
||||
data.list[i].statusText = '未生效'
|
||||
} else if (data.list[i].cardStatus === 2) {
|
||||
data.list[i].statusText = '已失效'
|
||||
}
|
||||
|
||||
if (data.list[i].cardType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
} else if (data.list[i].cardType === 2) {
|
||||
data.list[i].timeText =
|
||||
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
|
||||
' - ' +
|
||||
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM') +
|
||||
' 限时'
|
||||
} else {
|
||||
data.list[i].timeText =
|
||||
timeFormat(data.list[i].startDate, 'yyyy-mm-dd') +
|
||||
' - ' +
|
||||
timeFormat(data.list[i].endDate, 'yyyy-mm-dd') +
|
||||
' 循环'
|
||||
}
|
||||
}
|
||||
if (params.pageNo === 1) {
|
||||
list.value = data.list
|
||||
} else {
|
||||
list.value = list.value.concat(data.list)
|
||||
}
|
||||
return { code }
|
||||
}
|
||||
return { code, message }
|
||||
}
|
||||
|
||||
const changeSearch = async data => {
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
searchStr: data,
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toCreate = () => {
|
||||
$basic.routeJump({
|
||||
name: 'createCard'
|
||||
})
|
||||
}
|
||||
|
||||
const toDetail = item => {
|
||||
$basic.routeJump({
|
||||
name: 'cardDetail',
|
||||
params: {
|
||||
info: JSON.stringify(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search {
|
||||
padding: 32rpx;
|
||||
width: 686rpx !important;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||
font-weight: bold;
|
||||
|
||||
.button-reset {
|
||||
margin-left: 50rpx;
|
||||
width: 300rpx;
|
||||
height: 88rpx;
|
||||
background-color: #df282d;
|
||||
color: white;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
|
||||
.button-create {
|
||||
margin-left: 50rpx;
|
||||
width: 300rpx;
|
||||
height: 88rpx;
|
||||
background-color: #63b8af;
|
||||
color: white;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #ffffff;
|
||||
height: 120rpx;
|
||||
width: 750rpx;
|
||||
|
||||
.item-left {
|
||||
margin-left: 32rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
margin-right: 32rpx;
|
||||
margin-left: 32rpx;
|
||||
width: 574rpx;
|
||||
|
||||
.item-right-top {
|
||||
max-width: 400rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.item-right-bottom {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
height: 2rpx;
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
.empty-list {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
margin: 300rpx auto 20rpx 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.empty-list-text {
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-left: auto;
|
||||
font-size: 26rpx;
|
||||
color: #df282d;
|
||||
}
|
||||
</style>
|
||||
290
pages/createCard/createCard.vue
Normal file
290
pages/createCard/createCard.vue
Normal file
@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="tabs">
|
||||
<up-tabs
|
||||
:list="tabs"
|
||||
lineWidth="40rpx"
|
||||
lineHeight="5rpx"
|
||||
:current="currentIndex"
|
||||
lineColor="#63b8af"
|
||||
@click="clickTab"
|
||||
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
|
||||
>
|
||||
</up-tabs>
|
||||
</view>
|
||||
<swiper
|
||||
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
|
||||
v-if="deviceInfo"
|
||||
:list="tabs"
|
||||
:autoplay="false"
|
||||
:circular="true"
|
||||
:current="currentIndex"
|
||||
@change="changeSwiper"
|
||||
>
|
||||
<swiper-item>
|
||||
<LockInput
|
||||
:value="permanentName"
|
||||
title="姓名"
|
||||
placeholder="请输入"
|
||||
@change-input="changePermanentInput"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<LockSwitch
|
||||
:value="false"
|
||||
title="是否为管理员"
|
||||
@change="changePermanentInput"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="mt-3 mb-3">
|
||||
<LockSwitch
|
||||
:value="false"
|
||||
title="胁迫卡"
|
||||
@change="changePermanentInput"
|
||||
:placeholder="placeholder"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="button" @click="createPassword('permanent')">下一步</view>
|
||||
</swiper-item>
|
||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||
<LockInput
|
||||
:value="temporaryName"
|
||||
title="姓名"
|
||||
placeholder="请输入"
|
||||
@change-input="changeTemporaryInput"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<LockDatetimePicker
|
||||
title="生效时间"
|
||||
:value="temporaryTime"
|
||||
:minDate="minDate"
|
||||
:maxDate="maxDate"
|
||||
type="datehour"
|
||||
@change-time="changeTemporaryTime"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<LockDatetimePicker
|
||||
title="失效时间"
|
||||
:value="temporaryTime"
|
||||
:minDate="minDate"
|
||||
:maxDate="maxDate"
|
||||
type="datehour"
|
||||
@change-time="changeTemporaryTime"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<LockSwitch
|
||||
:value="false"
|
||||
title="是否为管理员"
|
||||
@change="changePermanentInput"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="mt-3 mb-3">
|
||||
<LockSwitch
|
||||
:value="false"
|
||||
title="胁迫卡"
|
||||
@change="changePermanentInput"
|
||||
:placeholder="placeholder"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="button" @click="createPassword('temporary')">下一步</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { createPsaawordRequest } from '@/api/keyboardPwd'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
name: '永久'
|
||||
},
|
||||
{
|
||||
name: '限时'
|
||||
}
|
||||
]
|
||||
const permanentName = ref('')
|
||||
const temporaryName = ref('')
|
||||
const temporaryTime = ref(Number(new Date()))
|
||||
const minDate = ref(Number(new Date()))
|
||||
const maxDate = ref(Number(4133951940000))
|
||||
const currentIndex = ref(0)
|
||||
const deviceInfo = ref(null)
|
||||
const pending = ref(false)
|
||||
const placeholder =
|
||||
'当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息会推送给管理员,该功能需要锁联网。\n请不要将胁迫卡用于日常开锁'
|
||||
|
||||
onLoad(async () => {
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
temporaryTime.value = setTime()
|
||||
minDate.value = Number(getNextFullHour())
|
||||
maxDate.value = Number(getFutureTimestamp())
|
||||
})
|
||||
|
||||
const getNextFullHour = () => {
|
||||
const now = new Date()
|
||||
const currentHour = now.getHours()
|
||||
now.setHours(currentHour)
|
||||
now.setMinutes(0)
|
||||
now.setSeconds(0)
|
||||
now.setMilliseconds(0)
|
||||
|
||||
return now
|
||||
}
|
||||
|
||||
const getFutureTimestamp = () => {
|
||||
const currentDate = new Date()
|
||||
|
||||
const year = currentDate.getFullYear()
|
||||
const month = currentDate.getMonth()
|
||||
const day = currentDate.getDate()
|
||||
|
||||
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
|
||||
|
||||
return futureDate.getTime()
|
||||
}
|
||||
|
||||
const setTime = () => {
|
||||
const now = new Date()
|
||||
now.setMinutes(0, 0, 0)
|
||||
|
||||
return now.getTime()
|
||||
}
|
||||
|
||||
const createPassword = async type => {
|
||||
if (
|
||||
(type === 'temporary' && temporaryName.value === '') ||
|
||||
(type === 'permanent' && permanentName.value === '')
|
||||
) {
|
||||
uni.showToast({
|
||||
title: '名称不能为空',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
pending.value = true
|
||||
|
||||
let params = {
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
isCoerced: 2,
|
||||
pwdRight: 0
|
||||
}
|
||||
if (type === 'temporary') {
|
||||
params.keyboardPwdName = this.temporaryName
|
||||
params.keyboardPwdType = 3
|
||||
params.startDate = new Date().getTime()
|
||||
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) {
|
||||
uni.reportEvent('create_password', {})
|
||||
this.updatePasswordSearch({
|
||||
...this.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
this.getPasswordList(this.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 changePermanentInput = e => {
|
||||
permanentName.value = e
|
||||
}
|
||||
|
||||
const changeTemporaryInput = e => {
|
||||
temporaryName.value = e
|
||||
}
|
||||
|
||||
const changeTemporaryTime = e => {
|
||||
temporaryTime.value = e
|
||||
}
|
||||
|
||||
const clickTab = data => {
|
||||
currentIndex.value = data.index
|
||||
}
|
||||
|
||||
const changeSwiper = e => {
|
||||
currentIndex.value = e.detail.current
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tabs {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.text {
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 50rpx;
|
||||
color: #262626;
|
||||
font-size: 26rpx;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.button {
|
||||
border-radius: 64rpx;
|
||||
width: 686rpx;
|
||||
margin-left: 32rpx;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
text-align: center;
|
||||
background-color: #63b8af;
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
7
pages/createFingerprint/createFingerprint.vue
Normal file
7
pages/createFingerprint/createFingerprint.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<view> </view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
7
pages/fingerprintDetail/fingerprintDetail.vue
Normal file
7
pages/fingerprintDetail/fingerprintDetail.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<view> </view>
|
||||
</template>
|
||||
|
||||
<script setup></script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
7
pages/fingerprintList/fingerprintList.vue
Normal file
7
pages/fingerprintList/fingerprintList.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<view> </view>
|
||||
</template>
|
||||
|
||||
<script setup></script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@ -68,6 +68,22 @@
|
||||
<image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image>
|
||||
<view>密码</view>
|
||||
</view>
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'cardList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_card.png"></image>
|
||||
<view>卡</view>
|
||||
</view>
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'fingerprintList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_fingerprint.png"></image>
|
||||
<view>指纹</view>
|
||||
</view>
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'keyList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_admin_black.png"></image>
|
||||
<view>授权管理员</view>
|
||||
</view>
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'keyList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_record.png"></image>
|
||||
<view>操作记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="setting" @click="routeJump({ name: 'setting' })">
|
||||
@ -428,7 +444,6 @@
|
||||
.menu {
|
||||
margin-top: 32rpx;
|
||||
margin-left: 32rpx;
|
||||
padding-bottom: 32rpx;
|
||||
width: 686rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 32rpx;
|
||||
@ -449,16 +464,16 @@
|
||||
|
||||
.menu-main {
|
||||
padding-top: 32rpx;
|
||||
padding-bottom: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32rpx;
|
||||
font-size: 28rpx;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
margin-left: 43rpx;
|
||||
|
||||
.menu-main-view {
|
||||
width: 150rpx;
|
||||
margin-bottom: 48rpx;
|
||||
|
||||
.menu-main-image {
|
||||
filter: sepia(100%) saturate(10000%) hue-rotate(180deg) brightness(0.1);
|
||||
|
||||
BIN
static/images/icon_add_blue.png
Normal file
BIN
static/images/icon_add_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
static/images/icon_admin_black.png
Normal file
BIN
static/images/icon_admin_black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
static/images/icon_card.png
Normal file
BIN
static/images/icon_card.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
static/images/icon_card_white.png
Executable file
BIN
static/images/icon_card_white.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
BIN
static/images/icon_fingerprint.png
Normal file
BIN
static/images/icon_fingerprint.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
BIN
static/images/icon_record.png
Normal file
BIN
static/images/icon_record.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@ -111,6 +111,36 @@ const pages = [
|
||||
name: 'addLockGuid',
|
||||
path: '/pages/addLockGuid/addLockGuid',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'cardList',
|
||||
path: '/pages/cardList/cardList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'createCard',
|
||||
path: '/pages/createCard/createCard',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'cardDetail',
|
||||
path: '/pages/cardDetail/cardDetail',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'fingerprintList',
|
||||
path: '/pages/fingerprintList/fingerprintList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'createFingerprint',
|
||||
path: '/pages/createFingerprint/createFingerprint',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'fingerprintDetail',
|
||||
path: '/pages/fingerprintDetail/fingerprintDetail',
|
||||
tabBar: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -102,10 +102,12 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
// 更新服务端时间戳
|
||||
async updateServerTimestamp() {
|
||||
const { code, data, message } = await getServerDatetime({})
|
||||
let timestamp = new Date().getTime()
|
||||
if (code === 0) {
|
||||
this.serverTimestamp = parseInt(data.date / 1000, 10)
|
||||
timestamp = data.date
|
||||
}
|
||||
return { code, data, message }
|
||||
return { code, data: { ...data, timestamp }, message }
|
||||
},
|
||||
// 关闭全部蓝牙监听并关闭蓝牙模拟
|
||||
closeAllBluetooth() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user