Merge branch 'fanpeng' into 'master'
Fanpeng See merge request StarlockTeam/wx-starlock!3
This commit is contained in:
commit
9d04ca4481
@ -30,12 +30,13 @@
|
||||
<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>{{getRole(lock.userType, lock.keyRight)}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="lock-name">{{lock.lockAlias}}</view>
|
||||
<view class="lock-time">
|
||||
<view v-if="lock.keyType === 1" style="font-size: 32rpx">{{ getTimeLimit(lock.keyType) }}</view>
|
||||
<view v-if="lock.keyType === 1 || lock.keyType === 3" 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>
|
||||
|
||||
@ -2,16 +2,31 @@
|
||||
<view>
|
||||
<view class="item">
|
||||
<view class="item-title">名称</view>
|
||||
<view class="item-content">{{ currentKeyInfo.nickname }}</view>
|
||||
<view class="item-content">{{ currentKeyInfo.keyName }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="currentKeyInfo.keyType === 1">永久</view>
|
||||
<view v-else-if="currentKeyInfo.keyType === 3">单次</view>
|
||||
<view v-else-if="currentKeyInfo.keyType === 4">
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.startDate, 'yyyy-mm-dd') }}</view>
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.endDate, 'yyyy-mm-dd') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<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>
|
||||
</view>
|
||||
<view v-if="currentKeyInfo.keyType === 4" class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效日</view>
|
||||
<view class="item-content">{{ convertWeekDaysToChineseString(currentKeyInfo.weekDays) }}</view>
|
||||
</view>
|
||||
<view class="item" v-if="currentKeyInfo.keyType === 4" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效时间</view>
|
||||
<view class="item-content">
|
||||
{{ timeFormat(currentKeyInfo.startDate, 'h:M') }}-{{ timeFormat(currentKeyInfo.endDate, 'h:M') }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">接收者</view>
|
||||
<view class="item-content">{{ currentKeyInfo.username }}</view>
|
||||
@ -78,8 +93,23 @@ export default {
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
convertWeekDaysToChineseString(weekDays) {
|
||||
const dayMap = {
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
5: '五',
|
||||
6: '六',
|
||||
7: '日'
|
||||
}
|
||||
|
||||
const chineseWeekDays = weekDays.map(day => dayMap[day])
|
||||
|
||||
return chineseWeekDays.join(',')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ page {
|
||||
}
|
||||
|
||||
.key-right-bottom {
|
||||
font-size: 26rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<view class="bottom">
|
||||
<view class="bottom-side">
|
||||
<image class="bottom-icon" src="/static/images/icon_role.png" mode="aspectFill"></image>
|
||||
<view>{{ getRole(currentLockInfo.userType) }}</view>
|
||||
<view>{{ getRole(currentLockInfo.userType, currentLockInfo.keyRight) }}</view>
|
||||
</view>
|
||||
<view class="bottom-side">
|
||||
<image class="bottom-icon" :src=" currentLockInfo.lockSetting.appUnlockOnline ?
|
||||
@ -26,18 +26,18 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu" v-if="currentLockInfo.userType === 110301">
|
||||
<view class="menu" v-if="currentLockInfo.keyRight === 1">
|
||||
<view class="menu-title">
|
||||
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
||||
<view>功能</view>
|
||||
</view>
|
||||
<view class="menu-main">
|
||||
<view v-if="currentLockInfo.userType === 110301"
|
||||
<view 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>
|
||||
<view>电子钥匙</view>
|
||||
</view>
|
||||
<view v-if="currentLockInfo.lockFeature.password || currentLockInfo.userType === 110301"
|
||||
<view 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>
|
||||
<view>密码</view>
|
||||
@ -61,6 +61,7 @@ import { useLockStore } from '@/stores/lock'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getLockNetTokenRequest } from '@/api/lock'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
@ -71,8 +72,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useBluetoothStore, ['currentLockInfo']),
|
||||
...mapState(useUserStore, ['userInfo'])
|
||||
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
||||
...mapState(useUserStore, ['userInfo']),
|
||||
...mapState(useLockStore, ['lockSearch']),
|
||||
},
|
||||
components: {
|
||||
SwitchLoading
|
||||
@ -84,9 +86,9 @@ export default {
|
||||
this.getServeTime()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useLockStore, ['getRole']),
|
||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList']),
|
||||
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']),
|
||||
...mapActions(useBasicStore, ['routeJump']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast']),
|
||||
powerTip() {
|
||||
const that = this
|
||||
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
||||
@ -151,12 +153,30 @@ export default {
|
||||
title: `${type === 'close' ? '关' : '开'}锁成功`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if(code === 13) {
|
||||
uni.showToast({
|
||||
title: `只能在循环时间内操作门锁`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if(this.currentLockInfo.keyType === 3) {
|
||||
const { code: deleteKeyCode } = await deleteKeyRequest({
|
||||
keyId: this.keyId
|
||||
})
|
||||
if(deleteKeyCode === 0) {
|
||||
this.updateLockSearch({
|
||||
...this.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
this.getLockList(this.lockSearch)
|
||||
this.backAndToast('单次钥匙已在被使用后删除', 1)
|
||||
}
|
||||
}
|
||||
this.$refs.loading.close()
|
||||
this.pending = false
|
||||
}
|
||||
|
||||
@ -11,10 +11,13 @@
|
||||
<view class="item" style="margin-top: 2rpx">
|
||||
<view class="item-title">有效期</view>
|
||||
<view v-if="currentPasswordInfo.keyboardPwdType === 2">永久</view>
|
||||
<view v-else>
|
||||
<view v-else-if="currentPasswordInfo.keyboardPwdType <= 4">
|
||||
<view class="item-content">{{ timeFormat(currentPasswordInfo.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view class="item-content">{{ timeFormat(currentPasswordInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
{{ currentPasswordInfo.timeText }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx">
|
||||
<view class="item-title">发送人</view>
|
||||
|
||||
@ -303,11 +303,11 @@ page {
|
||||
.password-right-top {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6rpx;
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.password-right-bottom {
|
||||
font-size: 26rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,6 @@ export default {
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
that.backAndToast('删除成功', 2)
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
|
||||
@ -711,6 +711,21 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
}
|
||||
})
|
||||
},
|
||||
// 周数组转换
|
||||
convertWeekdaysToNumber(weekDay) {
|
||||
let weekStr = '00000000'
|
||||
|
||||
for (const day of weekDay) {
|
||||
const index = day % 7 // 将周日的索引转换为0
|
||||
weekStr = weekStr.substring(0, index) + '1' + weekStr.substring(index + 1)
|
||||
}
|
||||
|
||||
// 倒序 weekStr
|
||||
weekStr = weekStr.split('').reverse().join('')
|
||||
|
||||
const weekRound = parseInt(weekStr, 2)
|
||||
return weekRound
|
||||
},
|
||||
// 查找设备并连接
|
||||
async searchAndConnectDevice() {
|
||||
const that = this
|
||||
@ -771,26 +786,27 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
const timestamp = parseInt(new Date().getTime() / 1000)
|
||||
const password = (Math.floor(Math.random() * 900000) + 100000).toString()
|
||||
console.log('用户未添加,开始添加用户')
|
||||
const { code: addUserCode } = await this.addLockUser({
|
||||
const addUserParams = {
|
||||
name: this.currentLockInfo.name,
|
||||
keyId: this.keyId,
|
||||
authUid: this.currentLockInfo.senderUserId.toString(),
|
||||
uid: this.currentLockInfo.uid.toString(),
|
||||
openMode: 1,
|
||||
keyType: 0,
|
||||
startDate: this.currentLockInfo.startDate === 0 ? timestamp : this.currentLockInfo.startDate,
|
||||
expireDate: this.currentLockInfo.endDate === 0 ? 0xffffffff : this.currentLockInfo.endDate,
|
||||
startDate: this.currentLockInfo.startDate === 0 ? timestamp : parseInt(this.currentLockInfo.startDate / 1000),
|
||||
expireDate: this.currentLockInfo.endDate === 0 ? 0xffffffff : parseInt(this.currentLockInfo.endDate / 1000),
|
||||
useCountLimit: this.currentLockInfo.keyType === 3 ? 1 : 0xffff,
|
||||
isRound: 0,
|
||||
weekRound: 0,
|
||||
startHour: 0,
|
||||
startMin: 0,
|
||||
endHour: 0,
|
||||
endMin: 0,
|
||||
isRound: this.currentLockInfo.keyType === 4 ? 1 : 0,
|
||||
weekRound: this.currentLockInfo.keyType === 4 ? this.convertWeekdaysToNumber(this.currentLockInfo.weekDays) : 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,
|
||||
password
|
||||
})
|
||||
console.log('添加用户蓝牙结果', addUserCode)
|
||||
}
|
||||
const { code: addUserCode } = await this.addLockUser(addUserParams)
|
||||
console.log('添加用户蓝牙结果', addUserCode, addUserParams)
|
||||
if(addUserCode === 0) {
|
||||
const { code } = await updateLockUserNoRequest({
|
||||
keyId: this.keyId,
|
||||
|
||||
@ -66,9 +66,11 @@ export const useLockStore = defineStore('lock', {
|
||||
updateCurrentPasswordInfo(info) {
|
||||
this.currentPasswordInfo = info
|
||||
},
|
||||
getRole(userType) {
|
||||
getRole(userType, keyRight) {
|
||||
if(userType === 110301) {
|
||||
return '超级管理员'
|
||||
} else if(keyRight === 1) {
|
||||
return '授权管理员'
|
||||
} else {
|
||||
return '普通用户'
|
||||
}
|
||||
@ -118,10 +120,41 @@ export const useLockStore = defineStore('lock', {
|
||||
if(code === 0) {
|
||||
this.passwordTotal = data.total
|
||||
for(let i = 0; i < data.list.length; i++) {
|
||||
if(data.list[i].keyboardPwdType === 2) {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].created_at), 'yyyy-mm-dd h:M')} 永久`
|
||||
if(data.list[i].keyboardPwdType === 1) {
|
||||
data.list[i].timeText = `${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')} 永久`
|
||||
} else if(data.list[i].keyboardPwdType === 3) {
|
||||
data.list[i].timeText = `${data.list[i].validTimeStr} 限时`
|
||||
} else if(data.list[i].keyboardPwdType === 4) {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 清空码`
|
||||
} else {
|
||||
let text = ''
|
||||
if(data.list[i].keyboardPwdType === 5) {
|
||||
text = '周末'
|
||||
} else if(data.list[i].keyboardPwdType === 6) {
|
||||
text = '每日'
|
||||
} else if(data.list[i].keyboardPwdType === 7) {
|
||||
text = '工作日'
|
||||
} else if(data.list[i].keyboardPwdType === 8) {
|
||||
text = '周一'
|
||||
} else if(data.list[i].keyboardPwdType === 9) {
|
||||
text = '周二'
|
||||
} else if(data.list[i].keyboardPwdType === 10) {
|
||||
text = '周三'
|
||||
} else if(data.list[i].keyboardPwdType === 11) {
|
||||
text = '周四'
|
||||
} else if(data.list[i].keyboardPwdType === 12) {
|
||||
text = '周五'
|
||||
} else if(data.list[i].keyboardPwdType === 13) {
|
||||
text = '周六'
|
||||
} else if(data.list[i].keyboardPwdType === 14) {
|
||||
text = '周日'
|
||||
}
|
||||
data.list[i].timeText = `${text} ${data.list[i].hoursStart}:00-${data.list[i].hoursEnd}:00 循环`
|
||||
}
|
||||
if(data.list[i].isCustom === 1) {
|
||||
data.list[i].timeText += ' 自定义'
|
||||
}
|
||||
}
|
||||
if(params.pageNo === 1) {
|
||||
@ -143,10 +176,15 @@ export const useLockStore = defineStore('lock', {
|
||||
if(code === 0) {
|
||||
this.keyTotal = data.total
|
||||
for(let i = 0; i < data.list.length; i++) {
|
||||
if(data.list[i].keyType === 2) {
|
||||
console.log(data.list[i].keyType)
|
||||
if(data.list[i].keyType === 1) {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].sendDate), 'yyyy-mm-dd h:M')} 永久`
|
||||
} 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')} 限时`
|
||||
} else if(data.list[i].keyType === 3) {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].sendDate), 'yyyy-mm-dd h:M')} 单次`
|
||||
} else {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].startDate), 'yyyy-mm-dd h:M')} 永久`
|
||||
data.list[i].timeText = `循环`
|
||||
}
|
||||
}
|
||||
if(params.pageNo === 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user