detail.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. <template>
  2. <view class="device-detail">
  3. <view class="device-detail__header">
  4. <u-icon
  5. size="36"
  6. class="arrow-left"
  7. name="arrow-left"
  8. @click="handleBack"
  9. ></u-icon>
  10. {{ deviceInfo.name }}
  11. </view>
  12. <view class="operation" @click.stop="isShowOperation = !isShowOperation">操作</view>
  13. <view class="operation-container" v-if="isShowOperation" @click="closeOperationHandler">
  14. <view class="operation-background"></view>
  15. <view class="operation-content">
  16. <!-- <view class="operation-item" v-if="isShowPhoto" @click="handlePhotoClick">
  17. <image :src="photoIcon" class="operation-icon"></image>
  18. 拍照
  19. </view> -->
  20. <view class="operation-item" @click="handleServiceClick">
  21. <image :src="serviceIcon" class="operation-icon"></image>
  22. 维修
  23. </view>
  24. <!-- <view class="operation-item" @click="handleSettingClick">
  25. <image :src="settingIcon" class="operation-icon"></image>
  26. 设置
  27. </view> -->
  28. <!-- <view class="operation-item" @click="handleSimClick">
  29. <image :src="simIcon" class="operation-icon"></image>
  30. SIM卡
  31. </view> -->
  32. <view class="operation-item" @click="modification">
  33. <image :src="editIcon" class="operation-icon"></image>
  34. 修改
  35. </view>
  36. </view>
  37. </view>
  38. <view class="device-detail__body">
  39. <DeviceCard
  40. :dataSource="deviceInfo"
  41. :collectTime="time"
  42. :title="deviceInfo.name"
  43. :deviceType="deviceType"
  44. />
  45. <view class="tabs">
  46. <view class="tab-container" v-if="isShowTab">
  47. <view class="tab-item" :class="activeTab === 'viewImage'?'active':''" @click="handleTabClick('viewImage')">
  48. 图像数据
  49. </view>
  50. <view class="tab-item" :class="activeTab === 'pestAnalysis'?'active':''" @click="handleTabClick('pestAnalysis')">
  51. 鼠情分析
  52. </view>
  53. <!-- <view class="tab-item" :class="activeTab === 'aiAnalysis'?'active':''" @click="handleTabClick('aiAnalysis')">
  54. 设备预警
  55. </view> -->
  56. <!-- <view class="tab-item" :class="activeTab === 'deviceData'?'active':''" @click="handleTabClick('deviceData')">
  57. 设备数据
  58. </view> -->
  59. </view>
  60. <view class="select-timer-container">
  61. <view class="select-year">
  62. <view class="select-year-item" @click="showPicker = true">
  63. {{ currentYear }}
  64. <u-icon name="arrow-down" size="18" class="arrow-down"></u-icon>
  65. </view>
  66. </view>
  67. <view class="tabs-timer-container" @click="showCalendar">
  68. <block v-if="isRangeDate">
  69. <view class="tabs-timer-item">
  70. {{startDate}}
  71. </view>
  72. 至
  73. <view class="tabs-timer-item">
  74. {{endDate}}
  75. </view>
  76. </block>
  77. <block v-else>
  78. <view class="tabs-timer-item">
  79. {{imageDate}}
  80. </view>
  81. </block>
  82. <u-icon name="calendar" size="36" class="calendar-icon"></u-icon>
  83. </view>
  84. </view>
  85. </view>
  86. <view v-show="activeTab === 'pestAnalysis'" class="tab-content">
  87. <PestDiscern
  88. :total="total"
  89. :pest_order="pest_order"
  90. />
  91. <RodentAnalysis :active="activeTab === 'pestAnalysis'" :device-id="deviceInfo.id" :start="analysisStart" :end="analysisEnd" />
  92. <!-- <PestArchive
  93. :pest_info="pestInfo"
  94. /> -->
  95. <!-- <view v-if="!pests.length">
  96. <u-empty text="暂无数据"></u-empty>
  97. </view> -->
  98. </view>
  99. <view class="tabs" v-if="activeTab === 'viewImage'">
  100. <view class="tab-container">
  101. <view class="tab-item" :class="imageTab === 'viewImage'?'active':''" @click="handleImageTabClick('viewImage')">
  102. 监测图像(前后左右)
  103. </view>
  104. <view class="tab-item" :class="imageTab === 'downImage'?'active':''" @click="handleImageTabClick('downImage')">
  105. 监测图像(下)
  106. </view>
  107. </view>
  108. <view v-show="imageTab === 'viewImage'">
  109. <!-- 实现下拉加载 -->
  110. <scroll-view class="scroll-view" scroll-y style="height: 60vh;" @scrolltolower="handleReachBottom">
  111. <photoImage
  112. :images="imageList"
  113. :pestList="pestList"
  114. :disableShow="disableShow"
  115. :ding_one_device_id="ding_one_device_id"
  116. :ding_three_device_id="ding_three_device_id"
  117. :ding_two_device_id="ding_two_device_id"
  118. @changeTab="changeTab"
  119. :currentYear="currentYear"
  120. :deviceInfo="deviceInfo"
  121. />
  122. </scroll-view>
  123. </view>
  124. <view v-show="imageTab === 'downImage'">
  125. <scroll-view class="scroll-view" scroll-y style="height: 60vh;">
  126. <downImage :images="downImageList" :deviceInfo="deviceInfo" />
  127. </scroll-view>
  128. </view>
  129. </view>
  130. <view v-if="activeTab === 'aiAnalysis'">
  131. <AiChat
  132. :pestMessage="pestMessage"
  133. />
  134. </view>
  135. <view v-if="activeTab === 'deviceData'">
  136. <DeviceData
  137. :deviceInfo="deviceInfo"
  138. :polylineList="polylineList"
  139. :deviceHistoryList="deviceHistoryList"
  140. :totalPage="totalPage"
  141. :currentPage="page"
  142. :page_size="page_size"
  143. @prevPage="prevPage"
  144. @nextPage="nextPage"
  145. />
  146. </view>
  147. </view>
  148. <u-calendar v-model="show" :mode="calendarMode" range-color="#999" btn-type="success" active-bg-color="#0BBC58" range-bg-color="rgba(11,188,88,0.13)" @change="handleChange" :max-date="maxDate" :min-date="minDate"></u-calendar>
  149. <u-picker v-model="showPicker" mode="selector" :range="selectorRange" range-key="id" :default-selector="[0]" @confirm="confirmHandler"></u-picker>
  150. </view>
  151. </template>
  152. <script>
  153. import DeviceCard from './components/DeviceCard.vue';
  154. import PestDiscern from './components/pestDiscern.vue';
  155. import PestArchive from './components/pestArchive.vue';
  156. import photoImage from './components/photoImage.vue';
  157. import downImage from './components/downImage.vue';
  158. import DeviceData from './components/deviceData.vue';
  159. import AiChat from './components/aiChat.vue';
  160. import RodentAnalysis from './components/rodentAnalysis.vue';
  161. export default {
  162. components: {
  163. DeviceCard,
  164. PestDiscern,
  165. AiChat,
  166. PestArchive,
  167. photoImage,
  168. downImage,
  169. DeviceData,
  170. RodentAnalysis,
  171. },
  172. data(){
  173. return {
  174. isShowTab:false,
  175. showPicker: false,
  176. disableShow: false,
  177. isShowOperation: false,
  178. photoIcon:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/photoIcon.png',
  179. editIcon:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/editIcon.png',
  180. serviceIcon:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/serviceIcon.png',
  181. simIcon:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/simIcon.png',
  182. settingIcon:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/settingIcon.png',
  183. totalPage:0,
  184. currentYear: new Date().getFullYear(),
  185. selectorRange: [],
  186. maxDate: this.formatDate(new Date()),
  187. minDate: this.formatDate(new Date(new Date().getFullYear(), 0, 1)),
  188. show: false,
  189. showSim: false,
  190. // 鼠情分析/设备数据用的时间区间:结束为今天,开始为7天前 格式2026-01-01
  191. startDate: this.formatDate(new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000)),
  192. endDate: this.formatDate(new Date()),
  193. // 图像数据用单日,默认今天(onLoad会按time_folder接口更新为最近有数据的日期)
  194. imageDate: this.formatDate(new Date()),
  195. imageList: [],
  196. downImageList: [],
  197. pest_order:{},
  198. pestMessage:'',
  199. deviceInfo: {},
  200. time: '',
  201. activeTab: 'pestAnalysis',
  202. // 图像数据内的子切换:viewImage-前后左右 downImage-下
  203. imageTab: 'viewImage',
  204. deviceType: '',
  205. camera_id: '',
  206. location: '',
  207. total: 0,
  208. imgTotal: 0,
  209. page:1,
  210. is_pest:'',
  211. page_size:24,
  212. pestList:[],
  213. pests:[],
  214. polylineList:[],
  215. isShowPhoto:false,
  216. deviceHistoryList:[],
  217. ding_one_device_id:'',
  218. ding_three_device_id:'',
  219. ding_two_device_id:''
  220. }
  221. },
  222. computed: {
  223. // 鼠情分析/设备数据用区间选择,图像数据用单日选择
  224. isRangeDate() {
  225. return this.activeTab === 'pestAnalysis' || this.activeTab === 'deviceData';
  226. },
  227. calendarMode() {
  228. return this.isRangeDate ? 'range' : 'date';
  229. },
  230. // 鼠情分析查询范围(秒级时间戳)
  231. analysisStart() {
  232. return this.startDate ? new Date(this.startDate + ' 00:00:00').getTime() / 1000 : 0;
  233. },
  234. analysisEnd() {
  235. return this.endDate ? new Date(this.endDate + ' 23:59:59').getTime() / 1000 : 0;
  236. }
  237. },
  238. async onLoad(options){
  239. this.deviceInfo = JSON.parse(options.info);
  240. const { ding_one_device_id, ding_three_device_id, ding_two_device_id } = this.deviceInfo;
  241. this.ding_one_device_id = ding_one_device_id;
  242. this.ding_three_device_id = ding_three_device_id;
  243. this.ding_two_device_id = ding_two_device_id;
  244. // 先取有数据的日期,默认选中最近的一天,再加载各模块数据
  245. await this.initDateFolder();
  246. this.getPestAnalysis();
  247. this.isShow();
  248. const currentYear = new Date().getFullYear();
  249. this.selectorRange = [];
  250. for(let i = 0;i<50;i++){
  251. const item = {
  252. label: currentYear - i,
  253. id: currentYear - i
  254. }
  255. this.selectorRange.push(item);
  256. }
  257. },
  258. methods: {
  259. formatePestMessage(data) {
  260. if (data.length === 0) {
  261. this.pestMessage = '';
  262. return;
  263. }
  264. this.pestMessage = `当前设备位置为${this.deviceInfo.address},在${this.startDate}至${this.endDate} 监测到的害虫如下:`;
  265. data.map((item, index) => {
  266. if(index === data.length - 1){
  267. this.pestMessage += `${item.name}:${item.value}头.`;
  268. } else {
  269. this.pestMessage += `${item.name}:${item.value}头,`;
  270. }
  271. });
  272. },
  273. handleReachBottom(){
  274. if (this.activeTab === 'viewImage') {
  275. if(this.imageList.length >= this.imgTotal){
  276. return
  277. }
  278. this.initImageList(true);
  279. }
  280. },
  281. handleSimClick(){
  282. // this.showSim = true;
  283. //`/pages/deviceDetails/weatherStation/${type}?deviceInfo=${encodeURIComponent(JSON.stringify(this.deviceInfo))}`
  284. uni.navigateTo({
  285. url:
  286. '/pages/deviceDetails/weatherStation/simDetail?deviceInfo=' +
  287. encodeURIComponent(JSON.stringify(this.deviceInfo))
  288. });
  289. },
  290. modification() {
  291. uni.navigateTo({
  292. url:
  293. '/pages/equipList2/seabox/modification?data=' +
  294. JSON.stringify(this.deviceInfo) +
  295. '&id=' +
  296. this.deviceInfo.type,
  297. });
  298. },
  299. async handlePhotoClick(){
  300. const res = await this.$myRequest({
  301. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  302. method: 'POST',
  303. data: {
  304. device_type_id: this.deviceInfo.type,
  305. d_id: this.deviceInfo.d_id,
  306. cmd: 'takephoto',
  307. },
  308. });
  309. if(res){
  310. this.$u.toast('拍照成功')
  311. }
  312. },
  313. handleServiceClick(){
  314. uni.navigateTo({
  315. url: '/pages/afterSale/addafter?d_id=' + this.deviceInfo.d_id +'&device_id='+this.deviceInfo.id + '&device_type=' + this.deviceInfo.type,
  316. })
  317. },
  318. handleSettingClick(){
  319. uni.navigateTo({
  320. url: '/pages/shuHai1/deviceControl?deviceId=' + this.deviceInfo.id + '&d_id=' + this.deviceInfo.d_id + '&name=' + encodeURIComponent(this.deviceInfo.name || ''),
  321. });
  322. },
  323. closeOperationHandler(){
  324. this.isShowOperation = false;
  325. },
  326. isShow(){
  327. // disable == 0 或者 device_model == 15 表示不可以查看
  328. if(!this.deviceInfo.d_id){
  329. return false;
  330. }
  331. let showStatus = true;
  332. if(this.deviceInfo.device_model == 15 || this.deviceInfo.device_model == 12){
  333. showStatus = false;
  334. }
  335. if(showStatus){
  336. this.activeTab = 'pestAnalysis';
  337. }else{
  338. this.activeTab = 'deviceData';
  339. }
  340. this.initAction();
  341. this.isShowTab = showStatus;
  342. if(this.deviceInfo.disable == 0){
  343. this.disableShow = false;
  344. if(showStatus){
  345. this.activeTab = 'viewImage';
  346. this.handleTabClick('viewImage');
  347. }
  348. }else{
  349. this.disableShow = true;
  350. }
  351. },
  352. prevPage(e){
  353. if(e == 1){
  354. return
  355. }
  356. this.page = e-=1;
  357. this.getDeviceHistoryData();
  358. },
  359. nextPage(e){
  360. if(e * this.page_size >= this.totalPage){
  361. return
  362. }
  363. this.page = e+=1;
  364. this.getDeviceHistoryData();
  365. },
  366. changeTab(camera_id){
  367. this.camera_id = camera_id;
  368. this.initImageList();
  369. },
  370. confirmHandler(e){
  371. this.currentYear = this.selectorRange[e].id;
  372. if(this.calendarMode === 'range'){
  373. // 区间选择:结束日期保持月日仅切换年份,开始日期为结束日期前7天
  374. const timeDate = this.currentYear + '-' + this.endDate.split('-')[1] + '-' + this.endDate.split('-')[2];
  375. this.endDate = this.formatDate(new Date(timeDate));
  376. this.startDate = this.formatDate(new Date(new Date(this.endDate).getTime() - 7 * 24 * 60 * 60 * 1000));
  377. }else{
  378. // 单日选择:保持月日不变,仅切换年份
  379. const timeDate = this.currentYear + '-' + this.imageDate.split('-')[1] + '-' + this.imageDate.split('-')[2];
  380. this.imageDate = this.formatDate(new Date(timeDate));
  381. }
  382. if(this.currentYear == new Date().getFullYear()){
  383. this.maxDate = this.formatDate(new Date());
  384. this.minDate = this.formatDate(new Date(new Date().getFullYear(), 0, 1));
  385. }else{
  386. this.maxDate = this.formatDate(new Date(this.currentYear, 11, 31));
  387. this.minDate = this.formatDate(new Date(this.currentYear, 0, 1));
  388. }
  389. this.initAction();
  390. this.showPicker = false;
  391. },
  392. // 格式化日期为YYYY-MM-DD格式,月份和日期小于10时前面加0
  393. formatDate(date) {
  394. const year = date.getFullYear();
  395. const month = String(date.getMonth() + 1).padStart(2, '0');
  396. const day = String(date.getDate()).padStart(2, '0');
  397. return `${year}-${month}-${day}`;
  398. },
  399. handleChange(e){
  400. if(this.calendarMode === 'range'){
  401. this.startDate = e.startDate;
  402. this.endDate = e.endDate;
  403. }else{
  404. this.imageDate = e.result;
  405. }
  406. this.page = 1;
  407. this.initAction();
  408. },
  409. showCalendar(){
  410. this.show = true;
  411. },
  412. handleBack() {
  413. uni.navigateBack({
  414. delta: 1
  415. });
  416. },
  417. initAction(){
  418. // this.pest_order =
  419. if(this.activeTab === 'pestAnalysis'){
  420. this.getPestAnalysis();
  421. }else if(this.activeTab === 'aiAnalysis'){
  422. this.getAiAnalysis();
  423. }else if(this.activeTab === 'viewImage'){
  424. if(this.imageTab === 'viewImage'){
  425. this.initPest();
  426. this.initImageList();
  427. }else{
  428. this.initDownImageList();
  429. }
  430. }else if(this.activeTab === 'deviceData'){
  431. this.getPolylineData();
  432. this.getDeviceHistoryData();
  433. }
  434. },
  435. getAiAnalysis(){
  436. },
  437. handleTabClick(tab) {
  438. this.activeTab = tab;
  439. this.initAction();
  440. },
  441. // 图像数据内的子切换,不影响上方 图像数据/鼠情分析 的选中状态
  442. handleImageTabClick(tab) {
  443. if(this.imageTab === tab){
  444. return
  445. }
  446. this.imageTab = tab;
  447. this.initAction();
  448. },
  449. async initImageList(isLoadMore){
  450. if(isLoadMore){
  451. this.page++;
  452. }
  453. uni.showLoading({
  454. title: '加载中',
  455. })
  456. const res = await this.$myRequest({
  457. url: '/api/api_gateway?method=forecast.shuhai.shuhai_group_imgs',
  458. method: 'POST',
  459. data: {
  460. device_id: this.deviceInfo.id,
  461. start: new Date(this.imageDate + ' 00:00:00').getTime()/1000,// 秒级时间戳
  462. end: new Date(this.imageDate + ' 23:59:59').getTime()/1000,// 秒级时间戳
  463. page: this.page,
  464. page_number: this.page_size,
  465. },
  466. });
  467. const data = res?.data || [];
  468. uni.hideLoading();
  469. this.imgTotal = res?.total || 0;
  470. if (isLoadMore) {
  471. this.imageList = [...this.imageList, ...data];
  472. } else {
  473. this.imageList = data;
  474. }
  475. },
  476. async initDownImageList(){
  477. uni.showLoading({
  478. title: '加载中',
  479. })
  480. const res = await this.$myRequest({
  481. url: '/api/api_gateway?method=forecast.shuhai.shuhai_down_imgs',
  482. method: 'POST',
  483. data: {
  484. device_id: this.deviceInfo.id,
  485. start: new Date(this.imageDate + ' 00:00:00').getTime()/1000,// 秒级时间戳
  486. end: new Date(this.imageDate + ' 23:59:59').getTime()/1000,// 秒级时间戳
  487. },
  488. });
  489. uni.hideLoading();
  490. this.downImageList = res?.data || [];
  491. },
  492. // 获取有数据的日期,默认选中最近的一天
  493. async initDateFolder(){
  494. const res = await this.$myRequest({
  495. url: '/api/api_gateway?method=forecast.shuhai.shuhai_time_folder',
  496. method: 'POST',
  497. data: {
  498. device_id: this.deviceInfo.id,
  499. },
  500. });
  501. // 返回结构:[{ "2026": { "01": [3] } }, { "2025": { "12": [13], ... } }]
  502. const folders = res?.data || [];
  503. const dates = [];
  504. folders.forEach(yearItem => {
  505. for(const year in yearItem){
  506. const months = yearItem[year] || {};
  507. for(const month in months){
  508. (months[month] || []).forEach(day => {
  509. dates.push(`${year}-${month}-${String(day).padStart(2, '0')}`);
  510. });
  511. }
  512. }
  513. });
  514. if(!dates.length){
  515. return;
  516. }
  517. // YYYY-MM-DD 格式可直接按字符串比较
  518. dates.sort((a, b) => b.localeCompare(a));
  519. const today = this.formatDate(new Date());
  520. // 日历最大可选今天,数据日期超过今天时取今天
  521. this.imageDate = dates[0] > today ? today : dates[0];
  522. },
  523. async initPest(){
  524. const res = await this.$myRequest({
  525. url: '/api/api_gateway?method=forecast.new_cbd.pest_type_list',
  526. method: 'POST',
  527. data:{
  528. page:1,
  529. page_size:999999,
  530. device_id: this.deviceInfo.id,
  531. identify_model: 'B',
  532. time_begin: this.formatDate(new Date(this.imageDate)) + ' 00:00:00',// 格式化开始时间YYYY-MM-DD HH:MM:SS
  533. time_end: this.formatDate(new Date(this.imageDate)) + ' 23:59:59',// 格式化结束时间YYYY-MM-DD HH:MM:SS
  534. },
  535. });
  536. const data = res?.data || [];
  537. this.pestList = data
  538. },
  539. async getPolylineData(){
  540. const res = await this.$myRequest({
  541. url: '/api/api_gateway?method=forecast.shuhai.shuhai_two_camera_polyline_data',
  542. method: 'POST',
  543. data: {
  544. device_id: this.deviceInfo.id,
  545. start_time: new Date(this.startDate + ' 00:00:00').getTime()/1000,// 秒级时间戳
  546. end_time: new Date(this.endDate + ' 23:59:59').getTime()/1000,
  547. },
  548. });
  549. const data = res || [];
  550. this.polylineList = data
  551. },
  552. async getDeviceHistoryData(){
  553. const res = await this.$myRequest({
  554. url: '/api/api_gateway?method=forecast.shuhai.shuhai_two_camera_device_data',
  555. method: 'POST',
  556. data: {
  557. device_id: this.deviceInfo.id,
  558. start_time: new Date(this.startDate + ' 00:00:00').getTime()/1000,// 秒级时间戳
  559. end_time: new Date(this.endDate + ' 23:59:59').getTime()/1000,
  560. page: this.page,
  561. page_size: this.page_size,
  562. },
  563. });
  564. const data = res || [];
  565. // 接口未返回总条数,按返回条数估算:不足一页视为最后一页
  566. if (data.length < this.page_size) {
  567. this.totalPage = (this.page - 1) * this.page_size + data.length;
  568. } else {
  569. this.totalPage = Math.max(this.totalPage, (this.page + 1) * this.page_size);
  570. }
  571. this.deviceHistoryList = data
  572. },
  573. async getPestAnalysis(){
  574. const res = await this.$myRequest({
  575. url: '/api/api_gateway?method=forecast.shuhai.shuhai_analysis',
  576. method: 'POST',
  577. data: {
  578. device_id: this.deviceInfo.id,
  579. start: this.analysisStart,// 秒级时间戳
  580. end: this.analysisEnd,// 秒级时间戳
  581. },
  582. });
  583. // total:[{name,value}] → pest_order:{name:value},供识别统计/物种图表tabs使用
  584. const totalList = res?.total || [];
  585. const pest_order = {};
  586. totalList.forEach(item => {
  587. pest_order[item.name] = item.value || 0;
  588. });
  589. const total = totalList.reduce((sum, item) => sum + (item.value || 0), 0);
  590. this.pests = [];
  591. for(let key in pest_order){
  592. this.pests.push({
  593. name: key,
  594. percent: total ? (pest_order[key] / total) * 100 : 0
  595. })
  596. }
  597. this.pest_order = pest_order;
  598. this.formatePestMessage([...totalList].reverse());
  599. this.total = total;
  600. }
  601. }
  602. }
  603. </script>
  604. <style scoped lang="scss">
  605. ::v-deep .u-calendar__action{
  606. display:flex;
  607. justify-content: space-between;
  608. }
  609. ::v-deep .u-hover-class{
  610. .u-calendar__content__item__inner{
  611. color:#aaa !important;
  612. }
  613. }
  614. .operation-container{
  615. position: fixed;
  616. right: 0;
  617. top: 0;
  618. width: 100%;
  619. height: 100%;
  620. z-index: 99;
  621. }
  622. .operation{
  623. position: fixed;
  624. top: 260rpx;
  625. right: 0;
  626. z-index: 999;
  627. width:48rpx;
  628. height: 100rpx;
  629. line-height: 50rpx;
  630. border-radius: 8px 0 0 8px;
  631. border-top: 4rpx solid #FFF;
  632. border-bottom: 4rpx solid #FFF;
  633. border-left: 4rpx solid #FFF;
  634. background: #dddfe6a3;
  635. color: #515153;
  636. text-align: center;
  637. font-family: "Source Han Sans CN VF";
  638. font-size: 24rpx;
  639. font-weight: 500;
  640. writing-mode: vertical-rl;
  641. }
  642. .operation-background{
  643. position: fixed;
  644. right: 0;
  645. top: 0;
  646. width: 100%;
  647. height: 100%;
  648. z-index: 998;
  649. background: #00000040;
  650. }
  651. .operation-content{
  652. position: fixed;
  653. top: 240rpx;
  654. right: 80rpx;
  655. height: 126rpx;
  656. display: flex;
  657. padding: 16rpx 32rpx;
  658. align-items: center;
  659. gap: 64rpx;
  660. z-index: 999;
  661. border-radius: 32rpx;
  662. border: 2rpx solid #FFF;
  663. background: #FFF;
  664. backdrop-filter: blur(8rpx);
  665. .operation-item{
  666. display: flex;
  667. flex-direction: column;
  668. align-items: center;
  669. justify-content: center;
  670. color: #333333;
  671. text-align: center;
  672. font-family: "Source Han Sans CN VF";
  673. font-size: 24rpx;
  674. font-weight: 400;
  675. }
  676. .operation-icon{
  677. width: 58rpx;
  678. height: 58rpx;
  679. }
  680. }
  681. .device-detail {
  682. display: flex;
  683. width: 100%;
  684. min-height: calc(100vh - 112rpx);
  685. padding-top: 112rpx;
  686. flex-direction: column;
  687. align-items: center;
  688. background: linear-gradient(180deg, #ffffff00 0%, #F5F6FA 23.64%, #F5F6FA 100%), linear-gradient(102deg, #BFEADD 6.77%, #B8F1E7 40.15%, #B9EEF5 84.02%);
  689. .device-detail__header {
  690. width: 100%;
  691. font-size: 28rpx;
  692. color: #999;
  693. color: #042118;
  694. font-family: 'Source Han Sans CN VF';
  695. font-weight: 700;
  696. position: relative;
  697. text-align: center;
  698. .arrow-left {
  699. position: absolute;
  700. left: 32rpx;
  701. margin-right: 12rpx;
  702. }
  703. }
  704. .device-detail__body {
  705. width: calc(100% - 64rpx);
  706. margin: 0 auto;
  707. border-radius: 16rpx;
  708. overflow-x: hidden;
  709. overflow-y: auto;
  710. // 隐藏滚动条
  711. -ms-overflow-style: none;
  712. scrollbar-width: none;
  713. }
  714. .tab-content{
  715. width: 100%;
  716. padding-bottom: 32rpx;
  717. }
  718. .tabs {
  719. background: #ffffff;
  720. margin: 24rpx 0;
  721. border-radius: 16rpx;
  722. padding: 16rpx 0;
  723. padding-top: 0;
  724. .tab-container{
  725. display: flex;
  726. width: 100%;
  727. height: 88rpx;
  728. line-height: 88rpx;
  729. text-align: center;
  730. font-size: 28rpx;
  731. font-weight: 700;
  732. color: #042118;
  733. font-family: 'Source Han Sans CN VF';
  734. }
  735. .select-timer-container{
  736. display:flex;
  737. align-items: center;
  738. padding-left: 32rpx;
  739. .select-year{
  740. width: 110rpx;
  741. text-align: center;
  742. height: 64rpx;
  743. border-radius: 32rpx;
  744. font-family: 'Source Han Sans CN VF';
  745. line-height: 64rpx;
  746. background: #F1F4F8;
  747. padding: 0 32rpx;
  748. .select-year-item{
  749. color: #656565;
  750. font-size: 24rpx;
  751. display: flex;
  752. align-items: center;
  753. justify-content: space-around;
  754. }
  755. }
  756. }
  757. .tabs-timer-container{
  758. display: flex;
  759. align-items: center;
  760. justify-content: center;
  761. width: calc(100% - 206rpx);
  762. height: 64rpx;
  763. line-height: 64rpx;
  764. text-align: center;
  765. font-size: 24rpx;
  766. font-weight: 500;
  767. font-family: 'Source Han Sans CN VF';
  768. border-radius: 32rpx;
  769. background: #F1F4F8;
  770. padding: 0 32rpx;
  771. color: #656565;
  772. margin: 16rpx;
  773. position: relative;
  774. white-space: nowrap;
  775. .tabs-timer-item{
  776. width: auto;
  777. flex-shrink: 0;
  778. color: #656565;
  779. text-align: center;
  780. font-family: "Source Han Sans CN VF";
  781. font-size: 24rpx;
  782. font-weight: 400;
  783. }
  784. .calendar-icon{
  785. margin-left: 24rpx;
  786. flex-shrink: 0;
  787. }
  788. }
  789. .tab-item {
  790. flex: 1;
  791. color: #999999;
  792. text-align: center;
  793. font-family: "Source Han Sans CN VF";
  794. font-size: 28rpx;
  795. font-weight: 400;
  796. }
  797. .active{
  798. position: relative;
  799. color: #303133;
  800. text-align: center;
  801. font-family: "Source Han Sans CN VF";
  802. font-size: 28rpx;
  803. font-weight: 700;
  804. &::after {
  805. content: '';
  806. position: absolute;
  807. bottom: 0;
  808. left: 50%;
  809. -webkit-transform: translateX(-50%);
  810. transform: translateX(-50%);
  811. width: 36rpx;
  812. height: 36rpx;
  813. border: 6rpx solid #0BBC58;
  814. border-radius: 50%;
  815. border-color: transparent;
  816. border-bottom-color: #0BBC58;
  817. }
  818. }
  819. }
  820. }
  821. </style>