index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. <template>
  2. <view class="container">
  3. <!-- 搜索区域 -->
  4. <view class="search-section">
  5. <view class="search-box" :class="{ 'search-focus': isSearchFocused }">
  6. <view class="search-icon">
  7. <!-- <text class="iconfont icon-search"></text> -->
  8. <image src="@/static/icons/search.png" style="width: 40rpx; height: 40rpx; padding-right: 10rpx;"
  9. mode="widthFix" />
  10. </view>
  11. <input
  12. class="search-input"
  13. type="text"
  14. v-model="searchKey"
  15. placeholder="搜索设备名称 / 编号"
  16. confirm-type="search"
  17. @confirm="onSearch"
  18. @focus="isSearchFocused = true"
  19. @blur="isSearchFocused = false"
  20. />
  21. <view class="clear-icon" v-if="searchKey" @click="clearSearch">
  22. <text class="iconfont icon-close"></text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 状态筛选区域 -->
  27. <view class="filter-section">
  28. <view
  29. class="filter-item"
  30. :class="{ active: currentStatus === -1 }"
  31. @click="selectStatus(-1)"
  32. >
  33. 全部
  34. </view>
  35. <view
  36. class="filter-item"
  37. :class="{ active: currentStatus === 1 }"
  38. @click="selectStatus(1)"
  39. >
  40. <view class="filter-dot online-dot"></view>
  41. 在线 ({{ onlineDevices }})
  42. </view>
  43. <view
  44. class="filter-item"
  45. :class="{ active: currentStatus === 0 }"
  46. @click="selectStatus(0)"
  47. >
  48. <view class="filter-dot offline-dot"></view>
  49. 离线 ({{ offlineDevices }})
  50. </view>
  51. <!-- <view
  52. class="filter-item"
  53. :class="{ active: currentStatus === 2 }"
  54. @click="selectStatus(2)"
  55. >
  56. <view class="filter-dot fault-dot"></view>
  57. 故障 ({{ getStatusCount(2) }})
  58. </view> -->
  59. </view>
  60. <!-- 设备列表区域 -->
  61. <scroll-view
  62. scroll-y
  63. class="device-list"
  64. @scrolltolower="onReachBottom"
  65. :scroll-with-animation="true"
  66. :enable-back-to-top="true"
  67. :refresher-enabled="true"
  68. :refresher-threshold="80"
  69. :refresher-triggered="isRefreshing"
  70. @refresherrefresh="handleRefresh"
  71. @refresherrestore="isRefreshing = false"
  72. >
  73. <!-- 无数据提示 -->
  74. <view v-if="deviceList.length === 0 && !loading" class="empty-tips">
  75. <view class="empty-icon">
  76. <text class="iconfont icon-empty"></text>
  77. </view>
  78. <text class="empty-text">{{ searchKey ? '未找到匹配的设备' : '暂无设备' }}</text>
  79. <view v-if="searchKey" class="empty-action" @click="clearSearch">
  80. <text>清除搜索条件</text>
  81. </view>
  82. </view>
  83. <!-- 首次加载中状态 -->
  84. <view v-if="loading && deviceList.length === 0" class="loading-container">
  85. <view class="loading-spinner"></view>
  86. <text class="loading-text">加载中...</text>
  87. </view>
  88. <!-- 设备列表 -->
  89. <view
  90. v-for="(item, index) in deviceList"
  91. :key="index"
  92. class="device-card"
  93. :class="{
  94. 'has-alert': item.hasAlert,
  95. 'is-offline': item.status === 0
  96. }"
  97. hover-class="device-card-hover"
  98. hover-stay-time="70"
  99. @click="navigateToDeviceDetail(item)"
  100. >
  101. <!-- 设备基本信息 -->
  102. <view class="device-info">
  103. <view class="device-icon-wrapper">
  104. <!-- 告警标记 -->
  105. <view v-if="item.hasAlert" class="alarm-badge">
  106. 1
  107. </view>
  108. <view class="device-icon-container" :class="{'offline-icon': item.status === 0}">
  109. <image :src="getDeviceTypeIcon(item.deviceTypeId)" mode="aspectFit" class="device-icon"></image>
  110. </view>
  111. </view>
  112. <view class="device-meta">
  113. <view class="device-name-row">
  114. <text class="device-name" :class="{'offline-text': item.status === 0}">{{ item.deviceName }}</text>
  115. <view
  116. class="status-tag"
  117. :class="{
  118. 'status-online': item.status === 1,
  119. 'status-offline': item.status === 0,
  120. 'status-fault': item.status === 2,
  121. 'status-maintain': item.status === 3
  122. }"
  123. >
  124. <text class="status-dot" :class="{
  125. 'offline-dot': item.status === 0,
  126. 'fault-dot': item.status === 2,
  127. 'maintain-dot': item.status === 3
  128. }"></text>
  129. {{ getStatusText(item.status) }}
  130. </view>
  131. </view>
  132. <view class="device-id">
  133. <text class="id-label">设备编号:</text>
  134. <text class="id-value">{{ item.deviceId }}</text>
  135. </view>
  136. <view class="device-location">
  137. <text class="location-label">安装位置:</text>
  138. <text class="location-value">{{ item.fieldName || '未指定位置' }}</text>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 底部信息栏 -->
  143. <view class="device-footer">
  144. <text class="update-time">最后活跃: {{ formatDate(item.lastActiveTime) }}</text>
  145. </view>
  146. </view>
  147. <!-- 加载更多提示 -->
  148. <view v-if="deviceList.length > 0" class="load-more">
  149. <view class="load-more-content" v-if="loadMoreStatus === 'loading'">
  150. <view class="loading-icon"></view>
  151. <text>正在加载...</text>
  152. </view>
  153. <view class="load-more-content" v-if="loadMoreStatus === 'noMore'">
  154. <text>没有更多了</text>
  155. </view>
  156. <view class="load-more-content" v-if="loadMoreStatus === 'more'" @click="onReachBottom">
  157. <text>点击加载更多</text>
  158. </view>
  159. </view>
  160. </scroll-view>
  161. </view>
  162. </template>
  163. <script>
  164. import { fetchDevicesByType } from "@/api/services/device.js";
  165. import storage from "@/utils/storage.js";
  166. export default {
  167. data() {
  168. return {
  169. deviceType: '', // monitor, sensor, control, irrigation, tractor
  170. deviceTypeName: '',
  171. deviceList: [],
  172. searchKey: '',
  173. isSearchFocused: false,
  174. currentStatus: -1, // -1代表全部
  175. pageNum: 1,
  176. pageSize: 10,
  177. total: 0,
  178. loading: false,
  179. isRefreshing: false,
  180. loadMoreStatus: 'more', // 加载更多状态: more-加载更多 loading-加载中 noMore-没有更多了
  181. deviceTypeMap: {
  182. 'monitor': { name: '监控设备', icon: '/static/icons/camera.png', class: 'type-monitor' },
  183. 'sensor': { name: '采集设备', icon: '/static/icons/sensor.png', class: 'type-sensor' },
  184. 'control': { name: '控制设备', icon: '/static/icons/control.png', class: 'type-control' },
  185. 'irrigation': { name: '灌溉设备', icon: '/static/icons/water.png', class: 'type-irrigation' },
  186. 'tractor': { name: '农机设备', icon: '/static/icons/tractor.png', class: 'type-tractor' }
  187. },
  188. currentFieldId: null,
  189. onlineDevices:0,
  190. offlineDevices:0
  191. };
  192. },
  193. computed: {
  194. // 设备类型对应的样式类
  195. deviceTypeClass() {
  196. return this.deviceTypeMap[this.deviceType]?.class || '';
  197. }
  198. },
  199. onLoad(options) {
  200. // 获取传递的设备类型
  201. console.log("options类型:", options);
  202. const { type, typeOnline, typeOffline } = options;
  203. // 处理传递过来的统计数量
  204. this.offlineDevices = typeOffline
  205. this.onlineDevices = typeOnline
  206. if (type && this.deviceTypeMap[type]) {
  207. this.deviceType = type;
  208. this.deviceTypeName = this.deviceTypeMap[type].name;
  209. }
  210. // 获取当前地块ID
  211. this.initFieldInfo();
  212. // 加载设备列表
  213. this.loadDeviceList();
  214. },
  215. methods: {
  216. // 初始化地块信息
  217. initFieldInfo() {
  218. const currentPlots = JSON.parse(storage.getPlots() || '{}');
  219. if (currentPlots) {
  220. this.currentFieldId = currentPlots.id;
  221. }
  222. },
  223. // 获取特定状态的设备数量
  224. getStatusCount(status) {
  225. return this.deviceList.filter(device => device.status === status).length;
  226. },
  227. // 加载设备列表
  228. loadDeviceList(reset = true) {
  229. if (this.loading) return;
  230. if (reset) {
  231. this.pageNum = 1;
  232. this.deviceList = [];
  233. }
  234. this.loading = true;
  235. this.loadMoreStatus = 'loading';
  236. // 构建查询参数
  237. const params = {
  238. pageNum: this.pageNum,
  239. pageSize: this.pageSize,
  240. deviceQueryParams: this.searchKey || undefined,
  241. deviceType: this.deviceType || undefined,
  242. fieldId: this.currentFieldId || undefined
  243. };
  244. // 如果状态不是全部,添加状态筛选
  245. if (this.currentStatus !== -1) {
  246. params.status = this.currentStatus;
  247. }
  248. // 调用API获取设备列表
  249. fetchDevicesByType(params)
  250. .then(res => {
  251. console.log("res", res);
  252. if (res.data.code === 200 && res.data.rows) {
  253. const { rows, total } = res.data;
  254. // 更新设备列表
  255. if (reset) {
  256. this.deviceList = rows;
  257. } else {
  258. this.deviceList = [...this.deviceList, ...rows];
  259. }
  260. this.total = total;
  261. // 标记有告警的设备
  262. this.deviceList.forEach(device => {
  263. // 这里可以根据实际情况设置hasAlert属性
  264. device.hasAlert = false; // 示例,实际应该根据后台数据判断
  265. });
  266. // 更新加载更多状态
  267. if (this.deviceList.length >= total) {
  268. this.loadMoreStatus = 'noMore';
  269. } else {
  270. this.loadMoreStatus = 'more';
  271. }
  272. } else {
  273. this.handleApiError(res);
  274. }
  275. })
  276. .catch(error => {
  277. console.error('获取设备列表失败', error);
  278. uni.showToast({
  279. title: '获取设备列表失败',
  280. icon: 'none'
  281. });
  282. this.loadMoreStatus = 'more';
  283. })
  284. .finally(() => {
  285. this.loading = false;
  286. this.isRefreshing = false;
  287. uni.hideLoading();
  288. });
  289. },
  290. // 处理API错误
  291. handleApiError(res) {
  292. console.error('API错误', res);
  293. uni.showToast({
  294. title: res.msg || '获取数据失败',
  295. icon: 'none'
  296. });
  297. },
  298. // 搜索
  299. onSearch() {
  300. this.loadDeviceList();
  301. },
  302. // 清除搜索
  303. clearSearch() {
  304. this.searchKey = '';
  305. this.loadDeviceList();
  306. },
  307. // 选择状态
  308. selectStatus(value) {
  309. this.currentStatus = value;
  310. this.loadDeviceList();
  311. },
  312. // 处理下拉刷新
  313. handleRefresh() {
  314. this.isRefreshing = true;
  315. this.loadDeviceList();
  316. },
  317. // 跳转到设备详情页
  318. navigateToDeviceDetail(device) {
  319. console.log("device",device);
  320. // 根据设备类型跳转到不同的详情页
  321. let url = '';
  322. // 先发送事件
  323. uni.$emit('passDeviceData', {
  324. deviceId: device.deviceId,
  325. deviceTypeId: device.deviceTypeId,
  326. fieldName: device.fieldName,
  327. deviceName: device.deviceName
  328. });
  329. if (device.deviceTypeId === '2') {
  330. url = `/pages/device/device-list/detail-camera?id=${device.id}`;
  331. } else if (device.deviceTypeId === '1') {
  332. // 采集设备跳转到采集设备详情页,同时传递设备编码,便于判断设备子类型
  333. // url = `/pages/device/device-list/detail-collector?id=${device.deviceId}&deviceTypeId=${device.deviceTypeId}&fieldName=${device.fieldName}&deviceName=${device.deviceName}`;
  334. url = `/pages/device/device-list/detail-collector`;
  335. } else {
  336. // 其他类型设备暂时使用通用详情页
  337. url = `/pages/device/device-detail/index?id=${device.id}&type=${device.type}`;
  338. }
  339. // 先跳转
  340. uni.navigateTo({
  341. url: url,
  342. success: () => {
  343. // 跳转成功后再发送事件,延迟一点确保页面onLoad注册完成
  344. setTimeout(() => {
  345. uni.$emit('passDeviceData', {
  346. deviceId: device.deviceId,
  347. deviceTypeId: device.deviceTypeId,
  348. fieldName: device.fieldName,
  349. deviceName: device.deviceName,
  350. status:device.status
  351. });
  352. }, 100); // 100ms 通常足够,必要时可加到 200
  353. }
  354. });
  355. },
  356. // 获取设备类型图标
  357. getDeviceTypeIcon(typeId) {
  358. // 根据后端设备类型ID获取对应前端类型的图标
  359. const typeMapping = {
  360. '1': 'sensor', // 传感器
  361. '2': 'monitor', // 摄像头
  362. '3': 'control', // 控制器
  363. '4': 'irrigation', // 气象设备/灌溉设备
  364. '5': 'tractor' // 农机设备
  365. };
  366. const frontendType = typeMapping[typeId] || this.deviceType;
  367. return this.deviceTypeMap[frontendType]?.icon || '/static/icons/device.png';
  368. },
  369. // 获取设备类型名称
  370. getDeviceTypeName(typeId) {
  371. const typeNames = {
  372. '1': '采集设备',
  373. '2': '监控设备',
  374. '3': '控制设备',
  375. '4': '灌溉设备',
  376. '5': '农机设备'
  377. };
  378. return typeNames[typeId] || '未知类型';
  379. },
  380. // 获取状态文本
  381. getStatusText(status) {
  382. const statusMap = {
  383. 0: '离线',
  384. 1: '在线',
  385. 2: '故障',
  386. 3: '维护中'
  387. };
  388. return statusMap[status] || '未知状态';
  389. },
  390. // 格式化日期
  391. formatDate(dateStr) {
  392. if (!dateStr) return '未知';
  393. // 解析为 Date
  394. const parsedStr = dateStr.replace(' ', 'T');
  395. const date = new Date(parsedStr);
  396. if (isNaN(date)) return '无效时间';
  397. const now = new Date();
  398. // 计算差时长(分钟)
  399. const diff = Math.floor((now - date) / 1000 / 60);
  400. if (diff < 1) return '刚刚更新';
  401. if (diff < 5) return '1分钟前更新';
  402. if (diff < 10) return '5分钟前更新';
  403. if (diff < 60) return `${diff}分钟前更新`;
  404. if (diff < 120) return '1小时前更新';
  405. if (diff < 24 * 60) return `${Math.floor(diff / 60)}小时前更新`;
  406. if (diff < 7 * 24 * 60) return `${Math.floor(diff / (60 * 24))}天前更新`;
  407. return parsedStr.split('T')[0] + ' 更新';
  408. },
  409. /* formatDate(dateStr) {
  410. if (!dateStr) return '未知';
  411. const date = new Date(dateStr);
  412. const now = new Date();
  413. // 今天的日期
  414. if (date.toDateString() === now.toDateString()) {
  415. return `今天 ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
  416. }
  417. // 一周内
  418. const days = ['日', '一', '二', '三', '四', '五', '六'];
  419. const dayDiff = Math.floor((now - date) / (24 * 60 * 60 * 1000));
  420. if (dayDiff < 7) {
  421. return `周${days[date.getDay()]} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
  422. }
  423. // 超过一周
  424. return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
  425. }, */
  426. // 页面上拉触底事件
  427. onReachBottom() {
  428. if (this.loadMoreStatus === 'more') {
  429. this.pageNum++;
  430. this.loadDeviceList(false);
  431. }
  432. }
  433. },
  434. // 下拉刷新
  435. onPullDownRefresh() {
  436. this.loadDeviceList();
  437. setTimeout(() => {
  438. uni.stopPullDownRefresh();
  439. }, 1000);
  440. },
  441. // 页面显示
  442. onShow() {
  443. uni.setNavigationBarTitle({
  444. title: this.deviceTypeName || '设备列表'
  445. });
  446. }
  447. };
  448. </script>
  449. <style scoped>
  450. /* 图标字体 */
  451. @font-face {
  452. font-family: "iconfont";
  453. src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAAAOMAAsAAAAACFAAAAM+AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACDMgqDGIJmATYCJAMUCwwABCAFhGcHRhvqBsgOJaDgwABgBNFYPPy3H/3OSB4kWdI1Pb2QBw8gSpZIsxBFsTCNTIm//9dv/7FzF1E1S9ysIZWDPNdPJdSYbfLy/+fpTTMwKn5ZZ3OImpRUTZ8FHAcYFrLCBqyAHZD3CP9I09oXUgNcDSEAS8oGR507tO6KhRQTNQGQyeNGD8PCkVATUkFYsMgGcuqQ5YiFWruCPAVYnn9f/KGFBQxrghRq0KjzAXS5TP3SHp3ZmXUyEIfTAYDvDEiQARSQiaJjIjKaZiDJ+hpQYnY1i8tK1ZfWl83/fxYLm8TS//EADBBU6C9ghIBwJXxprxqwhC8d6x9AvAB4BcARgGWgRlWY71Cn5I5XvJ5Ot5sXy91Ud9Oj1nXnfbK9vK09bVsrGq2rrB1sxMcbxZmXntbdI8u6cRGhGy9r92Hj7hCjx1G6Dd9G9N6sbSvwVZiw+/hC0D7WFi5tbcltVyPOdqm41HkQr9T0bKFa2zrLLVeKJufZy7vn7aXtY+3XMvl65fJ7wnHT7ZJWozcvrHC5XNnTGy5/0NvX1xdSu8W9Ml0ePXEqZ3Jm0r6SLSdPbJnc27Mm05YsrLjfI8Ypvb5dL5pAj9m5c3Tzw+UvtK/SzO/Vv+Dt/9Lfq3+Xr30Hf9pz0JsnGgsPDBWHv+v12l5zGsE7Pz9A2d0W9WJ2dUZ/a/PkxQW58o/asvHDfyvJEw39G/5zf2p9OmZFYYGKoioVKPzPpwQA0+d2xv7C/aL/Dx/m7QfkjDLZL8AH4F3p+8PBrGIuqFLmM3uqfI6+YxAFCRZWAQ9LM8Q3JuRm2/bCgWEDCgzzIFgrEYk0AxgciQCDtQxgSRr76yYgfkIiHoB0FxGEEKfAEOQMJCHukYj0CQyjPsMQ0oJgyQD6hI6DL3FILJJLiqDqQs9kbYnLnTRuoA+5j7HsWmUJG2QdvdPrY51xR0WpwQZZIJvsGJ8OWYgVpomO28rIDCGTHHGJpqFe7xSPlUXs04FBiQV1FxSCqhboGVlrEldXpOGP94G4Hwydnaj6DjJBj1dvVtZizE8WlMYD9rHWaVsLsmF6QhZEmMDsIk1wOZWLgSHSSTkEJzGNQvvLc3HLFVXz9euBBWkm+YbLZKGH3uISrbIXRuNaAA==');
  454. }
  455. .iconfont {
  456. font-family: "iconfont" !important;
  457. font-size: 24rpx;
  458. font-style: normal;
  459. -webkit-font-smoothing: antialiased;
  460. -moz-osx-font-smoothing: grayscale;
  461. }
  462. .icon-search:before {
  463. content: "\e6e1";
  464. font-size: 32rpx;
  465. }
  466. .icon-close:before {
  467. content: "\e6a7";
  468. font-size: 28rpx;
  469. }
  470. .icon-right:before {
  471. content: "\e6a3";
  472. font-size: 28rpx;
  473. }
  474. .icon-empty:before {
  475. content: "\e6a9";
  476. font-size: 80rpx;
  477. }
  478. /* 容器样式 */
  479. .container {
  480. display: flex;
  481. flex-direction: column;
  482. min-height: 100vh;
  483. background-color: #F9FCFA;
  484. padding-bottom: 20rpx;
  485. }
  486. /* 搜索区域 */
  487. .search-section {
  488. padding: 20rpx 30rpx;
  489. background-color: #FFFFFF;
  490. margin-bottom: 2rpx;
  491. width: 100%;
  492. box-sizing: border-box;
  493. position: relative;
  494. z-index: 5;
  495. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.03);
  496. }
  497. .search-box {
  498. display: flex;
  499. align-items: center;
  500. background-color: #F7F7F7;
  501. height: 80rpx;
  502. border-radius: 40rpx;
  503. padding: 0 24rpx;
  504. width: 100%;
  505. box-sizing: border-box;
  506. border: 2rpx solid transparent;
  507. transition: all 0.3s ease;
  508. }
  509. .search-box.search-focus {
  510. border-color: #4CAF50;
  511. background-color: #FFFFFF;
  512. box-shadow: 0 0 10rpx rgba(76, 175, 80, 0.1);
  513. }
  514. .search-icon {
  515. color: #4CAF50;
  516. width: 60rpx;
  517. display: flex;
  518. justify-content: center;
  519. }
  520. .search-input {
  521. flex: 1;
  522. height: 80rpx;
  523. font-size: 28rpx;
  524. color: #333333;
  525. }
  526. .clear-icon {
  527. width: 60rpx;
  528. display: flex;
  529. justify-content: center;
  530. color: #999;
  531. }
  532. /* 状态筛选区域 */
  533. .filter-section {
  534. display: flex;
  535. padding: 24rpx 24rpx;
  536. background-color: #FFFFFF;
  537. margin-bottom: 20rpx;
  538. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
  539. position: relative;
  540. z-index: 4;
  541. flex-wrap: wrap;
  542. }
  543. .filter-item {
  544. display: flex;
  545. align-items: center;
  546. font-size: 28rpx;
  547. color: #666666;
  548. margin-right: 30rpx;
  549. padding: 12rpx 20rpx;
  550. border-radius: 30rpx;
  551. transition: all 0.2s ease;
  552. position: relative;
  553. margin-bottom: 10rpx;
  554. }
  555. .filter-item.active {
  556. background-color: #F0F9F0;
  557. color: #4CAF50;
  558. font-weight: 500;
  559. }
  560. .filter-dot {
  561. width: 14rpx;
  562. height: 14rpx;
  563. border-radius: 50%;
  564. margin-right: 10rpx;
  565. }
  566. .online-dot {
  567. background-color: #4CAF50;
  568. box-shadow: 0 0 6rpx rgba(76, 175, 80, 0.5);
  569. }
  570. .offline-dot {
  571. background-color: #F56C6C;
  572. box-shadow: 0 0 6rpx rgba(245, 108, 108, 0.5);
  573. }
  574. .fault-dot {
  575. background-color: #FF9800;
  576. box-shadow: 0 0 6rpx rgba(255, 152, 0, 0.5);
  577. }
  578. .maintain-dot {
  579. background-color: #2196F3;
  580. box-shadow: 0 0 6rpx rgba(33, 150, 243, 0.5);
  581. }
  582. /* 设备列表区域 */
  583. .device-list {
  584. flex: 1;
  585. padding: 0 30rpx;
  586. box-sizing: border-box;
  587. width: 100%;
  588. position: relative;
  589. z-index: 3;
  590. height: calc(100vh - 220rpx);
  591. }
  592. /* 空数据提示 */
  593. .empty-tips {
  594. padding: 120rpx 0;
  595. display: flex;
  596. flex-direction: column;
  597. align-items: center;
  598. justify-content: center;
  599. }
  600. .empty-icon {
  601. color: #DDDDDD;
  602. margin-bottom: 20rpx;
  603. }
  604. .empty-text {
  605. font-size: 28rpx;
  606. color: #999999;
  607. margin-bottom: 20rpx;
  608. }
  609. .empty-action {
  610. font-size: 26rpx;
  611. color: #4CAF50;
  612. padding: 12rpx 30rpx;
  613. border-radius: 30rpx;
  614. background-color: rgba(76, 175, 80, 0.1);
  615. }
  616. /* 首次加载中状态 */
  617. .loading-container {
  618. padding: 80rpx 0;
  619. display: flex;
  620. flex-direction: column;
  621. align-items: center;
  622. justify-content: center;
  623. }
  624. .loading-spinner {
  625. width: 60rpx;
  626. height: 60rpx;
  627. border: 4rpx solid #E0E0E0;
  628. border-top: 4rpx solid #4CAF50;
  629. border-radius: 50%;
  630. animation: spin 1s linear infinite;
  631. margin-bottom: 20rpx;
  632. }
  633. .loading-text {
  634. font-size: 28rpx;
  635. color: #999999;
  636. }
  637. /* 设备卡片 */
  638. .device-card {
  639. position: relative;
  640. background-color: #FFFFFF;
  641. border-radius: 24rpx;
  642. padding: 28rpx;
  643. margin-bottom: 24rpx;
  644. box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.05);
  645. transition: all 0.25s ease;
  646. width: 100%;
  647. box-sizing: border-box;
  648. border: 1rpx solid rgba(0, 0, 0, 0.05);
  649. overflow: hidden;
  650. }
  651. .device-card::before {
  652. content: "";
  653. position: absolute;
  654. top: 0;
  655. left: 0;
  656. width: 6rpx;
  657. height: 100%;
  658. background: linear-gradient(to bottom, #66CC6A, #3BB44A);
  659. opacity: 0;
  660. transition: opacity 0.3s ease;
  661. }
  662. .device-card:active::before {
  663. opacity: 1;
  664. }
  665. .device-card-hover {
  666. background-color: #f2fef6;
  667. box-shadow: 0 10rpx 25rpx rgba(59, 180, 74, 0.1);
  668. transform: translateY(-3rpx);
  669. }
  670. .device-card.has-alert {
  671. box-shadow: 0 6rpx 20rpx rgba(245, 108, 108, 0.08);
  672. border: 1rpx solid rgba(245, 108, 108, 0.08);
  673. }
  674. .device-card.has-alert::before {
  675. background: linear-gradient(to bottom, #FF8F8F, #F56C6C);
  676. }
  677. .device-card.is-offline {
  678. opacity: 0.9;
  679. }
  680. .device-card.is-offline.device-card-hover {
  681. background-color: #f5f5f5;
  682. box-shadow: 0 10rpx 25rpx rgba(0, 0, 0, 0.05);
  683. }
  684. /* 告警角标 */
  685. .alarm-badge {
  686. position: absolute;
  687. top: -8rpx;
  688. right: -8rpx;
  689. min-width: 36rpx;
  690. height: 36rpx;
  691. border-radius: 18rpx;
  692. background-color: #F56C6C;
  693. color: #FFFFFF;
  694. font-size: 22rpx;
  695. font-weight: 600;
  696. display: flex;
  697. align-items: center;
  698. justify-content: center;
  699. padding: 0 8rpx;
  700. z-index: 3;
  701. box-shadow: 0 3rpx 8rpx rgba(245, 108, 108, 0.3);
  702. animation: pulse 1.5s infinite;
  703. }
  704. @keyframes pulse {
  705. 0% {
  706. transform: scale(1);
  707. }
  708. 50% {
  709. transform: scale(1.1);
  710. }
  711. 100% {
  712. transform: scale(1);
  713. }
  714. }
  715. /* 设备基本信息 */
  716. .device-info {
  717. display: flex;
  718. margin-bottom: 24rpx;
  719. width: 100%;
  720. }
  721. .device-icon-wrapper {
  722. position: relative;
  723. margin-right: 24rpx;
  724. flex-shrink: 0;
  725. }
  726. .device-icon-container {
  727. width: 96rpx;
  728. height: 96rpx;
  729. border-radius: 50%;
  730. background: linear-gradient(135deg, #66CC6A 0%, #3BB44A 100%);
  731. display: flex;
  732. align-items: center;
  733. justify-content: center;
  734. flex-shrink: 0;
  735. box-shadow: 0 6rpx 16rpx rgba(59, 180, 74, 0.2);
  736. transition: all 0.3s ease;
  737. }
  738. .device-icon-container.offline-icon {
  739. background: linear-gradient(135deg, #AAB2BD 0%, #656D78 100%);
  740. box-shadow: 0 6rpx 16rpx rgba(101, 109, 120, 0.2);
  741. }
  742. .device-icon {
  743. width: 52rpx;
  744. height: 52rpx;
  745. filter: brightness(0) invert(1);
  746. }
  747. .device-meta {
  748. flex: 1;
  749. width: calc(100% - 120rpx);
  750. overflow: hidden;
  751. }
  752. .device-name-row {
  753. display: flex;
  754. justify-content: space-between;
  755. align-items: center;
  756. margin-bottom: 14rpx;
  757. width: 100%;
  758. }
  759. .device-name {
  760. font-size: 34rpx;
  761. font-weight: 600;
  762. color: #333333;
  763. max-width: 65%;
  764. overflow: hidden;
  765. text-overflow: ellipsis;
  766. white-space: nowrap;
  767. transition: color 0.3s ease;
  768. }
  769. .device-name.offline-text {
  770. color: #656D78;
  771. }
  772. .status-tag {
  773. padding: 6rpx 16rpx 6rpx 32rpx;
  774. border-radius: 8rpx;
  775. font-size: 24rpx;
  776. font-weight: 500;
  777. flex-shrink: 0;
  778. border: 1rpx solid;
  779. position: relative;
  780. overflow: hidden;
  781. }
  782. .status-online {
  783. background-color: rgba(76, 175, 80, 0.1);
  784. color: #4CAF50;
  785. border-color: rgba(76, 175, 80, 0.3);
  786. }
  787. .status-offline {
  788. background-color: rgba(245, 108, 108, 0.1);
  789. color: #F56C6C;
  790. border-color: rgba(245, 108, 108, 0.3);
  791. }
  792. .status-fault {
  793. background-color: rgba(255, 152, 0, 0.1);
  794. color: #FF9800;
  795. border-color: rgba(255, 152, 0, 0.3);
  796. }
  797. .status-maintain {
  798. background-color: rgba(33, 150, 243, 0.1);
  799. color: #2196F3;
  800. border-color: rgba(33, 150, 243, 0.3);
  801. }
  802. .status-dot {
  803. position: absolute;
  804. width: 8rpx;
  805. height: 8rpx;
  806. background-color: #4CAF50;
  807. border-radius: 50%;
  808. top: 50%;
  809. left: 16rpx;
  810. transform: translateY(-50%);
  811. box-shadow: 0 0 4rpx rgba(76, 175, 80, 0.8);
  812. animation: blink 1.5s infinite;
  813. display: inline-block;
  814. }
  815. .status-dot.offline-dot {
  816. background-color: #F56C6C;
  817. box-shadow: 0 0 4rpx rgba(245, 108, 108, 0.8);
  818. }
  819. .status-dot.fault-dot {
  820. background-color: #FF9800;
  821. box-shadow: 0 0 4rpx rgba(255, 152, 0, 0.8);
  822. }
  823. .status-dot.maintain-dot {
  824. background-color: #2196F3;
  825. box-shadow: 0 0 4rpx rgba(33, 150, 243, 0.8);
  826. }
  827. @keyframes blink {
  828. 0% {
  829. opacity: 0.4;
  830. }
  831. 50% {
  832. opacity: 1;
  833. }
  834. 100% {
  835. opacity: 0.4;
  836. }
  837. }
  838. .device-id, .device-location {
  839. display: flex;
  840. font-size: 26rpx;
  841. margin-top: 10rpx;
  842. color: #666666;
  843. width: 100%;
  844. overflow: hidden;
  845. }
  846. .id-label, .location-label {
  847. color: #999999;
  848. margin-right: 8rpx;
  849. flex-shrink: 0;
  850. }
  851. .id-value, .location-value {
  852. color: #666666;
  853. overflow: hidden;
  854. text-overflow: ellipsis;
  855. white-space: nowrap;
  856. }
  857. /* 底部信息栏 */
  858. .device-footer {
  859. display: flex;
  860. justify-content: space-between;
  861. align-items: center;
  862. padding-top: 18rpx;
  863. border-top: 1rpx solid #F2F2F2;
  864. }
  865. .update-time {
  866. font-size: 24rpx;
  867. color: #999999;
  868. }
  869. .device-actions {
  870. display: flex;
  871. align-items: center;
  872. color: #CCCCCC;
  873. }
  874. /* 加载更多区域 */
  875. .load-more {
  876. padding: 20rpx 0 40rpx;
  877. }
  878. .load-more-content {
  879. display: flex;
  880. justify-content: center;
  881. align-items: center;
  882. height: 60rpx;
  883. font-size: 24rpx;
  884. color: #999999;
  885. }
  886. .loading-icon {
  887. width: 30rpx;
  888. height: 30rpx;
  889. margin-right: 10rpx;
  890. border: 2rpx solid #E0E0E0;
  891. border-top: 2rpx solid #4CAF50;
  892. border-radius: 50%;
  893. animation: spin 1s linear infinite;
  894. }
  895. @keyframes spin {
  896. 0% { transform: rotate(0deg); }
  897. 100% { transform: rotate(360deg); }
  898. }
  899. </style>