2024-08-20 19:54:37 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
2024-08-22 15:03:30 +08:00
|
|
|
|
<view v-if="!penging">
|
|
|
|
|
|
<view v-if="isLogin">
|
|
|
|
|
|
<scroll-view scroll-y="true" :style="{ height: 'calc(100vh)' }" lower-threshold="100"
|
|
|
|
|
|
@refresherrefresh="refresherList" :refresher-enabled="true" @scrolltolower="nextPage"
|
|
|
|
|
|
:refresher-triggered="refresherTriggered">
|
|
|
|
|
|
<view class="search">
|
|
|
|
|
|
<up-search :searchIconSize="48" :inputStyle="{ fontSize: '32rpx' }" @focus="getFocus" @blur="getBlur"
|
|
|
|
|
|
:height="80" placeholder="搜索" :clearabled="false" @change="changeSearch"
|
|
|
|
|
|
v-model="search.searchStr" bgColor="#ffffff" :showAction="false" maxlength="20"></up-search>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="lock-list" v-if="!penging">
|
|
|
|
|
|
<view v-if="lockList.length === 0 && search.searchStr === '' && !focus">
|
2024-08-22 16:37:15 +08:00
|
|
|
|
<image src="/static/images/icon_add.png" mode="aspectFill" class="button-add-big" @click="toSearchDevice"></image>
|
2024-08-22 15:03:30 +08:00
|
|
|
|
<view class="text">填加锁时,手机必须在锁旁边</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view v-else>
|
|
|
|
|
|
<view class="group" v-for="group in lockList" :key="group.groupId">
|
|
|
|
|
|
<view class="group-name">
|
|
|
|
|
|
<view class="group-name-text">{{group.groupName}}</view>
|
|
|
|
|
|
<view class="group-name-line"></view>
|
|
|
|
|
|
</view>
|
2024-08-22 16:37:15 +08:00
|
|
|
|
<view class="lock" v-for="lock in group.lockList" :key="lock.lockId" @click="toLockDeatil(lock)">
|
2024-08-22 15:03:30 +08:00
|
|
|
|
<view class="lock-top">
|
|
|
|
|
|
<image class="lock-image-lock" src="/static/images/icon_lock.png"></image>
|
|
|
|
|
|
<view class="lock-top-right">
|
|
|
|
|
|
<view class="lock-top-right-power">
|
|
|
|
|
|
<image class="lock-top-right-power-image" src="/static/images/icon_power.png"></image>
|
|
|
|
|
|
<view class="lock-top-right-power-text">{{lock.electricQuantity}}%</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view>{{getRole(lock.userType)}}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="lock-name">{{lock.lockName}}</view>
|
|
|
|
|
|
<view class="lock-time">
|
|
|
|
|
|
<view v-if="lock.keyType !== 1" style="font-size: 32rpx">{{ getTimeLimit(lock.keyType) }}</view>
|
|
|
|
|
|
<view v-else>
|
|
|
|
|
|
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
|
|
|
|
|
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</scroll-view>
|
|
|
|
|
|
<image v-if="lockList.length !== 0" src="/static/images/icon_add.png" mode="aspectFill"
|
2024-08-22 16:37:15 +08:00
|
|
|
|
class="button-add" @click="toSearchDevice"></image>
|
2024-08-22 15:03:30 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view v-else>
|
|
|
|
|
|
<view class="button-login" @click="login">登录</view>
|
|
|
|
|
|
</view>
|
2024-08-21 16:20:11 +08:00
|
|
|
|
</view>
|
2024-08-22 15:03:30 +08:00
|
|
|
|
</view>
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-08-22 15:03:30 +08:00
|
|
|
|
import { timeFormat } from 'uview-plus'
|
2024-08-20 19:54:37 +08:00
|
|
|
|
import { getUserInfoRequest } from '@/api/user'
|
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
2024-08-22 15:03:30 +08:00
|
|
|
|
import { useLockStore } from '@/stores/lock'
|
2024-08-22 16:37:15 +08:00
|
|
|
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
|
|
|
|
|
import { useBasicStore } from '@/stores/basic'
|
2024-08-20 19:54:37 +08:00
|
|
|
|
import { mapState, mapActions } from 'pinia'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2024-08-22 15:03:30 +08:00
|
|
|
|
search: {
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: 50,
|
|
|
|
|
|
searchStr: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
refresherTriggered: false,
|
|
|
|
|
|
focus: false,
|
2024-08-22 16:37:15 +08:00
|
|
|
|
penging: true
|
2024-08-20 19:54:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2024-08-22 15:03:30 +08:00
|
|
|
|
...mapState(useUserStore, ['userInfo', 'isLogin']),
|
2024-08-22 16:37:15 +08:00
|
|
|
|
...mapState(useLockStore, ['lockList', 'lockTotal']),
|
|
|
|
|
|
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']),
|
2024-08-20 19:54:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
async onLoad() {
|
2024-08-21 16:20:11 +08:00
|
|
|
|
uni.showLoading({
|
|
|
|
|
|
title: '加载中'
|
|
|
|
|
|
})
|
|
|
|
|
|
const token = uni.getStorageSync('token')
|
|
|
|
|
|
if(token) {
|
|
|
|
|
|
this.updateLoginStatus(true)
|
2024-08-22 15:03:30 +08:00
|
|
|
|
const code = await this.getUserInfo()
|
|
|
|
|
|
if(code === 0) {
|
|
|
|
|
|
await this.getLockList(this.search)
|
|
|
|
|
|
}
|
2024-08-21 16:20:11 +08:00
|
|
|
|
}
|
2024-08-22 15:03:30 +08:00
|
|
|
|
this.penging = false
|
2024-08-21 16:20:11 +08:00
|
|
|
|
uni.hideLoading()
|
2024-08-20 19:54:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-08-22 15:03:30 +08:00
|
|
|
|
timeFormat,
|
2024-08-21 16:20:11 +08:00
|
|
|
|
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'login']),
|
2024-08-22 15:03:30 +08:00
|
|
|
|
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit']),
|
2024-08-22 16:37:15 +08:00
|
|
|
|
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo', 'checkSetting']),
|
|
|
|
|
|
...mapActions(useBasicStore, ['routeJump']),
|
2024-08-22 15:03:30 +08:00
|
|
|
|
async nextPage() {
|
|
|
|
|
|
if(this.lockList.length < this.lockTotal) {
|
|
|
|
|
|
this.search.pageNo++
|
|
|
|
|
|
const { code } = await this.getLockList(this.search)
|
|
|
|
|
|
if(code !== 0) {
|
|
|
|
|
|
this.search.pageNo--
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
async refresherList() {
|
|
|
|
|
|
this.refresherTriggered = true
|
|
|
|
|
|
this.search.pageNo = 1
|
|
|
|
|
|
await this.getLockList(this.search)
|
|
|
|
|
|
this.refresherTriggered = false
|
|
|
|
|
|
},
|
|
|
|
|
|
async changeSearch(data) {
|
|
|
|
|
|
this.search.searchStr = data
|
|
|
|
|
|
await this.getLockList(this.search)
|
|
|
|
|
|
},
|
2024-08-20 19:54:37 +08:00
|
|
|
|
async getUserInfo() {
|
|
|
|
|
|
const { code, data } = await getUserInfoRequest()
|
|
|
|
|
|
if(code === 0) {
|
|
|
|
|
|
this.updateUserInfo(data)
|
|
|
|
|
|
console.log(this.userInfo)
|
|
|
|
|
|
}
|
2024-08-22 15:03:30 +08:00
|
|
|
|
return code
|
|
|
|
|
|
},
|
|
|
|
|
|
getFocus() {
|
|
|
|
|
|
this.focus = true
|
|
|
|
|
|
},
|
|
|
|
|
|
getBlur() {
|
|
|
|
|
|
this.focus = false
|
2024-08-22 16:37:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
async toSearchDevice() {
|
|
|
|
|
|
if(this.bluetoothStatus !== 0) {
|
|
|
|
|
|
this.getBluetoothStatus()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
let result = true
|
|
|
|
|
|
if(!this.isInitBluetooth) {
|
|
|
|
|
|
result = await this.initAndListenBluetooth()
|
|
|
|
|
|
}
|
|
|
|
|
|
if(result) {
|
|
|
|
|
|
this.routeJump({
|
|
|
|
|
|
name: 'searchDevice'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.checkSetting()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
async toLockDeatil(lock) {
|
|
|
|
|
|
if(this.bluetoothStatus !== 0) {
|
|
|
|
|
|
this.getBluetoothStatus()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
let result = true
|
|
|
|
|
|
if(!this.isInitBluetooth) {
|
|
|
|
|
|
result = await this.initAndListenBluetooth()
|
|
|
|
|
|
}
|
|
|
|
|
|
if(result) {
|
|
|
|
|
|
this.updateCurrentLockInfo(lock)
|
|
|
|
|
|
this.routeJump({
|
|
|
|
|
|
name: 'lockDetail'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.checkSetting()
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
page {
|
|
|
|
|
|
background-color: $uni-bg-color-grey;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2024-08-22 15:03:30 +08:00
|
|
|
|
.search {
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
width: 686rpx !important;
|
|
|
|
|
|
margin-left: 32rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-21 16:20:11 +08:00
|
|
|
|
.button-login {
|
|
|
|
|
|
margin-top: 40vh;
|
|
|
|
|
|
border-radius: 46rpx;
|
|
|
|
|
|
width: 650rpx;
|
|
|
|
|
|
height: 120rpx;
|
|
|
|
|
|
line-height: 120rpx;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-left: 50rpx;
|
|
|
|
|
|
background: #63b8af;
|
|
|
|
|
|
color: #ffffff;
|
|
|
|
|
|
font-size: 48rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2024-08-22 15:03:30 +08:00
|
|
|
|
|
|
|
|
|
|
.button-add {
|
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
|
height: 120rpx;
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
right: 50rpx;
|
|
|
|
|
|
bottom: 50rpx;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.lock-list {
|
|
|
|
|
|
padding-bottom: 32rpx;
|
|
|
|
|
|
width: 672rpx;
|
|
|
|
|
|
margin-left: 39rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.lock {
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
width: 320rpx;
|
|
|
|
|
|
height: 300rpx;
|
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
|
box-shadow: 0 8rpx 36rpx 0 rgba(0,0,0,0.12);
|
|
|
|
|
|
border-radius: 32rpx;
|
|
|
|
|
|
|
|
|
|
|
|
.lock-name {
|
|
|
|
|
|
padding: 0 24rpx;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
|
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: normal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.lock-time {
|
|
|
|
|
|
padding: 12rpx 24rpx 0 24rpx;
|
|
|
|
|
|
font-size: 22rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.lock-top {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
padding: 24rpx 24rpx 12rpx 24rpx;
|
|
|
|
|
|
font-size: 22rpx;
|
|
|
|
|
|
|
|
|
|
|
|
.lock-image-lock {
|
|
|
|
|
|
width: 64rpx;
|
|
|
|
|
|
height: 64rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.lock-top-right-power {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.lock-top-right-power-image {
|
|
|
|
|
|
width: 40rpx;
|
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
|
margin-right: 10rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.group {
|
|
|
|
|
|
width: 672rpx;
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.group-name {
|
|
|
|
|
|
width: 672rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.group-name-text {
|
|
|
|
|
|
padding: 0 32rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.group-name-line {
|
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
|
height: 3rpx;
|
|
|
|
|
|
background: #E5E5E5;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.button-add-big {
|
|
|
|
|
|
width: 400rpx;
|
|
|
|
|
|
height: 400rpx;
|
|
|
|
|
|
margin-top: 250rpx;
|
|
|
|
|
|
margin-left: 136rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
width: 672rpx;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
margin-top: 32rpx;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2024-08-20 19:54:37 +08:00
|
|
|
|
</style>
|