This commit is contained in:
Double-_-Z 2025-08-07 20:37:50 +08:00
parent ebdd3c68f7
commit d5342f5fed
6 changed files with 182 additions and 213 deletions

View File

@ -1,217 +1,185 @@
<template>
<view class="aircraft-equipment">
<!-- 顶部区域 -->
<Topnav :topLevel="topLevel" title="爱尚云" />
<view class="header">
<view class="header-content">
<u-image width="100%" :src="fileUrl + banner" mode="widthFix" />
<view class="top-abs">
<view class="title">我的设备</view>
</view>
</view>
</view>
<!-- 设备列表区域 -->
<scroll-view scroll-y class="device-list">
<view
class="device-item"
v-for="(item, index) in deviceList"
:key="index"
>
<u-image
class="device-image"
:src="item.image"
mode="widthFix"
></u-image>
<view class="device-info">
<text class="device-name">{{ item.name }}</text>
<text class="device-model">{{ item.model }}</text>
</view>
<button class="detail-btn" @click="goToDetail(item.id)">
查看详情
</button>
</view>
</scroll-view>
<u-toast ref="uToast"></u-toast>
</view>
<view class="aircraft-equipment" :style="{backgroundImage: `url(${fileUrl+banner})`}">
<view class="equipment-content">
<view class="top-abs" :style="{marginTop: CustomBar+'px'}">
我的设备
</view>
<view class="device-item" v-for="(item, index) in deviceList" :key="index">
<u-image class="device-image" :src="item.image||(ordFileUrl+defaultIcon)"
mode="widthFix" @click="preview(item.image||(ordFileUrl+defaultIcon))" />
<view class="device-info">
<text class="device-name">{{ item.name }}</text>
<text class="device-model">{{ item.model }}</text>
</view>
<button class="detail-btn" @click="goToDetail(item.id)">
查看详情
</button>
</view>
<u-loadmore v-if="deviceList.length>0" @loadmore="getMore" :status="form.isFinish" color="#333333" marginTop="30" marginBottom="20" />
<view class="device-empty" :style="{marginTop: CustomBar+100+'px'}" v-else>
<u-empty text="暂无设备" mode="list"
src="/static/empty.png" icon-size="300" font-size="40"
margin-top="250"></u-empty>
</view>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import { tools } from "@/utils/utils.js";
import Topnav from "@/components/topnav/index.vue";
export default {
// #ifdef MP
options: {
styleIsolation: "shared"
},
// #endif
components: { Topnav },
props: {
topLevel: {
type: Number,
default: 0
},
},
data() {
return {
fileUrl: "/static/", //
banner: "devicebg.png",
deviceList: [],
};
},
mounted() {
this.init();
},
methods: {
//
async init() {
//
const devicesRes = await this.$api.getDevices();
if (!devicesRes) {
this.$refs.uToast.show({
type: 'error',
title: '设备列表获取失败!'
});
return;
}
//
const deviceList = [];
for (const device of devicesRes.records) {
try {
const detailRes = await this.$api.getDevicesDetail(device.id);
if (detailRes) {
// 使
const image = detailRes.deviceImages && detailRes.deviceImages.length > 0
? detailRes.deviceImages[0].fileFullPath
: '/static/drone.png';
deviceList.push({
id: device.id,
name: device.name,
model: device.model,
image: image
});
}
} catch(err) {
console.error('获取设备详情失败:', err);
// 使
deviceList.push({
id: device.id,
name: device.name,
model: device.model,
image: '/static/drone.png'
});
}
}
this.deviceList = deviceList;
},
//
goToDetail(id) {
uni.navigateTo({
url: `/aircraft/server/equipment/equipmentDetail?id=${id}`,
});
},
},
};
import configService from '@/common/config.service.js';
export default {
// #ifdef MP
options: {
styleIsolation: "shared"
},
// #endif
data() {
return {
// #ifdef MP
//
StatusBar: this.StatusBar || 0,
CustomBar: this.CustomBar || 0,
// #endif
fileUrl: configService.fileUrl + 'aerocraft/equipment/', //
ordFileUrl: configService.fileUrl + 'aerocraft/order/',
//
defaultIcon: 'default.png',
banner: "devicebg.png",
deviceList: [],
//
form:{
current: 1,
size: 10,
// loadmoreloadingnomore
isFinish: 'nomore',
},
};
},
methods: {
//
async init() {
this.form = {size: 10,current: 1,isFinish: 'nomore'};
await this.getDeviceList();
},
async getDeviceList(){
this.form.isFinish = 'loading';
let deviceRes = await this.$api.getDevices(this.form);
if(deviceRes){
const { records, size, total, current } = deviceRes;
if(current == 1) this.deviceList = records || [];
else this.deviceList.push(...records);
this.form.isFinish = size*current >= total ? 'nomore' : 'loadmore';
}else{
this.$refs.uToast.show({type:'error',title: "设备列表获取失败!"});
this.form.isFinish = 'loadmore';
}
},
//
getMore(){
if(this.form.isFinish === 'nomore') return;
this.form.current++;
this.getDeviceList();
},
//
preview(url){
console.log(url);
this.$util.tools.methods.lookImage(0,[url]);
},
//
goToDetail(id) {
uni.navigateTo({
url: `/aircraft/server/equipment/equipmentDetail?id=${id}`,
});
},
},
};
</script>
<style scoped lang="scss">
.aircraft-equipment {
min-height: 100vh;
background-color: #f5f5f5;
height: 100%;
background-color: #f5f5f5;
display: flex;
flex-direction: column;
background-size: contain;
background-repeat: no-repeat;
padding-bottom: 30rpx;
.header {
background: linear-gradient(180deg, #fff7e6 0%, #fff9ed 100%);
position: relative;
width: 100%;
height: 261rpx;
.equipment-content {
width: 100%;
position: relative;
padding: 0 24rpx 0;
.header-content {
position: relative;
height: 100%;
.top-abs {
// position: absolute;
display: flex;
align-items: center;
font-family: Source Han Sans SC;
font-weight: 800;
font-size: 44rpx;
color: #333333;
margin-bottom: 40rpx;
}
.top-abs {
position: absolute;
top: 72px;
.device-item {
margin-top: 26rpx;
background: #ffffff;
border-radius: 16rpx;
display: flex;
align-items: center;
padding: 30rpx;
.title {
margin-left: 34rpx;
font-family: Source Han Sans SC;
font-weight: 800;
font-size: 50rpx;
color: #333333;
}
}
.device-image {
width: 142rpx;
height: 142rpx;
background: #f3f3f3;
border-radius: 12rpx;
border: 2rpx solid #cccccc;
}
.header-image {
position: absolute;
right: 0;
bottom: 0;
}
}
}
.device-info {
flex: 1;
margin-left: 24rpx;
margin-bottom: 32rpx;
.device-list {
padding: 24rpx;
padding-top: 0;
height: calc(100vh - 160px);
box-sizing: border-box;
.device-name {
font-family: Source Han Sans SC;
font-weight: bold;
font-size: 36rpx;
color: #333333;
display: block;
margin-bottom: 16rpx;
}
.device-item {
height: 200rpx;
background: #ffffff;
border-radius: 16rpx;
margin-bottom: 26rpx;
padding: 30rpx;
display: flex;
align-items: center;
.device-model {
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 32rpx;
color: #666666;
display: block;
}
.device-image {
width: 142rpx;
height: 142rpx;
background: #f3f3f3;
border-radius: 12rpx;
border: 2rpx solid #cccccc;
}
}
.detail-btn {
border: none;
background: #fee547;
border-radius: 12rpx;
font-family: Source Han Sans SC;
font-weight: bold;
font-size: 30rpx;
color: #333333;
}
}
.device-info {
flex: 1;
margin-left: 24rpx;
margin-bottom: 32rpx;
.device-name {
font-family: Source Han Sans SC;
font-weight: bold;
font-size: 36rpx;
color: #333333;
display: block;
margin-bottom: 16rpx;
}
.device-model {
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 32rpx;
color: #666666;
display: block;
}
}
.detail-btn {
border: none;
background: #fee547;
border-radius: 12rpx;
font-family: Source Han Sans SC;
font-weight: bold;
font-size: 30rpx;
color: #333333;
}
}
}
.device-empty{
width: 100%;
&::v-deep .u-icon__label{
margin-top: 24rpx !important;
font-weight: 500;
font-family: Source Han Sans SC;
}
}
}
}
</style>

View File

@ -1,9 +1,9 @@
<template>
<view class="equipment-detail">
<!-- 顶部导航区 -->
<Topnav :topLevel="topLevel" title="设备详情" defaultBackColor="#333333"
defaultNavTextColor="#333333" showBack />
<Topnav :topLevel="topLevel" title="设备详情" defaultBackColor="#333333"
defaultNavTextColor="#333333" showBack />
<view :style="{height: CustomBar + 'px'}" />
<!-- 主要内容区域 -->
<view class="detail-container">
<!-- 设备图片展示区 -->
@ -88,7 +88,7 @@
<view class="action-title">新增记录</view>
<u-icon
class="action-close"
:name="fileUrl + closeIcon"
:name="ordFileUrl + closeIcon"
size="32"
@click="showRecordPopup = false"
/>
@ -159,7 +159,7 @@ export default {
// #endif
deviceId: '',
equipmentImages: [{
image: "/static/drone.png",
image: this.fileUrl + "drone.png",
title: "默认图片"
}],
currentImageIndex: 0,
@ -170,8 +170,9 @@ export default {
//
equipmentDetail: {},
maintenanceRecords: [],
fileUrl: configService.fileUrl + 'aerocraft/equipment/', //
//
fileUrl: configService.fileUrl + "aerocraft/order/",
ordFileUrl: configService.fileUrl + "aerocraft/order/",
//
triangle: "triangle.png",
//
@ -382,7 +383,7 @@ export default {
.equipment-images {
width: 100%;
overflow: hidden;
padding-top:144rpx;
// padding-top:144rpx;
background-color: #ebebf0;
// margin-bottom: 20rpx;
}

View File

@ -74,7 +74,7 @@ export default {
name: '路线',
icon: 'route.png',
select: 'route-select.png',
navTitle: '路线'
navTitle: '爱尚云'
},
{
name: '我的',

View File

@ -38,7 +38,7 @@ const install = (Vue, vm) => {
// 设备管理
vm.$api.obtainDeviceList = async (params = {}) => await vm.$u.get('/api/dataDropdown/obtainDeviceList',params);// 获取设备下拉列表
vm.$api.getDevices = async (params = {}) => await vm.$u.get('/aircraft/device/page',params);// 获取设备列表
vm.$api.getDevicesDetail = async (id) => await vm.$u.get(`/aircraft/device/${id}`);// 获取设备详情
vm.$api.getDevicesDetail = async (id) => await vm.$u.get(`/aircraft/device/${id}`);// 获取设备详情
vm.$api.getMaintenanceRecords = async (params = {}) => await vm.$u.get('/aircraft/maintenance/page',params);// 获取设备维保记录
vm.$api.addMaintenanceRecord = async (params = {}) => await vm.$u.post('/aircraft/maintenance',params);// 新增设备维保记录

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB