Merge branch 'fanpeng' into 'master'
Fanpeng See merge request StarlockTeam/wx-starlock!5
This commit is contained in:
commit
12b99d0bc5
@ -6,7 +6,8 @@
|
||||
{{ timeFormat(time, 'yyyy-mm-dd h:M') }}
|
||||
</view>
|
||||
</view>
|
||||
<up-datetime-picker itemHeight="60" :minDate="minDate" :title="placeholder" :show="show" v-model="time"
|
||||
<up-datetime-picker :filter="filter" itemHeight="60" :minDate="minDate" :title="placeholder" :show="show"
|
||||
v-model="time"
|
||||
mode="datetime" @confirm="confirm" :closeOnClickOverlay="true"
|
||||
@close="close"></up-datetime-picker>
|
||||
</view>
|
||||
@ -21,7 +22,11 @@ export default {
|
||||
title: String,
|
||||
value: Number,
|
||||
minDate: Number,
|
||||
placeholder: String
|
||||
placeholder: String,
|
||||
type: {
|
||||
type: String,
|
||||
default: 'datetime'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -34,6 +39,13 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
filter(mode, options) {
|
||||
if (mode === 'minute' && this.type === 'datehour') {
|
||||
return options.filter((option) => option === '00')
|
||||
}
|
||||
|
||||
return options
|
||||
},
|
||||
changeShow() {
|
||||
this.show = !this.show
|
||||
},
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<LockInput :value="temporaryName" title="名称" placeholder="给密码命名"
|
||||
@changeInput="changeTemporaryInput"></LockInput>
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockDatetimePicker title="失效时间" :value="temporaryTime" :minDate="minDate"
|
||||
<LockDatetimePicker title="失效时间" :value="temporaryTime" :minDate="minDate" type="datehour"
|
||||
placeholder="请选择失效时间" @changeTime="changeTemporaryTime"></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="text">{{ text }}</view>
|
||||
|
||||
@ -17,43 +17,51 @@
|
||||
<view class="text">填加锁时,手机必须在锁旁边</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="group" v-for="group in lockList" :key="group.groupId">
|
||||
<view class="group" v-for="(group, grounIndex) in lockList" :key="group.groupId">
|
||||
<view class="group-name">
|
||||
<view class="group-name-text">{{group.groupName}}</view>
|
||||
<view class="group-name-line"></view>
|
||||
</view>
|
||||
<view class="lock" v-for="lock in group.lockList" :key="lock.lockId" @click="toLockDeatil(lock)">
|
||||
<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>
|
||||
<up-swipe-action class="lock">
|
||||
<up-swipe-action-item class="lock" :ref="'swipeItem' + grounIndex" :options="options" v-for="(lock,
|
||||
lockIndex)
|
||||
in
|
||||
group.lockList"
|
||||
:key="lock.lockId" :threshold="50" @click="deleteLock(lock, grounIndex, lockIndex)">
|
||||
<view class="lock" @click="toLockDeatil(lock)">
|
||||
<view class="lock-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="getPowerIcon(lock.electricQuantity)"></image>
|
||||
<view class="lock-top-right-power-text">{{ lock.electricQuantity }}%</view>
|
||||
</view>
|
||||
<view>{{getRole(lock.userType, lock.keyRight)}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>{{getRole(lock.userType, lock.keyRight)}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="lock-name">{{lock.lockAlias}}</view>
|
||||
<view style="display: flex;align-items: center">
|
||||
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
|
||||
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">余{{lock.days}}天</view>
|
||||
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view>
|
||||
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
|
||||
<view v-if="lock.lockSetting.remoteUnlock === 1" class="lock-status" style="background-color:
|
||||
<view class="lock-name">{{lock.lockAlias}}</view>
|
||||
<view style="display: flex;align-items: center">
|
||||
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
|
||||
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">余{{lock.days}}天</view>
|
||||
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view>
|
||||
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
|
||||
<view v-if="lock.lockSetting.remoteUnlock === 1" class="lock-status" style="background-color:
|
||||
#63b8af">远程开锁
|
||||
</view>
|
||||
</view>
|
||||
<view class="lock-time"
|
||||
:style="{padding: lock.keyStatus === 110401 && !lock.days ? '12rpx 24rpx 0 24rpx'
|
||||
</view>
|
||||
</view>
|
||||
<view class="lock-time"
|
||||
:style="{padding: lock.keyStatus === 110401 && !lock.days ? '12rpx 24rpx 0 24rpx'
|
||||
:'6rpx 24rpx 0 24rpx'}">
|
||||
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
|
||||
getTimeLimit(lock.keyType) }}</view>
|
||||
<view v-else>
|
||||
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + 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>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-swipe-action-item>
|
||||
</up-swipe-action>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -69,6 +77,15 @@
|
||||
</view>
|
||||
</view>
|
||||
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button>
|
||||
<up-modal :show="showModal" title="是否删除授权管理员钥匙?" :showCancelButton="true" width="600rpx" @cancel="cancelModal"
|
||||
@confirm="confirmModal">
|
||||
<view class="slot-content" @click="changeRadio">
|
||||
<view style="display: flex;align-items: center;">
|
||||
<radio :checked="checked"></radio>
|
||||
<view>同时删除其发送的所有钥匙,钥匙删除后不能恢复</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -80,6 +97,8 @@
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { mapState, mapActions } from 'pinia'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
import { deleteLockRequest } from '@/api/lock'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -87,13 +106,22 @@
|
||||
refresherTriggered: false,
|
||||
focus: false,
|
||||
penging: true,
|
||||
deviceInfo: null
|
||||
deviceInfo: null,
|
||||
options: [{
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: '#f56c6c'
|
||||
}
|
||||
}],
|
||||
showModal: false,
|
||||
checked: false,
|
||||
deleteLockInfo: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useUserStore, ['userInfo', 'isLogin']),
|
||||
...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']),
|
||||
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']),
|
||||
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth', 'keyId', 'currentLockInfo']),
|
||||
},
|
||||
async onLoad() {
|
||||
uni.showLoading({
|
||||
@ -119,10 +147,133 @@
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']),
|
||||
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']),
|
||||
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch', 'getPowerIcon']),
|
||||
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo',
|
||||
'checkSetting', 'updateKeyId']),
|
||||
'checkSetting', 'updateKeyId', 'resetDevice']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
|
||||
async deleteLock(lock, groupIndex, lockIndex) {
|
||||
const that = this
|
||||
|
||||
that.$refs['swipeItem' + groupIndex][lockIndex].closeHandler()
|
||||
if(lock.userType !== 110301 && lock.keyRight === 1) {
|
||||
this.deleteLockInfo = lock
|
||||
this.showModal = true
|
||||
return
|
||||
}
|
||||
const message = lock.userType === 110301 ? '删除锁后,所有信息都会一起删除,确定删除锁吗?' : '确定删除该钥匙吗?'
|
||||
const data = {
|
||||
...lock,
|
||||
name: lock.bluetooth.bluetoothDeviceName,
|
||||
deviceId: lock.bluetooth.bluetoothDeviceId,
|
||||
commKey: lock.bluetooth.privateKey,
|
||||
signKey: lock.bluetooth.signKey,
|
||||
publicKey: lock.bluetooth.publicKey,
|
||||
}
|
||||
this.updateKeyId(lock.keyId.toString())
|
||||
this.updateCurrentLockInfo(data)
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: message,
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
if(that.currentLockInfo.userType === 110301) {
|
||||
const { code: resetDeviceCode } = await that.resetDevice({
|
||||
name: that.currentLockInfo.name,
|
||||
authUid: that.userInfo.uid.toString(),
|
||||
keyId: that.keyId.toString()
|
||||
})
|
||||
if(resetDeviceCode === 0) {
|
||||
const { code, message } = await deleteLockRequest({
|
||||
lockId: that.currentLockInfo.lockId
|
||||
})
|
||||
if(code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if(code === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
}
|
||||
} else {
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: that.keyId
|
||||
})
|
||||
if(code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async confirmModal() {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const that = this
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: that.deleteLockInfo.keyId,
|
||||
includeUnderlings: that.checked ? 1 : 0
|
||||
})
|
||||
that.showModal = false
|
||||
if(code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
homeLogin() {
|
||||
const that = this
|
||||
return new Promise((resolve) => {
|
||||
@ -162,6 +313,13 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
changeRadio() {
|
||||
this.checked = !this.checked
|
||||
},
|
||||
cancelModal() {
|
||||
this.showModal = false
|
||||
this.checked = false
|
||||
},
|
||||
async getphonenumber(data) {
|
||||
if(data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||
return
|
||||
@ -281,6 +439,30 @@
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
|
||||
.u-swipe-action {
|
||||
overflow: inherit !important;
|
||||
}
|
||||
|
||||
.u-swipe-action-item {
|
||||
margin-top: 32rpx;
|
||||
overflow: inherit !important;
|
||||
border-radius: 32rpx !important;
|
||||
width: 320rpx;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
.u-swipe-action-item__right {
|
||||
border-radius: 32rpx !important;
|
||||
}
|
||||
|
||||
.u-swipe-action-item__content {
|
||||
border-radius: 32rpx !important;
|
||||
}
|
||||
|
||||
.u-swipe-action-item__right__button {
|
||||
border-radius: 32rpx !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@ -321,7 +503,6 @@ page {
|
||||
justify-content: space-between;
|
||||
|
||||
.lock {
|
||||
margin-top: 32rpx;
|
||||
width: 320rpx;
|
||||
height: 300rpx;
|
||||
background: #FFFFFF;
|
||||
@ -367,7 +548,7 @@ page {
|
||||
|
||||
.lock-top-right-power-image {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<image class="top-background" src="/static/images/background_main.jpg" mode="aspectFill"></image>
|
||||
<view style="width: 100%;height: 50rpx">
|
||||
<view class="power" @click="powerTip">
|
||||
<image class="power-icon" src="/static/images/icon_power.png" mode="aspectFill"></image>
|
||||
<image class="power-icon" :src="getPowerIcon(currentLockInfo.electricQuantity)" mode="aspectFill"></image>
|
||||
<view class="power-text">{{ currentLockInfo.electricQuantity }}%</view>
|
||||
<image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
@ -85,7 +85,7 @@ export default {
|
||||
this.getServeTime()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList']),
|
||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
|
||||
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast']),
|
||||
powerTip() {
|
||||
@ -246,7 +246,7 @@ export default {
|
||||
.power-icon {
|
||||
width: 50rpx;
|
||||
margin-right: 10rpx;
|
||||
height: 50rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
|
||||
.power-text {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
BIN
static/images/icon_power_1.png
Executable file
BIN
static/images/icon_power_1.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 859 B |
BIN
static/images/icon_power_2.png
Executable file
BIN
static/images/icon_power_2.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 907 B |
BIN
static/images/icon_power_3.png
Executable file
BIN
static/images/icon_power_3.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 940 B |
BIN
static/images/icon_power_4.png
Executable file
BIN
static/images/icon_power_4.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 930 B |
BIN
static/images/icon_power_5.png
Executable file
BIN
static/images/icon_power_5.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 826 B |
@ -51,6 +51,21 @@ export const useLockStore = defineStore('lock', {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 获取电量icon
|
||||
getPowerIcon(power) {
|
||||
if(power >= 80) {
|
||||
return '/static/images/icon_power_5.png'
|
||||
} else if(power >= 60) {
|
||||
return '/static/images/icon_power_4.png'
|
||||
} else if(power >= 40) {
|
||||
return '/static/images/icon_power_3.png'
|
||||
} else if(power >= 20) {
|
||||
return '/static/images/icon_power_2.png'
|
||||
} else {
|
||||
return '/static/images/icon_power_1.png'
|
||||
}
|
||||
},
|
||||
// 将星期转换为中文字符串
|
||||
convertWeekDaysToChineseString(weekDays) {
|
||||
const dayMap = {
|
||||
1: '一',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user