list.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. <template>
  2. <view class="container">
  3. <!-- 头部区域 -->
  4. <view class="header">
  5. <view class="back-button" @click="goBack">
  6. <text class="iconfont icon-back">&#xe60e;</text>
  7. </view>
  8. <text class="page-title">选择地块</text>
  9. </view>
  10. <!-- 搜索栏 -->
  11. <view class="search-box">
  12. <view class="search-input">
  13. <image src="@/static/icons/search.png" style="width: 40rpx; height: 40rpx; padding-right: 10rpx;"
  14. mode="widthFix" />
  15. <input type="text" v-model="searchKeyword" placeholder="搜索地块名称/编号/负责人/农场" confirm-type="search"
  16. @input="handleSearch" />
  17. <text v-if="searchKeyword" class="clear-icon" @click="clearSearch">×</text>
  18. </view>
  19. </view>
  20. <!-- 当前选中地块 -->
  21. <view class="current-block">
  22. <view class="block-header">
  23. <view class="left">
  24. <text class="icon-tag">当前</text>
  25. <text class="title">当前地块</text>
  26. </view>
  27. </view>
  28. <view class="current-block-card">
  29. <view class="current-tag">当前</view>
  30. <view class="block-content">
  31. <view class="block-icon">
  32. <image src="/static/icons/location.svg" class="location-icon" mode="aspectFit"></image>
  33. </view>
  34. <view class="block-info">
  35. <!-- 标题区域:显示地块名称 + 所属农场名称 -->
  36. <view class="block-name">{{ currentBlock.name }}</view>
  37. <view class="block-farm">{{ currentBlock.farmName }}</view>
  38. <!-- 次级信息区域:显示地块编号、负责人 -->
  39. <view class="block-meta">
  40. <text>编号:{{ currentBlock.code }}</text>
  41. <text class="separator">|</text>
  42. <text>负责人:{{ currentBlock.manager }}</text>
  43. </view>
  44. <!-- 已有信息:面积、类型、作物 -->
  45. <view class="block-details">
  46. <text>{{ currentBlock.area }}亩</text>
  47. <text class="separator">|</text>
  48. <text>{{ currentBlock.type }}</text>
  49. <text v-if="currentBlock.crop" class="separator">|</text>
  50. <text v-if="currentBlock.crop">{{ currentBlock.crop }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="block-stats">
  55. <view class="stat-item">
  56. <image src="/static/icons/device.svg" class="stat-icon" mode="aspectFit"></image>
  57. <text>设备:{{ currentBlock.deviceCount }}</text>
  58. </view>
  59. <view class="stat-item">
  60. <image src="/static/icons/online.svg" class="stat-icon online-icon" mode="aspectFit"></image>
  61. <text>在线:{{ currentBlock.onlineDevices }}</text>
  62. </view>
  63. <view class="stat-item" v-if="currentBlock.alerts > 0">
  64. <image src="/static/icons/alert.svg" class="stat-icon alert-icon" mode="aspectFit"></image>
  65. <text class="alert-text">告警:{{ currentBlock.alerts }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 地块列表 -->
  71. <view class="block-list">
  72. <view class="block-header">
  73. <view class="left">
  74. <text class="icon-tag">列表</text>
  75. <text class="title">可选地块列表</text>
  76. </view>
  77. <text class="count">共{{ filteredBlocks.length }}个地块</text>
  78. </view>
  79. <!-- 加载骨架屏 -->
  80. <template v-if="isLoading">
  81. <view class="skeleton-container">
  82. <view class="skeleton-box" v-for="i in 3" :key="i">
  83. <view class="skeleton-header">
  84. <view class="skeleton-icon"></view>
  85. <view class="skeleton-info">
  86. <view class="skeleton-title"></view>
  87. <view class="skeleton-detail"></view>
  88. </view>
  89. </view>
  90. <view class="skeleton-stats"></view>
  91. </view>
  92. </view>
  93. </template>
  94. <!-- 空状态 -->
  95. <template v-else-if="filteredBlocks.length === 0">
  96. <view class="empty-state">
  97. <image src="/static/images/empty.png" mode="aspectFit" class="empty-image"></image>
  98. <text class="empty-text">暂无可选地块</text>
  99. <text class="empty-subtext">请添加或关联地块后再试</text>
  100. </view>
  101. </template>
  102. <!-- 地块列表 -->
  103. <template v-else>
  104. <view class="block-cards">
  105. <view class="block-card" v-for="block in filteredBlocks" :key="block.id"
  106. :class="{'active-block': currentBlock.id === block.id, 'clickable': currentBlock.id !== block.id}"
  107. @click="handleBlockClick(block)">
  108. <view v-if="block.status === 'active'" class="status-badge status-active-badge">使用中</view>
  109. <view v-if="block.status === 'idle'" class="status-badge status-idle-badge">闲置</view>
  110. <view v-if="block.status === 'maintenance'" class="status-badge status-maintenance-badge">维护中
  111. </view>
  112. <view class="block-content">
  113. <view class="block-icon">
  114. <image src="/static/icons/location.svg" class="location-icon" mode="aspectFit"></image>
  115. </view>
  116. <view class="block-info">
  117. <!-- 标题区域:显示地块名称 + 所属农场名称 -->
  118. <view class="block-name">{{ block.name }}</view>
  119. <view class="block-farm">{{ block.farmName }}</view>
  120. <!-- 次级信息区域:显示地块编号、负责人 -->
  121. <view class="block-meta">
  122. <text>编号:{{ block.code }}</text>
  123. <text class="separator">|</text>
  124. <text>负责人:{{ block.manager }}</text>
  125. </view>
  126. <!-- 已有信息:面积、类型、作物 -->
  127. <view class="block-details">
  128. <text>{{ block.area }}亩</text>
  129. <text class="separator">|</text>
  130. <text>{{ block.type }}</text>
  131. <text v-if="block.crop" class="separator">|</text>
  132. <text v-if="block.crop">{{ block.crop }}</text>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="block-stats">
  137. <view class="stat-item">
  138. <image src="/static/icons/device.svg" class="stat-icon" mode="aspectFit"></image>
  139. <text>设备:{{ block.deviceCount }}</text>
  140. </view>
  141. <view class="stat-item">
  142. <image src="/static/icons/online.svg" class="stat-icon online-icon" mode="aspectFit">
  143. </image>
  144. <text>在线:{{ block.onlineDevices }}</text>
  145. </view>
  146. <view class="stat-item" v-if="block.alerts > 0">
  147. <image src="/static/icons/alert.svg" class="stat-icon alert-icon" mode="aspectFit">
  148. </image>
  149. <text class="alert-text">告警:{{ block.alerts }}</text>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </template>
  155. </view>
  156. <!-- 底部加载提示区域 -->
  157. <view class="loading-more" v-if="isLoadingTip || !hasMore">
  158. <view v-if="loadingMore" class="loading-text">
  159. <view class="loading-icon"></view>
  160. <text>正在加载更多地块...</text>
  161. </view>
  162. <text v-else-if="!hasMore && blocks.length > 0" class="no-more-text">没有更多地块了</text>
  163. </view>
  164. </view>
  165. </template>
  166. <script>
  167. import {
  168. fetchUserFieldList,
  169. getUserCurrentField,
  170. searchUserField
  171. } from '@/api/services/field.js';
  172. import storage from "@/utils/storage.js";
  173. export default {
  174. // 配置页面的下拉刷新
  175. onPullDownRefresh: true,
  176. data() {
  177. return {
  178. isLoading: true,
  179. searchKeyword: '',
  180. currentBlock: {
  181. id: '',
  182. code: '',
  183. name: '',
  184. farmName: '',
  185. manager: '',
  186. area: 0,
  187. type: '',
  188. crop: '',
  189. status: 'active',
  190. deviceCount: 0,
  191. onlineDevices: 0,
  192. alerts: 0
  193. },
  194. blocks: [],
  195. searchTimer: null,
  196. // 添加分页相关数据
  197. pageNum: 1, // 当前页码
  198. pageSize: 10, // 每页数量
  199. totalCount: 0, // 总记录数
  200. loadingMore: false, // 是否正在加载更多
  201. hasMore: true, // 是否还有更多数据
  202. isLoadingTip: false, // 是否显示底部加载提示
  203. refreshing: false // 是否正在下拉刷新
  204. }
  205. },
  206. computed: {
  207. filteredBlocks() {
  208. return this.blocks;
  209. }
  210. },
  211. mounted() {
  212. // 获取当前选中地块
  213. // this.fetchCurrentField();
  214. // 获取地块列表
  215. this.getFieldList(true);
  216. },
  217. // 添加页面触底事件处理函数
  218. onReachBottom() {
  219. this.loadMore();
  220. },
  221. // 下拉刷新
  222. onPullDownRefresh() {
  223. this.refreshing = true;
  224. // 重置页码并刷新列表
  225. this.getFieldList(true);
  226. // 延迟关闭刷新动画
  227. setTimeout(() => {
  228. this.refreshing = false;
  229. uni.stopPullDownRefresh();
  230. }, 1000);
  231. },
  232. methods: {
  233. // 获取当前选中的地块
  234. fetchCurrentField() {
  235. try {
  236. // 获取当前登录用户的默认地块
  237. getUserCurrentField().then((res) => {
  238. console.log("fetchCurrentField", res);
  239. if (res.data && res.data.code === 200 && res.data.data) {
  240. this.currentBlock = res.data.data;
  241. } else {
  242. // 如果没有当前选中地块,则在获取列表成功后设置第一个为当前地块
  243. console.log('未查询到当前地块,将使用列表第一个地块');
  244. }
  245. }).catch(err => {
  246. console.error('获取当前地块失败', err);
  247. });
  248. } catch (e) {
  249. console.log("fetchCurrentField 异常", e);
  250. }
  251. },
  252. // 获取地块列表
  253. getFieldList(isRefresh = false) {
  254. console.log("执行情况");
  255. // 刷新时重置页码
  256. if (isRefresh) {
  257. this.pageNum = 1;
  258. this.blocks = [];
  259. this.hasMore = true;
  260. }
  261. if (!this.hasMore && !isRefresh) {
  262. return; // 如果没有更多数据且不是刷新,则不请求
  263. }
  264. // 标记正在加载
  265. if (this.pageNum === 1) {
  266. this.isLoading = true;
  267. } else {
  268. this.loadingMore = true;
  269. this.isLoadingTip = true;
  270. }
  271. console.log("当前页码值:", this.pageNum);
  272. // 获取当前登录用户关联的地块列表
  273. fetchUserFieldList(
  274. this.pageNum,
  275. this.pageSize
  276. ).then((res) => {
  277. if (this.pageNum === 1) {
  278. this.isLoading = false;
  279. } else {
  280. this.loadingMore = false;
  281. }
  282. console.log("地块res", res);
  283. if (res.data && res.data.code === 200 && res.data.data) {
  284. // 获取总数
  285. this.totalCount = res.data.data.total || 0;
  286. // 追加数据,而不是替换
  287. if (this.pageNum === 1) {
  288. this.blocks = res.data.data.list;
  289. } else {
  290. this.blocks = [...this.blocks, ...res.data.data.list];
  291. }
  292. // 判断是否还有更多数据
  293. this.hasMore = this.blocks.length < this.totalCount;
  294. // 尝试从本地存储中读取上次选择的地块
  295. if (this.pageNum === 1) {
  296. this.loadSavedBlock();
  297. // 如果当前没有选中地块,则设置第一个为当前地块
  298. if (!this.currentBlock.id && this.blocks.length > 0) {
  299. this.currentBlock = this.blocks[0];
  300. // 保存当前选择的地块到本地存储
  301. this.saveCurrentBlockToStorage(this.currentBlock);
  302. }
  303. }
  304. // 页码加1,为下次加载做准备
  305. this.pageNum++;
  306. } else {
  307. this.isLoading = false;
  308. this.loadingMore = false;
  309. this.hasMore = false;
  310. console.error('获取地块列表失败', res);
  311. uni.showToast({
  312. title: '获取地块列表失败',
  313. icon: 'none'
  314. });
  315. }
  316. // 2秒后隐藏加载提示
  317. setTimeout(() => {
  318. this.isLoadingTip = false;
  319. }, 2000);
  320. }).catch(err => {
  321. this.isLoading = false;
  322. this.loadingMore = false;
  323. this.hasMore = false;
  324. console.error('获取地块列表失败', err);
  325. uni.showToast({
  326. title: '获取地块列表失败',
  327. icon: 'none'
  328. });
  329. // 隐藏加载提示
  330. this.isLoadingTip = false;
  331. });
  332. },
  333. // 根据关键字搜索地块
  334. searchFields(keyword) {
  335. console.log("keyword",keyword);
  336. if (!keyword) {
  337. this.getFieldList(true);
  338. return;
  339. }
  340. // 重置分页数据
  341. this.pageNum = 1;
  342. this.blocks = [];
  343. this.hasMore = true;
  344. this.isLoading = true;
  345. // 使用用户关联地块搜索接口
  346. searchUserField({
  347. keyword: keyword,
  348. pageNum: this.pageNum,
  349. pageSize: this.pageSize
  350. }).then((res) => {
  351. this.isLoading = false;
  352. if (res.data && res.data.code === 200 && res.data.data.list) {
  353. this.blocks = res.data.data.list;
  354. // 搜索结果可能没有总数信息,根据返回数据判断是否有更多
  355. this.hasMore = res.data.data.total >= this.pageSize;
  356. // 增加页码为下次加载做准备
  357. this.pageNum++;
  358. }
  359. }).catch(err => {
  360. this.isLoading = false;
  361. this.hasMore = false;
  362. console.error('搜索地块失败', err);
  363. });
  364. },
  365. goBack() {
  366. uni.navigateBack();
  367. },
  368. handleSearch() {
  369. // 防抖处理,避免频繁请求
  370. if (this.searchTimer) {
  371. clearTimeout(this.searchTimer);
  372. }
  373. this.searchTimer = setTimeout(() => {
  374. this.searchFields(this.searchKeyword);
  375. }, 500);
  376. },
  377. clearSearch() {
  378. this.searchKeyword = '';
  379. this.getFieldList(true);
  380. },
  381. handleBlockClick(block) {
  382. // 如果点击当前已选中的地块,不做任何操作
  383. if (this.currentBlock.id === block.id) return;
  384. // 弹出确认框
  385. uni.showModal({
  386. title: '切换地块',
  387. content: '是否切换到该地块?切换后将查看该地块的相关设备数据。',
  388. cancelText: '取消',
  389. confirmText: '确定',
  390. success: (res) => {
  391. if (res.confirm) {
  392. this.selectBlock(block);
  393. }
  394. }
  395. });
  396. },
  397. selectBlock(block) {
  398. this.currentBlock = block;
  399. console.log("选择地块信息:",block);
  400. // 保存当前选择的地块到本地存储
  401. this.saveCurrentBlockToStorage(block);
  402. // 触发选择事件,传递地块ID
  403. this.$emit('selectBlock', block.id);
  404. // 获取页面参数,检查是否需要返回
  405. const pages = getCurrentPages();
  406. const currentPage = pages[pages.length - 1];
  407. let eventChannel;
  408. // 尝试获取页面参数和事件通道
  409. let shouldReturn = true; // 默认行为是返回
  410. try {
  411. const options = currentPage.options || {};
  412. // 获取事件通道(如果存在)
  413. eventChannel = currentPage.getOpenerEventChannel && currentPage.getOpenerEventChannel();
  414. // 如果有redirect参数,则跳转到指定页面而不是返回
  415. if (options.redirect) {
  416. shouldReturn = false;
  417. uni.redirectTo({
  418. url: decodeURIComponent(options.redirect),
  419. success: () => {
  420. // 跳转成功后传递选中的地块数据
  421. if (eventChannel) {
  422. eventChannel.emit('selectBlockResult', {
  423. success: true,
  424. blockId: block.id,
  425. blockData: block
  426. });
  427. }
  428. }
  429. });
  430. } else if (options.noReturn === 'true') {
  431. // 如果设置了noReturn参数,则不执行返回操作
  432. shouldReturn = false;
  433. }
  434. } catch (e) {
  435. console.error('获取页面参数失败', e);
  436. }
  437. // 如果需要返回上一页,则执行返回操作
  438. if (shouldReturn) {
  439. setTimeout(() => {
  440. uni.navigateBack({
  441. success: () => {
  442. // 返回成功后传递选中的地块数据
  443. if (eventChannel) {
  444. eventChannel.emit('selectBlockResult', {
  445. success: true,
  446. blockId: block.id,
  447. blockData: block
  448. });
  449. }
  450. }
  451. });
  452. }, 300);
  453. }
  454. },
  455. // 保存当前选择的地块到本地存储
  456. saveCurrentBlockToStorage(block) {
  457. try {
  458. this.currentBlock = block
  459. console.log("this.currentBlock", this.currentBlock);
  460. console.log("block", block);
  461. storage.setPlots(JSON.stringify({
  462. id: block.id,
  463. code: block.code,
  464. name: block.name,
  465. growCrops: block.crop,
  466. managerName:block.manager,
  467. size: block.area,
  468. farmId:block.farmId,
  469. timestamp: Date.now()
  470. }))
  471. } catch (e) {
  472. console.error('保存地块选择状态失败', e);
  473. }
  474. },
  475. // 从本地存储加载上次选择的地块
  476. loadSavedBlock() {
  477. try {
  478. const savedPlot = storage.getPlots();
  479. if (savedPlot) {
  480. const plotData = JSON.parse(savedPlot);
  481. // 如果存储的地块在当前地块列表中,则设置为当前选中地块
  482. const matchedBlock = this.blocks.find(block => block.id == plotData.id);
  483. if (matchedBlock) {
  484. this.currentBlock = matchedBlock;
  485. }
  486. }
  487. } catch (e) {
  488. console.error('读取保存的地块失败', e);
  489. }
  490. },
  491. getStatusClass(status) {
  492. const statusMap = {
  493. 'active': 'status-active',
  494. 'idle': 'status-idle',
  495. 'maintenance': 'status-maintenance'
  496. }
  497. return statusMap[status] || '';
  498. },
  499. getStatusText(status) {
  500. const statusMap = {
  501. 'active': '使用中',
  502. 'idle': '闲置',
  503. 'maintenance': '维护中'
  504. }
  505. return statusMap[status] || '未知';
  506. },
  507. // 可以被父组件调用的方法
  508. onBack(callback) {
  509. if (typeof callback === 'function') {
  510. callback(this.currentBlock.id);
  511. }
  512. },
  513. // 加载更多数据
  514. loadMore() {
  515. if (this.loadingMore || !this.hasMore) return;
  516. this.getFieldList();
  517. }
  518. }
  519. }
  520. </script>
  521. <style>
  522. .container {
  523. min-height: 100vh;
  524. background-color: #F5F7FA;
  525. padding-bottom: 30rpx;
  526. }
  527. /* 头部导航 */
  528. .header {
  529. display: none;
  530. /* 隐藏整个头部标题栏 */
  531. }
  532. .back-button {
  533. width: 60rpx;
  534. height: 60rpx;
  535. display: flex;
  536. align-items: center;
  537. justify-content: center;
  538. }
  539. .icon-back {
  540. font-size: 36rpx;
  541. color: #333;
  542. }
  543. .page-title {
  544. flex: 1;
  545. text-align: center;
  546. font-size: 32rpx;
  547. font-weight: bold;
  548. color: #333;
  549. margin-right: 60rpx;
  550. /* 平衡左侧返回按钮 */
  551. }
  552. /* 搜索框 */
  553. .search-box {
  554. padding: 20rpx 30rpx;
  555. background-color: #FFFFFF;
  556. border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  557. margin-bottom: 20rpx;
  558. }
  559. .search-header {
  560. font-size: 28rpx;
  561. color: #333;
  562. font-weight: 500;
  563. margin-bottom: 15rpx;
  564. }
  565. .search-input {
  566. display: flex;
  567. align-items: center;
  568. height: 70rpx;
  569. background-color: #F5F7FA;
  570. border-radius: 35rpx;
  571. padding: 0 30rpx;
  572. box-shadow: inset 0 1rpx 3rpx rgba(0, 0, 0, 0.05);
  573. border: 1rpx solid rgba(0, 0, 0, 0.03);
  574. }
  575. .icon-search {
  576. font-size: 28rpx;
  577. color: #999;
  578. margin-right: 10rpx;
  579. }
  580. .search-input input {
  581. flex: 1;
  582. height: 70rpx;
  583. font-size: 28rpx;
  584. color: #333;
  585. }
  586. .clear-icon {
  587. width: 40rpx;
  588. height: 40rpx;
  589. display: flex;
  590. align-items: center;
  591. justify-content: center;
  592. font-size: 32rpx;
  593. color: #999;
  594. }
  595. /* 块区域通用样式 */
  596. .current-block,
  597. .block-list {
  598. margin: 0 30rpx 20rpx;
  599. background-color: #FFFFFF;
  600. padding: 24rpx;
  601. border-radius: 24rpx;
  602. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  603. }
  604. .block-header {
  605. display: flex;
  606. justify-content: space-between;
  607. align-items: center;
  608. margin-bottom: 20rpx;
  609. }
  610. .block-header .left {
  611. display: flex;
  612. align-items: center;
  613. }
  614. .icon-tag {
  615. font-size: 24rpx;
  616. color: #FFFFFF;
  617. background: linear-gradient(135deg, #66CC6A 0%, #3BB44A 100%);
  618. padding: 4rpx 16rpx;
  619. border-radius: 6rpx;
  620. margin-right: 16rpx;
  621. box-shadow: 0 2rpx 5rpx rgba(59, 180, 74, 0.2);
  622. }
  623. .block-header .title {
  624. font-size: 30rpx;
  625. font-weight: bold;
  626. color: #333;
  627. }
  628. .block-header .count {
  629. font-size: 24rpx;
  630. color: #999;
  631. background-color: #F5F7FA;
  632. padding: 4rpx 16rpx;
  633. border-radius: 20rpx;
  634. }
  635. /* 当前选中地块卡片 */
  636. .current-block-card {
  637. background: linear-gradient(to right, #F0F8F0, #E7F5E8);
  638. border-radius: 16rpx;
  639. padding: 30rpx;
  640. position: relative;
  641. border: 2rpx solid rgba(59, 180, 74, 0.2);
  642. box-shadow: 0 4rpx 16rpx rgba(59, 180, 74, 0.1);
  643. }
  644. .current-tag {
  645. position: absolute;
  646. top: 0;
  647. right: 20rpx;
  648. background: linear-gradient(135deg, #66CC6A 0%, #3BB44A 100%);
  649. color: white;
  650. font-size: 22rpx;
  651. padding: 6rpx 16rpx;
  652. border-radius: 0 0 12rpx 12rpx;
  653. font-weight: bold;
  654. }
  655. /* 地块列表卡片 */
  656. .block-cards {
  657. display: flex;
  658. flex-direction: column;
  659. gap: 20rpx;
  660. }
  661. .block-card {
  662. background-color: #FFFFFF;
  663. border-radius: 16rpx;
  664. padding: 30rpx;
  665. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  666. position: relative;
  667. border: 1rpx solid rgba(0, 0, 0, 0.03);
  668. transition: all 0.3s ease;
  669. }
  670. .block-card:active {
  671. transform: scale(0.98);
  672. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.03);
  673. }
  674. .block-card.active-block {
  675. border: 2rpx solid #3BB44A;
  676. background-color: #F0F8F0;
  677. box-shadow: 0 4rpx 16rpx rgba(59, 180, 74, 0.1);
  678. }
  679. .block-card.clickable {
  680. cursor: pointer;
  681. }
  682. .block-card.clickable:hover {
  683. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  684. }
  685. .block-content {
  686. display: flex;
  687. align-items: flex-start;
  688. position: relative;
  689. margin-bottom: 20rpx;
  690. }
  691. .block-icon {
  692. width: 40rpx;
  693. margin-right: 15rpx;
  694. display: flex;
  695. align-items: center;
  696. justify-content: center;
  697. }
  698. .location-icon {
  699. width: 36rpx;
  700. height: 36rpx;
  701. }
  702. .block-info {
  703. flex: 1;
  704. }
  705. .block-name {
  706. font-size: 32rpx;
  707. font-weight: bold;
  708. color: #333;
  709. margin-bottom: 6rpx;
  710. }
  711. .block-farm {
  712. font-size: 26rpx;
  713. color: #666;
  714. margin-bottom: 10rpx;
  715. }
  716. .block-meta {
  717. font-size: 26rpx;
  718. color: #999;
  719. margin-bottom: 10rpx;
  720. }
  721. .block-details {
  722. font-size: 26rpx;
  723. color: #666;
  724. }
  725. .separator {
  726. margin: 0 10rpx;
  727. color: #ccc;
  728. }
  729. .check-mark {
  730. position: absolute;
  731. right: 0;
  732. top: 0;
  733. }
  734. .check-icon {
  735. width: 48rpx;
  736. height: 48rpx;
  737. }
  738. /* 状态标签 */
  739. .status-badge {
  740. position: absolute;
  741. top: 0;
  742. right: 0;
  743. font-size: 22rpx;
  744. padding: 4rpx 12rpx;
  745. border-radius: 0 16rpx 0 12rpx;
  746. font-weight: 500;
  747. z-index: 1;
  748. }
  749. .status-active-badge {
  750. background-color: #E6F7E6;
  751. color: #3BB44A;
  752. border-left: 1rpx solid rgba(59, 180, 74, 0.2);
  753. border-bottom: 1rpx solid rgba(59, 180, 74, 0.2);
  754. }
  755. .status-idle-badge {
  756. background-color: #F1F2F3;
  757. color: #909399;
  758. border-left: 1rpx solid rgba(144, 147, 153, 0.2);
  759. border-bottom: 1rpx solid rgba(144, 147, 153, 0.2);
  760. }
  761. .status-maintenance-badge {
  762. background-color: #FEF0F0;
  763. color: #F56C6C;
  764. border-left: 1rpx solid rgba(245, 108, 108, 0.2);
  765. border-bottom: 1rpx solid rgba(245, 108, 108, 0.2);
  766. }
  767. /* 地块统计信息 */
  768. .block-stats {
  769. display: flex;
  770. align-items: center;
  771. flex-wrap: wrap;
  772. border-top: 1rpx solid #F0F0F0;
  773. padding-top: 20rpx;
  774. }
  775. .stat-item {
  776. display: flex;
  777. align-items: center;
  778. margin-right: 24rpx;
  779. font-size: 26rpx;
  780. color: #666;
  781. }
  782. .stat-icon {
  783. width: 36rpx;
  784. height: 36rpx;
  785. margin-right: 8rpx;
  786. flex-shrink: 0;
  787. }
  788. .online-icon {
  789. /* 在线图标使用绿色 */
  790. filter: hue-rotate(120deg) saturate(1.2);
  791. }
  792. .alert-icon {
  793. /* 告警图标使用红色 */
  794. filter: hue-rotate(0deg) saturate(1.5);
  795. }
  796. .alert-text {
  797. color: #F56C6C;
  798. }
  799. /* 骨架屏 */
  800. .skeleton-container {
  801. display: flex;
  802. flex-direction: column;
  803. gap: 20rpx;
  804. }
  805. .skeleton-box {
  806. background-color: #FFFFFF;
  807. border-radius: 16rpx;
  808. padding: 20rpx;
  809. margin-bottom: 10rpx;
  810. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  811. animation: skeleton-loading 1.5s infinite;
  812. }
  813. @keyframes skeleton-loading {
  814. 0% {
  815. opacity: 0.7;
  816. }
  817. 50% {
  818. opacity: 0.5;
  819. }
  820. 100% {
  821. opacity: 0.7;
  822. }
  823. }
  824. .skeleton-header {
  825. display: flex;
  826. align-items: flex-start;
  827. }
  828. .skeleton-icon {
  829. width: 40rpx;
  830. height: 40rpx;
  831. background-color: #EEEEEE;
  832. border-radius: 8rpx;
  833. margin-right: 15rpx;
  834. }
  835. .skeleton-info {
  836. flex: 1;
  837. }
  838. .skeleton-title {
  839. width: 200rpx;
  840. height: 32rpx;
  841. background-color: #EEEEEE;
  842. margin-bottom: 10rpx;
  843. border-radius: 4rpx;
  844. }
  845. .skeleton-detail {
  846. width: 300rpx;
  847. height: 24rpx;
  848. background-color: #EEEEEE;
  849. border-radius: 4rpx;
  850. }
  851. .skeleton-stats {
  852. margin-top: 16rpx;
  853. padding-top: 16rpx;
  854. border-top: 1rpx solid #F5F5F5;
  855. height: 30rpx;
  856. background-color: #EEEEEE;
  857. border-radius: 4rpx;
  858. }
  859. /* 空状态 */
  860. .empty-state {
  861. display: flex;
  862. flex-direction: column;
  863. align-items: center;
  864. justify-content: center;
  865. padding: 60rpx 0;
  866. }
  867. .empty-image {
  868. width: 240rpx;
  869. height: 240rpx;
  870. margin-bottom: 20rpx;
  871. opacity: 0.7;
  872. }
  873. .empty-text {
  874. font-size: 32rpx;
  875. color: #666;
  876. font-weight: 500;
  877. margin-bottom: 10rpx;
  878. }
  879. .empty-subtext {
  880. font-size: 26rpx;
  881. color: #999;
  882. }
  883. /* 基础图标样式 */
  884. .iconfont {
  885. font-family: "iconfont" !important;
  886. font-style: normal;
  887. -webkit-font-smoothing: antialiased;
  888. -moz-osx-font-smoothing: grayscale;
  889. }
  890. /* 底部加载提示区域 */
  891. .loading-more {
  892. display: flex;
  893. justify-content: center;
  894. align-items: center;
  895. padding: 20rpx 0;
  896. background-color: #FFFFFF;
  897. border-top: 1px solid rgba(0, 0, 0, 0.03);
  898. }
  899. .loading-text {
  900. display: flex;
  901. align-items: center;
  902. font-size: 28rpx;
  903. color: #666;
  904. }
  905. .loading-icon {
  906. width: 40rpx;
  907. height: 40rpx;
  908. margin-right: 10rpx;
  909. background-color: #3BB44A;
  910. border-radius: 50%;
  911. animation: spin 1s linear infinite;
  912. }
  913. @keyframes spin {
  914. 0% {
  915. transform: rotate(0deg);
  916. }
  917. 100% {
  918. transform: rotate(360deg);
  919. }
  920. }
  921. .no-more-text {
  922. font-size: 28rpx;
  923. color: #999;
  924. margin-left: 10rpx;
  925. }
  926. </style>