小程序首页添加左滑删除
This commit is contained in:
parent
ad1d857bf2
commit
b3c8116007
@ -22,38 +22,43 @@
|
|||||||
<view class="group-name-text">{{group.groupName}}</view>
|
<view class="group-name-text">{{group.groupName}}</view>
|
||||||
<view class="group-name-line"></view>
|
<view class="group-name-line"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="lock" v-for="lock in group.lockList" :key="lock.lockId" @click="toLockDeatil(lock)">
|
<up-swipe-action class="lock">
|
||||||
<view class="lock-top">
|
<up-swipe-action-item class="lock" ref="swipeItem" :options="options" v-for="lock in group.lockList"
|
||||||
<image class="lock-image-lock" src="/static/images/icon_lock.png"></image>
|
:key="lock.lockId" :threshold="50" @click="deleteLock(lock)">
|
||||||
<view class="lock-top-right">
|
<view class="lock" @click="toLockDeatil(lock)">
|
||||||
<view class="lock-top-right-power">
|
<view class="lock-top">
|
||||||
<image class="lock-top-right-power-image" src="/static/images/icon_power.png"></image>
|
<image class="lock-image-lock" src="/static/images/icon_lock.png"></image>
|
||||||
<view class="lock-top-right-power-text">{{lock.electricQuantity}}%</view>
|
<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, lock.keyRight)}}</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view>{{getRole(lock.userType, lock.keyRight)}}</view>
|
<view class="lock-name">{{lock.lockAlias}}</view>
|
||||||
</view>
|
<view style="display: flex;align-items: center">
|
||||||
</view>
|
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
|
||||||
<view class="lock-name">{{lock.lockAlias}}</view>
|
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">余{{lock.days}}天</view>
|
||||||
<view style="display: flex;align-items: center">
|
<view v-if="lock.keyStatus === 110403" class="lock-status" style="background-color: #63b8af">未生效</view>
|
||||||
<view v-if="lock.keyStatus === 110412" class="lock-status">已过期</view>
|
<view v-if="lock.keyStatus === 110405" class="lock-status">已冻结</view>
|
||||||
<view v-if="lock.days" class="lock-status" style="background-color: #63b8af">余{{lock.days}}天</view>
|
<view v-if="lock.lockSetting.remoteUnlock === 1" class="lock-status" style="background-color:
|
||||||
<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">远程开锁
|
#63b8af">远程开锁
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="lock-time"
|
<view class="lock-time"
|
||||||
:style="{padding: lock.keyStatus === 110401 && !lock.days ? '12rpx 24rpx 0 24rpx'
|
:style="{padding: lock.keyStatus === 110401 && !lock.days ? '12rpx 24rpx 0 24rpx'
|
||||||
:'6rpx 24rpx 0 24rpx'}">
|
:'6rpx 24rpx 0 24rpx'}">
|
||||||
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
|
<view v-if="lock.keyType === 1 || lock.keyType === 3" style="font-size: 32rpx">{{
|
||||||
getTimeLimit(lock.keyType) }}</view>
|
getTimeLimit(lock.keyType) }}</view>
|
||||||
<view v-else>
|
<view v-else>
|
||||||
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
<view>{{ timeFormat(lock.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||||
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view>
|
<view>{{ timeFormat(lock.endDate, 'yyyy-mm-dd h:M ') + getTimeLimit(lock.keyType) }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</up-swipe-action-item>
|
||||||
</view>
|
</up-swipe-action>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -69,6 +74,15 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button open-type="getPhoneNumber" style="display:none" id="phone" @getphonenumber="getphonenumber"></button>
|
<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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -80,6 +94,8 @@
|
|||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
|
import { deleteKeyRequest } from '@/api/key'
|
||||||
|
import { deleteLockRequest } from '@/api/lock'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -87,13 +103,22 @@
|
|||||||
refresherTriggered: false,
|
refresherTriggered: false,
|
||||||
focus: false,
|
focus: false,
|
||||||
penging: true,
|
penging: true,
|
||||||
deviceInfo: null
|
deviceInfo: null,
|
||||||
|
options: [{
|
||||||
|
text: '删除',
|
||||||
|
style: {
|
||||||
|
backgroundColor: '#f56c6c'
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
showModal: false,
|
||||||
|
checked: false,
|
||||||
|
deleteLockInfo: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useUserStore, ['userInfo', 'isLogin']),
|
...mapState(useUserStore, ['userInfo', 'isLogin']),
|
||||||
...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']),
|
...mapState(useLockStore, ['lockList', 'lockTotal', 'lockSearch']),
|
||||||
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth']),
|
...mapState(useBluetoothStore, ['bluetoothStatus', 'isInitBluetooth', 'keyId', 'currentLockInfo']),
|
||||||
},
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
@ -121,8 +146,129 @@
|
|||||||
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']),
|
...mapActions(useUserStore, ['updateUserInfo', 'updateLoginStatus', 'phoneLogin', 'getUserInfo']),
|
||||||
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']),
|
...mapActions(useLockStore, ['getLockList', 'getRole', 'getTimeLimit', 'updateLockSearch']),
|
||||||
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo',
|
...mapActions(useBluetoothStore, ['getBluetoothStatus', 'initAndListenBluetooth', 'updateCurrentLockInfo',
|
||||||
'checkSetting', 'updateKeyId']),
|
'checkSetting', 'updateKeyId', 'resetDevice']),
|
||||||
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
|
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
|
||||||
|
async deleteLock(lock) {
|
||||||
|
const that = this
|
||||||
|
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() {
|
homeLogin() {
|
||||||
const that = this
|
const that = this
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -162,6 +308,13 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
changeRadio() {
|
||||||
|
this.checked = !this.checked
|
||||||
|
},
|
||||||
|
cancelModal() {
|
||||||
|
this.showModal = false
|
||||||
|
this.checked = false
|
||||||
|
},
|
||||||
async getphonenumber(data) {
|
async getphonenumber(data) {
|
||||||
if(data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
if(data.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||||
return
|
return
|
||||||
@ -281,6 +434,30 @@
|
|||||||
page {
|
page {
|
||||||
background-color: $uni-bg-color-grey;
|
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>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@ -321,7 +498,6 @@ page {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.lock {
|
.lock {
|
||||||
margin-top: 32rpx;
|
|
||||||
width: 320rpx;
|
width: 320rpx;
|
||||||
height: 300rpx;
|
height: 300rpx;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user