powerbank/pages/agentpages/devicemanagement/chargepallist/listdetail/index.vue

400 lines
9.9 KiB
Vue
Raw Normal View History

2024-05-11 10:57:53 +08:00
<template>
<view class="page">
<u-navbar title="设备详情" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
2024-05-25 18:06:00 +08:00
height='58'></u-navbar>
2024-05-11 10:57:53 +08:00
<view class="box">
<view class="boxtop">
<view class="bh">
2024-05-30 18:02:15 +08:00
{{xqobj.sn}} <u-icon name="file-text" size="34" @click="copybtn(xqobj.sn)"></u-icon>
2024-05-11 10:57:53 +08:00
</view>
<view class="cdbbuttom">
<view class="one">
2024-05-30 18:02:15 +08:00
<text>网络状态</text><text>设备状态</text><text>可租</text><text>电池</text><text>可还</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="two">
2024-05-30 18:02:15 +08:00
<text style="color: #1DBE7B;" v-if="xqobj.onlineStatus == 1">在线</text>
<text style="color: red;" v-if="xqobj.onlineStatus == 0">离线</text>
<text style="color: #1DBE7B;" v-if="xqobj.status == 1">正常</text>
<text style="color: red;" v-if="xqobj.status == 2">异常</text>
<text>{{xqobj.currentPowerBankNum}}</text><text>{{xqobj.currentPowerBankNum}}</text><text>{{xqobj.slotNum - xqobj.currentPowerBankNum}}</text>
2024-05-11 10:57:53 +08:00
</view>
</view>
<view class="yuny">
2024-05-30 18:02:15 +08:00
<text>已运营{{differenceInDays}}</text> <text>{{xqobj.createTime}}</text>
2024-05-11 10:57:53 +08:00
</view>
</view>
<view class="boxbd">
<view class="butt">
2024-05-30 18:02:15 +08:00
<text>刷新</text> <text>重启设备</text><text
@click="btntcsy">弹出所有</text><text>卡位({{xqobj.modelName}})</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="cbdxq">
2024-05-31 18:01:02 +08:00
<view style="color: #3D3D3D;" v-for="(item,index) in list" :key="index" @click="btntc(item.deviceId)">
2024-05-30 18:02:15 +08:00
{{item.sn == null ? '空闲' : item.sn + '/'}}{{item.currentPower == null ? '' : item.currentPower + '%'}}
</view>
2024-05-11 10:57:53 +08:00
</view>
<view class="tishi">
<view class="">
提示单点可强制弹出
</view>
<view class="" style="margin-top: 5rpx;">
长按卡位可以锁定卡位锁定的卡位将不会被租借
</view>
</view>
<view class="sjxx">
<view class="tit">
商家信息
</view>
<view class="dpxx">
2024-05-30 18:02:15 +08:00
<text>店铺名称</text> <text style="color: #1DBE7B;">{{xqobj.storeName}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="dpdz">
2024-05-30 18:02:15 +08:00
<text style="width: 240rpx;">店铺地址</text> <text>{{xqobj.storeAddress}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="dxxx">
断线信息
</view>
<view class="zjdx">
2024-05-30 18:02:15 +08:00
<text>最近断线时间</text> <text>{{xqobj.lastOfflineTime}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="zjdx">
2024-05-30 18:02:15 +08:00
<text>最近登录时间</text> <text>{{xqobj.lastLoginTime}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="zjdx">
2024-05-31 18:01:02 +08:00
<text>最近断线时长</text> <text>{{duration.days + '天' + duration.hours + '时' + duration.minutes + '分' + duration.seconds + '秒'}}</text>
2024-05-11 10:57:53 +08:00
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
2024-05-30 18:02:15 +08:00
cabinetId: '',
xqobj: {},
differenceInDays: '',
list: [],
bgc: {
background: '#25CE88'
},
2024-05-31 18:01:02 +08:00
duration:''
2024-05-11 10:57:53 +08:00
}
},
2024-05-30 18:02:15 +08:00
onLoad(option) {
this.cabinetId = option.cabinetId
this.getxq()
},
2024-05-11 10:57:53 +08:00
methods: {
2024-05-30 18:02:15 +08:00
btntcsy() {
if(Array.isArray(this.list)){
let deviceIds = ''
this.list.forEach((item, index) => {
if (item.deviceId) {
if (deviceIds !== '') {
deviceIds += ','
}
deviceIds += item.deviceId
}
})
this.$u.put(`/agent/device/${deviceIds}/pop`).then(res => {
if (res.code == 200) {
uni.showToast({
title: '已弹出所有设备',
icon: 'success',
duration: 2000
})
this.getxq()
}
})
}else{
uni.showToast({
title: '所有设备均已弹出',
icon: 'none',
duration: 2000
})
}
},
btntc(deviceId) {
if (deviceId) {
this.$u.put(`/agent/device/${deviceId}/pop`).then(res => {
if (res.code == 200) {
uni.showToast({
title: '已弹出该设备',
icon: 'success',
duration: 2000
})
this.getxq()
}
})
} else {
uni.showToast({
title: '该空位无设备',
icon: 'none',
duration: 2000
});
}
},
getxq() {
this.$u.get(`/agent/cabinet/${this.cabinetId}`).then(res => {
if (res.code == 200) {
this.xqobj = res.data
this.list = res.data.currentDeviceList
if (this.list) {
let allSlots = Array.from({
length: this.xqobj.slotNum
}, (_, i) => i + 1);
let missingSlots = [];
this.list.forEach(item => {
let index = allSlots.indexOf(item.currentSlot);
if (index !== -1) {
allSlots.splice(index, 1);
}
})
missingSlots = allSlots;
missingSlots.forEach(slot => {
this.list.push({
currentSlot: slot
})
this.list.sort((a, b) => b.currentSlot - a.currentSlot)
})
} else {
this.list = this.xqobj.slotNum
}
let dateTime = new Date(this.xqobj.createTime);
if (isNaN(dateTime.getTime())) {
console.error(`无法解析日期时间字符串: ${this.xqobj.createTime}`);
return;
}
let now = new Date().getTime();
let differenceInMilliseconds = now - dateTime.getTime();
this.differenceInDays = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24))
2024-05-31 18:01:02 +08:00
// 计算断线时长
let lastLoginTimeStr = this.xqobj.lastLoginTime
let lastOfflineTimeStr = this.xqobj.lastOfflineTime
let nows = new Date()
let lastLoginTime = this.parseDateString(lastLoginTimeStr)
let lastOfflineTime = this.parseDateString(lastOfflineTimeStr)
if (lastLoginTime && lastLoginTime > lastOfflineTime) {
let diff = lastLoginTime - lastOfflineTime
this.duration = this.formatDuration(diff)
// console.log(` ${duration.days} '天', ${duration.hours} '小时', ${duration.minutes} '分钟'`)
} else {
let diff = nows - lastOfflineTime
this.duration = this.formatDuration(diff)
// console.log(` ${duration.days} 天, ${duration.hours} 小时, ${duration.minutes} 分钟`)
}
2024-05-30 18:02:15 +08:00
}
})
},
2024-05-31 18:01:02 +08:00
parseDateString(dateStr) {
return dateStr ? new Date(dateStr) : null
},
formatDuration(durationMs) {
let duration = new Date(durationMs)
let days = Math.floor(durationMs / (1000 * 60 * 60 * 24))
durationMs -= days * (1000 * 60 * 60 * 24)
let hours = Math.floor((durationMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
durationMs -= hours * (1000 * 60 * 60)
let minutes = Math.floor((durationMs % (1000 * 60 * 60)) / (1000 * 60))
let seconds = Math.floor((durationMs % (1000 * 60)) / 1000)
return { days, hours, minutes,seconds}
},
2024-05-30 18:02:15 +08:00
copybtn(text) {
uni.setClipboardData({
data: text,
success: function(res) {
uni.showToast({
title: '复制成功',
});
}
});
},
2024-05-11 10:57:53 +08:00
}
}
</script>
<style lang="scss">
2024-05-25 18:06:00 +08:00
/deep/ .u-title,
/deep/ .uicon-nav-back {
padding-bottom: 40rpx;
}
2024-05-30 18:02:15 +08:00
2024-05-11 10:57:53 +08:00
page {
2024-05-30 18:02:15 +08:00
// background: linear-gradient(180deg, #25CE88 0%, rgba(255, 255, 255, 0) 100%);
2024-05-11 10:57:53 +08:00
}
.page {
width: 750rpx;
2024-05-30 18:02:15 +08:00
// position: fixed;
// top: 0;
// left: 0;
2024-05-11 10:57:53 +08:00
.box {
width: 750rpx;
height: 1440rpx;
background: #F4F5F7;
border-radius: 0rpx 0rpx 0rpx 0rpx;
padding-top: 22rpx;
.boxbd {
width: 750rpx;
2024-05-30 18:02:15 +08:00
height: 100%;
2024-05-11 10:57:53 +08:00
background: #FFFFFF;
padding: 30rpx 42rpx;
box-sizing: border-box;
margin-top: 32rpx;
2024-05-30 18:02:15 +08:00
.tishi {
2024-05-11 10:57:53 +08:00
text-align: center;
margin-top: 24rpx;
font-weight: 500;
font-size: 24rpx;
color: #FF4444;
}
2024-05-30 18:02:15 +08:00
.sjxx {
2024-05-11 10:57:53 +08:00
margin-top: 54rpx;
2024-05-30 18:02:15 +08:00
.tit {
font-weight: 600;
2024-05-11 10:57:53 +08:00
font-size: 28rpx;
color: #3D3D3D;
}
2024-05-30 18:02:15 +08:00
.dpxx {
2024-05-11 10:57:53 +08:00
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #808080;
margin-top: 24rpx;
}
2024-05-30 18:02:15 +08:00
.dpdz {
2024-05-11 10:57:53 +08:00
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #808080;
margin-top: 24rpx;
}
2024-05-30 18:02:15 +08:00
.dxxx {
font-weight: 600;
2024-05-11 10:57:53 +08:00
font-size: 28rpx;
color: #3D3D3D;
margin-top: 24rpx;
}
2024-05-30 18:02:15 +08:00
.zjdx {
2024-05-11 10:57:53 +08:00
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #808080;
margin-top: 24rpx;
}
}
2024-05-30 18:02:15 +08:00
2024-05-11 10:57:53 +08:00
.cbdxq {
width: 680rpx;
2024-05-30 18:02:15 +08:00
// height: 344rpx;
2024-05-11 10:57:53 +08:00
background: #F2F3F5;
border-radius: 24rpx 24rpx 24rpx 24rpx;
margin: auto;
margin-top: 52rpx;
2024-05-30 18:02:15 +08:00
padding: 20rpx 12rpx;
2024-05-11 10:57:53 +08:00
box-sizing: border-box;
2024-05-30 18:02:15 +08:00
2024-05-11 10:57:53 +08:00
view {
display: inline-block;
width: 314rpx;
background: #FFFFFF;
border-radius: 27rpx 27rpx 27rpx 27rpx;
font-weight: 500;
font-size: 20rpx;
color: #3D3D3D;
text-align: center;
line-height: 53rpx;
margin-top: 16rpx;
margin-right: 10rpx;
}
}
.butt {
display: flex;
justify-content: space-between;
text {
text-align: center;
width: 158rpx;
height: 68rpx;
line-height: 68rpx;
background: #1DBE7B;
border-radius: 10rpx 10rpx 10rpx 10rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
}
}
}
.boxtop {
padding: 30rpx;
box-sizing: border-box;
width: 680rpx;
height: 268rpx;
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
margin: auto;
.bh {
font-size: 24rpx;
color: #3D3D3D;
border-bottom: 1px solid #ccc;
padding-bottom: 14rpx;
}
.cdbbuttom {
margin-top: 20rpx;
font-size: 24rpx;
color: #3D3D3D;
border-bottom: 1px solid #ccc;
padding-bottom: 24rpx;
text {
width: 100rpx;
text-align: center;
}
.one {
display: flex;
justify-content: space-between;
}
.two {
display: flex;
justify-content: space-between;
margin-top: 16rpx;
}
}
.yuny {
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: #3D3D3D;
margin-top: 16rpx;
}
}
}
}
</style>