detail.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  1. <template>
  2. <view class="bigBox">
  3. <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#14A478"></u-tabs>
  4. <view class="currentBox">
  5. <view v-if="current == 0" class="infoBox">
  6. <view :class="['info',equipInfo.is_online==1?'on':'off']">
  7. <p @click="copy(equipInfo.imei)">设备ID:{{equipInfo.imei}}
  8. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode=""
  9. class="tishi">
  10. </image>
  11. </p>
  12. <p>设备名称:{{equipInfo.device_name==""?"无":equipInfo.device_name}}</p>
  13. <p>最新上报时间:{{equipInfo.uptime | timeFormat}}</p>
  14. <p>最新地址:{{equipInfo.address}}</p>
  15. <p class="fillin">诱芯名称:{{equipInfo.decoy}}</p>
  16. <!-- <p @click="glass_show=true">诱芯更换时间:<span style="margin:0 20rpx;">{{yxchangetime}}</span><u-icon
  17. name="edit-pen" color="#f0ad4e" size="28"></u-icon></p> -->
  18. <p>诱芯到期时间:{{equipInfo.xy_expire}}</p>
  19. <!-- <u-calendar v-model="glass_show" mode="date" :max-date="date" @change="timeChange"></u-calendar>
  20. <u-calendar v-model="glass_showtwo" mode="date" :max-date="date" @change="timeChangetwo"></u-calendar> -->
  21. </view>
  22. <view class="cardInfo">
  23. <text class="title">设备控制</text>
  24. <view class="controlCard">
  25. <view class="preBtn" v-for="btn in btnList" :key="btn.class">
  26. <view :class="['btnBox' , btn.class]" @click="btnFun(btn.code)">
  27. <text :class="btn.icon"></text>
  28. </view>
  29. <view>{{btn.text}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="cardInfo">
  34. <text class="title">监测数据</text>
  35. <view class="controlCard noBg">
  36. <view class="fleBox">
  37. <view class="preInfo" v-for="btn in dataList" :key="btn.icon">
  38. <view class="btnBox">
  39. <text :class="btn.icon"></text>
  40. </view>
  41. <view class="textBox">
  42. <view>
  43. {{newDataObj[btn.unit]}}
  44. </view>
  45. <view class="name">{{btn.text}}</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="cardInfo">
  52. <text class="title">设备信息</text>
  53. <view class="controlCard noBg">
  54. <u-cell-group class="widthSet">
  55. <u-cell-item v-for="btn in deviceDataList" :key="btn.icon" :title="btn.text"
  56. :value="deviceObj[btn.key]" :arrow="false" :border-bottom="true"></u-cell-item>
  57. </u-cell-group>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 数据统计 -->
  62. <view v-if="current == 1" class="infoBox">
  63. <view class="cardInfo">
  64. <text class="title">统计数据</text>
  65. <view class="chartBox">
  66. <view class="timeBox">
  67. <u-icon name="calendar" size="30" class="iconBox"></u-icon>
  68. <view class="text" @click="showRangeTime = true">{{photoTimeRangeText}}</view>
  69. <u-icon name="arrow-right" v-if="photoTimeRangeText == '请选择日期'"></u-icon>
  70. <u-icon name="close" v-else @click="clearTimeFun('chart')"></u-icon>
  71. <u-calendar v-model="showRangeTime" mode="range" @change="(e) => changePhotoTime(e, 'chart')"></u-calendar>
  72. </view>
  73. <canvas v-if="showCanvas && !showRangeTime" canvas-id="canvasColumnA" id="canvasColumnA" class="charts"
  74. @touchstart="touchLineA($event)" @touchmove="moveLineA($event)" @touchend="touchEndLineA($event)"
  75. disable-scroll=true
  76. :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}">
  77. </canvas>
  78. <view class="noEmpty" v-else>
  79. 暂无数据
  80. </view>
  81. </view>
  82. </view>
  83. <view class="cardInfo">
  84. <text class="title">虫情分析</text>
  85. <view class="chartBox">
  86. <view class="pestInfo">
  87. <view class="pest">
  88. <text>害虫种类</text>
  89. <text class="name">{{analyInfo.decoy}}</text>
  90. </view>
  91. <view class="pest">
  92. <text>日杀虫数量</text>
  93. <text class="name">{{analyInfo.count}}头</text>
  94. </view>
  95. <view class="pest">
  96. <text>处理意见</text>
  97. <text class="name">当前害虫情况正常,请继续监测。</text>
  98. </view>
  99. </view>
  100. <view class="pestStatus">
  101. <view class="block active">
  102. <view class="iconBox green">
  103. <text class="yficonfont icon-small"></text>
  104. </view>
  105. <view class="blueText">
  106. <view>平静期</view>
  107. <view>0-30</view>
  108. </view>
  109. </view>
  110. <view class="block">
  111. <view class="iconBox yellow">
  112. <text class="yficonfont icon-middle"></text>
  113. </view>
  114. <view class="yellowText">
  115. <view>始发期</view>
  116. <view>30-60</view>
  117. </view>
  118. </view>
  119. <view class="block">
  120. <view class="iconBox danger">
  121. <text class="yficonfont icon-most"></text>
  122. </view>
  123. <view class="redText">
  124. <view>爆发期</view>
  125. <view>≥60</view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 图片列表 -->
  133. <view v-if="current == 2" class="infoBox">
  134. <view class="imgList">
  135. <view class="preImg" v-for="(img, index) in photoList" :key="img.addtime">
  136. <text class="text">{{img.addtime}}</text>
  137. <u-image width="100%" height="226rpx" :src="img.addr" @click="examine(index)"></u-image>
  138. </view>
  139. <u-loadmore class="loadBox" :status="loadStatus" :icon-type="iconType" :load-text="loadText"
  140. @loadmore="loadMore" />
  141. </view>
  142. <view class="timeBox">
  143. <u-icon name="calendar" size="30" class="iconBox"></u-icon>
  144. <view class="text" @click="showRangeTime = true">{{photoTimeRangeText}}</view>
  145. <u-icon name="arrow-right" v-if="photoTimeRangeText == '请选择日期'"></u-icon>
  146. <u-icon name="close" v-else @click="clearTimeFun('photo')"></u-icon>
  147. <u-calendar v-if="showRangeTime" v-model="showRangeTime" mode="range" @change="e => changePhotoTime(e, 'photo')"></u-calendar>
  148. </view>
  149. </view>
  150. <!-- 设备控制 -->
  151. <view v-if="current == 3" class="bgColor">
  152. <u-form :model="equipContrlForm1" :label-width="180">
  153. <view class="" v-if="myuser_type">
  154. <u-divider>管理员操作</u-divider>
  155. <u-form-item label="升级文件地址" :label-width="220">
  156. <u-input v-model="ota_url" />
  157. </u-form-item>
  158. <u-button size="mini" type="primary" @click="equipBtnControl('reboot')">重启</u-button>
  159. <u-button size="mini" class="btn" type="primary"
  160. @click="equipBtnControl('update')">升级</u-button>
  161. <u-divider>设备控制</u-divider>
  162. </view>
  163. <u-form-item label="设备名称"><u-input v-model="equipContrlForm1.devname" /></u-form-item>
  164. <u-form-item label="高压包开关状态" :label-width="240">
  165. <u-radio-group v-model="equipContrlForm1.dev_work_onoff">
  166. <u-radio :name="1">开</u-radio>
  167. <u-radio :name="0">关</u-radio>
  168. </u-radio-group>
  169. </u-form-item>
  170. <u-form-item label="工作模式" :label-width="240">
  171. <u-radio-group v-model="equipContrlForm1.dev_work_mode">
  172. <u-radio :name="1">自动</u-radio>
  173. <u-radio :name="2">手动</u-radio>
  174. <u-radio :name="3">定时</u-radio>
  175. </u-radio-group>
  176. </u-form-item>
  177. <u-form-item label="定时时长" :label-width="240">
  178. <text @click="equipContrlForm1.show_st= true">{{equipContrlForm1.st}}</text>-
  179. <text @click="equipContrlForm1.show_et= true">{{equipContrlForm1.et}}</text>
  180. <u-picker mode="time" v-model="equipContrlForm1.show_st" :default-time="equipContrlForm1.st"
  181. :params="params" @confirm="(e) => changeControlTime(e, 'st')"></u-picker>
  182. <u-picker mode="time" v-model="equipContrlForm1.show_et" :default-time="equipContrlForm1.et"
  183. :params="params" @confirm="(e) => changeControlTime(e, 'et')"></u-picker>
  184. </u-form-item>
  185. <u-form-item label="SIM卡号" :label-width="200">
  186. <u-input v-model="equipContrlForm1.sim" />
  187. </u-form-item>
  188. <u-form-item label="心跳间隔(S)" :label-width="200">
  189. <u-input v-model="equipContrlForm1.heart_time" type="number" />
  190. </u-form-item>
  191. <u-form-item label="太阳能电压阈值(V)" :label-width="280">
  192. <u-input v-model="equipContrlForm1.solar_threshold" type="number" />
  193. </u-form-item>
  194. <u-form-item label="太阳能电压最大值(V)" :label-width="300">
  195. <u-input v-model="equipContrlForm1.solarmax" type="number" />
  196. </u-form-item>
  197. <u-form-item label="数据上传频率(min)" :label-width="300">
  198. <u-input v-model="equipContrlForm1.upload_time" type="number" />
  199. </u-form-item>
  200. <u-button size="medium " type="primary" @click="equipControlSubm">保存</u-button>
  201. </u-form>
  202. </view>
  203. <!-- 拍照定时 -->
  204. <u-modal v-model="photoTimeLayer" width="90%" :async-close="true" :show-cancel-button="true"
  205. @confirm="devicePhotoTime">
  206. <view class="slot-content">
  207. <view class="expireBox">
  208. <u-form>
  209. <u-form-item :label="`时间${index + 1}`" :label-width="180"
  210. v-for="(time, index) in photoTimeArray" :key="time.key">
  211. <text @click="time.show = true">{{time.value}}</text>
  212. <u-button size="mini" type="error" class="delBtn"
  213. @click="removeTime(index)">删除</u-button>
  214. <u-picker mode="time" v-model="time.show" :default-time="time.value" :params="params"
  215. @confirm="(e) => changeSnapTime(e, time.key, index)"></u-picker>
  216. </u-form-item>
  217. <u-button size="mini" type="primary" @click="addTime(photoTimeArray.length)">添加</u-button>
  218. </u-form>
  219. </view>
  220. </view>
  221. </u-modal>
  222. <!-- 信息素弹框 -->
  223. <u-modal v-model="expireInfoLayer" width="90%" :async-close="true" :show-cancel-button="true"
  224. @confirm="changeExpireFun">
  225. <view class="slot-content">
  226. <view class="expireBox">
  227. <u-form ref="uForm">
  228. <u-form-item label="信息素名称" :label-width="180">
  229. <u-input v-model="decoy" type="text" :border="true" placeholder="请输入信息素名称" />
  230. </u-form-item>
  231. <u-form-item label="新信息素可使用时间" :label-width="280">
  232. <u-radio-group v-model="xy_expire_time">
  233. <u-radio v-for="(item, index) in expireTimeList" :key="index" :name="item.value">
  234. {{item.label}}
  235. </u-radio>
  236. </u-radio-group>
  237. </u-form-item>
  238. </u-form>
  239. </view>
  240. </view>
  241. </u-modal>
  242. </view>
  243. </view>
  244. </template>
  245. <script>
  246. import uCharts from '../../../../components/js_sdk/u-charts/u-charts/u-charts.js';
  247. var canvaColumnA = null;
  248. export default {
  249. data() {
  250. return {
  251. myuser_type: '',
  252. equipInfoImei: '',
  253. equipInfo_d_id: '',
  254. btnList: [{
  255. text: '更换信息素',
  256. icon: 'yficonfont icon-weimingming-34',
  257. class: 'green',
  258. code: 'changeInfo'
  259. }],
  260. list: [{
  261. name: '基本信息'
  262. }],
  263. current: 0,
  264. equipInfo: {},
  265. dataList: [{
  266. text: '空气温度', // 中文
  267. unit: 'air_temp', // 对应字段
  268. data: '',
  269. icon: 'yficonfont icon-kongqiwendu', // iconclass名称
  270. },
  271. {
  272. text: '空气湿度',
  273. unit: 'air_humi',
  274. data: '',
  275. icon: 'yficonfont icon-shuizhi',
  276. },
  277. {
  278. text: '风力',
  279. unit: 'wind_force',
  280. isSmall: true,
  281. data: '',
  282. icon: 'yficonfont icon-fengli',
  283. },
  284. {
  285. text: '风向',
  286. unit: 'wind_dir',
  287. isSmall: true,
  288. data: '',
  289. icon: 'yficonfont icon-fengxiang',
  290. },
  291. {
  292. text: '害虫数量',
  293. unit: 'bugcnt',
  294. data: '',
  295. icon: 'yficonfont icon-chouchongbug',
  296. },
  297. {
  298. text: '光照强度',
  299. unit: 'light',
  300. data: '',
  301. isSmall: true,
  302. icon: 'yficonfont icon-qingtian',
  303. },
  304. {
  305. text: '降雨',
  306. unit: 'rain_status',
  307. data: '',
  308. icon: 'yficonfont icon-yu',
  309. },
  310. {
  311. text: '电池电量',
  312. unit: 'bat_level',
  313. data: '',
  314. icon: 'yficonfont icon-80dianliang',
  315. },
  316. {
  317. text: '信号强度',
  318. unit: 'gprs',
  319. data: '',
  320. icon: 'yficonfont icon-wifi',
  321. },
  322. {
  323. text: '定位信噪比',
  324. unit: 'cn0',
  325. data: '',
  326. isSmall: true,
  327. icon: 'yficonfont icon-dingwei1',
  328. },
  329. {
  330. text: '太阳能电压',
  331. unit: 'solar_voltage',
  332. data: '',
  333. icon: 'yficonfont icon-guangfuzujianshuliang',
  334. },
  335. {
  336. text: '蓄电池电压',
  337. unit: 'bat_val',
  338. data: '',
  339. icon: 'yficonfont icon-xudianchi',
  340. },
  341. ],
  342. dataLoading: true,
  343. newDataObj: {},
  344. deviceDataList: [{
  345. text: '设备名',
  346. key: 'devname',
  347. },
  348. {
  349. text: '设备版本号',
  350. key: 'version',
  351. },
  352. {
  353. text: '心跳间隔',
  354. key: 'heart_time',
  355. },
  356. {
  357. text: '太阳能电压阀值',
  358. key: 'solar_threshold',
  359. },
  360. {
  361. text: '太阳能电压最大值',
  362. key: 'solarmax',
  363. },
  364. {
  365. text: '数据上传频率',
  366. key: 'upload_time',
  367. },
  368. {
  369. text: '工作模式',
  370. key: 'dev_work_mode',
  371. },
  372. {
  373. text: '定时模式时间',
  374. key: 'dev_work_time',
  375. },
  376. {
  377. text: '高压包开关状态',
  378. key: 'dev_work_onoff',
  379. },
  380. {
  381. text: 'SIM卡号',
  382. key: 'sim',
  383. },
  384. ],
  385. deviceLoading: true,
  386. deviceObj: {},
  387. photoTimeArray: [],
  388. photoTimeLayer: false,
  389. expireInfoLayer: false,
  390. xy_expire_time: 2, // 时间
  391. decoy: '', // 诱芯名称
  392. expireTimeList: [{
  393. label: '1个月',
  394. value: 1,
  395. },
  396. {
  397. label: '2个月',
  398. value: 2,
  399. },
  400. {
  401. label: '3个月',
  402. value: 3,
  403. },
  404. {
  405. label: '4个月',
  406. value: 4,
  407. },
  408. ],
  409. params: {
  410. year: false,
  411. month: false,
  412. day: false,
  413. hour: true,
  414. minute: true,
  415. second: false
  416. },
  417. //设备控制
  418. equipContrlForm1: {
  419. devname: '',
  420. heart_time: '',
  421. solar_threshold: '',
  422. solarmax: '',
  423. upload_time: 0,
  424. dev_work_mode: '',
  425. dev_work_timeArray: '',
  426. dev_work_onoff: '',
  427. sim: '',
  428. et: '',
  429. st: '',
  430. show_st: false,
  431. show_et: false,
  432. // st: '', //时控开始时间
  433. // et: '', //时控结束时间
  434. // dat_f: null ,//数据上传时间间隔
  435. // ds:''//开关,1开机,0关机
  436. },
  437. ota_url: '',
  438. photoList: [],
  439. photoLoading: true,
  440. showRangeTime: false,
  441. photoTimeRange: '',
  442. photoTimeRangeText: '请选择日期',
  443. page: 1,
  444. total: 0,
  445. loadStatus: '',
  446. iconType: 'flower',
  447. loadText: {
  448. loadmore: '点击加载更多',
  449. loading: '努力加载中',
  450. nomore: '没有更多啦~'
  451. },
  452. cWidth: '400',
  453. cHeight: '400',
  454. pixelRatio: 1,
  455. showCanvas: false,
  456. analyInfo:{
  457. decoy:'',
  458. count:''
  459. }
  460. };
  461. },
  462. onLoad(option) {
  463. this.cWidth = uni.upx2px(650);
  464. this.cHeight = uni.upx2px(500);
  465. uni.getStorage({
  466. key: "jurisdiction",
  467. success: (res) => {
  468. let items = JSON.parse(res.data).filter((item) => {
  469. return item.pur_id == 36
  470. })
  471. var arr = items[0].children
  472. for (var i = 0; i < arr.length; i++) {
  473. switch (arr[i].pur_id) {
  474. case 338:
  475. let newChildren = arr[i].children;
  476. let hasImg = newChildren.some((item) => {
  477. return item.pur_id == 341
  478. })
  479. let hasControl = newChildren.some((item) => {
  480. return item.pur_id == 340
  481. })
  482. if (hasImg) {
  483. this.list.push({
  484. name: '数据分析'
  485. }, {
  486. name: '图片列表'
  487. })
  488. this.btnList.push({
  489. text: '拍照定时',
  490. icon: 'yficonfont icon-dingshi',
  491. class: 'blue',
  492. code: 'photoTime'
  493. }, {
  494. text: '一键拍照',
  495. icon: 'yficonfont icon-paizhao-xianxing',
  496. class: 'yellow',
  497. code: 'tackPhoto'
  498. })
  499. }
  500. if (hasControl) {
  501. this.list.push({
  502. name: '设备控制'
  503. });
  504. this.btnList.push({
  505. text: '设备清虫',
  506. icon: 'yficonfont icon-chouchongbug',
  507. class: 'danger',
  508. code: 'clear'
  509. })
  510. }
  511. break
  512. }
  513. }
  514. }
  515. })
  516. this.equipInfoImei = JSON.parse(option.detail).imei;
  517. this.equipInfo_d_id = JSON.parse(option.detail).d_id;
  518. this.getEquipInfo();
  519. // console.log(this.equipInfo);
  520. this.getData();
  521. this.getDeviceData();
  522. uni.getStorage({
  523. key: "myuser_type",
  524. success: (res) => {
  525. if (Number(res.data) == 1) {
  526. this.myuser_type = true
  527. }
  528. }
  529. })
  530. },
  531. methods: {
  532. // 害虫统计折线图
  533. showColumn(id, xtitle, xinfo) {
  534. var _self = this;
  535. canvaColumnA = new uCharts({
  536. canvasId: id,
  537. type: 'line',
  538. legend: {
  539. position: "top"
  540. },
  541. fontSize: 11,
  542. background: '#FFFFFF',
  543. pixelRatio: 1,
  544. animation: true,
  545. dataLabel: false,
  546. categories: xtitle,
  547. series: xinfo,
  548. enableScroll: true, //开启图表拖拽功能
  549. xAxis: {
  550. disableGrid: true,
  551. type: 'grid',
  552. gridType: 'dash',
  553. itemCount: 4, //x轴单屏显示数据的数量,默认为5个
  554. scrollShow: true, //新增是否显示滚动条,默认false
  555. // scrollAlign: 'left', //滚动条初始位置
  556. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  557. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  558. },
  559. width: _self.cWidth * 1,
  560. height: _self.cHeight * 1,
  561. yAxis: {},
  562. extra: {
  563. line: {
  564. type: 'curve'
  565. }
  566. }
  567. });
  568. },
  569. touchLineA(e) {
  570. console.log(e)
  571. canvaColumnA.scrollStart(e);
  572. },
  573. moveLineA(e) {
  574. canvaColumnA.scroll(e);
  575. },
  576. touchEndLineA(e) {
  577. canvaColumnA.scrollEnd(e);
  578. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  579. canvaColumnA.showToolTip(e, {
  580. format: function(item, category) {
  581. return category + ' ' + item.name + ':' + item.data
  582. }
  583. });
  584. },
  585. async lineChartPest(type) {
  586. let {
  587. photoTimeRange
  588. } = this;
  589. let res = await this.$myRequest({
  590. method: 'post',
  591. url: '/api/api_gateway?method=lpsxy.views.pest_count',
  592. data: {
  593. d_id: this.equipInfo_d_id,
  594. start: photoTimeRange ? (photoTimeRange[0] / 1000) : '',
  595. end: photoTimeRange ? (photoTimeRange[1] / 1000) : '',
  596. },
  597. })
  598. if (res.length > 0) {
  599. this.showCanvas = true;
  600. let name = [];
  601. let ydata = [];
  602. res.forEach(item => {
  603. name.push(item.date);
  604. ydata.push(item.total);
  605. });
  606. var obj = [{
  607. name: '诱虫数量',
  608. data: ydata,
  609. color: '#FF3F3F'
  610. }]
  611. if (type == 'search') {
  612. // 当前是搜索
  613. this.showColumn("canvasColumnA", name, obj)
  614. } else {
  615. this.showColumn("canvasColumnA", name, obj)
  616. }
  617. } else {
  618. this.showCanvas = false;
  619. }
  620. },
  621. examine(index) {
  622. var imgarr = []
  623. for (var i = 0; i < this.photoList.length; i++) {
  624. imgarr.push(this.photoList[i].addr)
  625. }
  626. // console.log(imgarr)
  627. uni.previewImage({
  628. urls: imgarr,
  629. current: index
  630. });
  631. },
  632. async getEquipInfo() {
  633. let res = await this.$myRequest({
  634. method: 'post',
  635. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  636. data: {
  637. device_id: this.equipInfoImei,
  638. page: 1,
  639. page_size: 10,
  640. device_model: 0,
  641. device_type_id: 25
  642. },
  643. })
  644. console.log(res);
  645. // console.log(res.data.data);
  646. this.equipInfo = res.data[0];
  647. },
  648. async getAnsyInfo() {
  649. let res = await this.$myRequest({
  650. method: 'post',
  651. url: '/api/api_gateway?method=lpsxy.views.pest_info',
  652. data: {
  653. d_id: this.equipInfo_d_id,
  654. },
  655. })
  656. console.log(res);
  657. // console.log(res.data.data);
  658. this.analyInfo = res;
  659. },
  660. btnFun(code) {
  661. switch (code) {
  662. case 'clear':
  663. this.takePhoto(3);
  664. break;
  665. case 'tackPhoto':
  666. this.takePhoto(1);
  667. break;
  668. case 'photoTime':
  669. this.getPhotoTime();
  670. this.photoTimeLayer = true;
  671. break;
  672. case 'changeInfo':
  673. this.decoy = '';
  674. this.xy_expire_time = 2;
  675. this.expireInfoLayer = true;
  676. break;
  677. default:
  678. break;
  679. }
  680. // if(code == 'clear') {
  681. // this.takePhoto(3)
  682. // }
  683. },
  684. async getData() {
  685. let res = await this.$myRequest({
  686. method: 'post',
  687. url: '/api/api_gateway?method=lpsxy.views.monitor_data',
  688. data: {
  689. device_id: this.equipInfoImei,
  690. },
  691. })
  692. console.log(res);
  693. // console.log(res.data.data);
  694. this.newDataObj = res;
  695. },
  696. async getDeviceData() {
  697. let res = await this.$myRequest({
  698. method: 'post',
  699. url: '/api/api_gateway?method=lpsxy.views.device_config',
  700. data: {
  701. d_id: this.equipInfo_d_id,
  702. },
  703. })
  704. console.log(res);
  705. // console.log(res.data.data);
  706. this.deviceObj = res;
  707. },
  708. // 获取当前拍照时间控制
  709. async getPhotoTime() {
  710. this.photoTimeLayer = true;
  711. this.photoTimeArray = [];
  712. let res = await this.$myRequest({
  713. method: 'POST',
  714. url: '/api/api_gateway?method=lpsxy.views.device_config',
  715. data: {
  716. d_id: this.equipInfo_d_id,
  717. config_type: 1
  718. },
  719. })
  720. if (res && Object.keys(res).length > 0) {
  721. let data = res;
  722. for (const key in data) {
  723. if (key.includes('snaptime')) {
  724. let text = (data[key] + '').padStart(4, '0');
  725. // console.log(`${text.substring(0, 2)}${text.substring(2, 4)}`);
  726. this.photoTimeArray.push({
  727. value: `${text.substring(0, 2)}:${text.substring(2, 4)}`,
  728. key,
  729. show: false,
  730. });
  731. }
  732. }
  733. // console.log(this.photoTimeArray);
  734. }
  735. },
  736. removeTime(index) {
  737. this.photoTimeArray.splice(index, 1);
  738. },
  739. addTime(index) {
  740. this.photoTimeArray.push({
  741. value: `00:00`,
  742. key: `snaptime${index}`,
  743. show: false,
  744. });
  745. },
  746. changeSnapTime(e, key, index) {
  747. this.photoTimeArray[index].value = `${e.hour}:${e.minute}`
  748. },
  749. changeControlTime(e, type) {
  750. this.equipContrlForm1[type] = `${e.hour}:${e.minute}`
  751. },
  752. async devicePhotoTime() {
  753. // console.log(this.photoTimeArray);
  754. let obj = {};
  755. this.photoTimeArray.forEach((item, index) => {
  756. if (item.value) {
  757. obj[`snaptime${index + 1}`] = (item.value.replace(/:/g, "")) * 1;
  758. }
  759. });
  760. // console.log(obj);
  761. let res = await this.$myRequest({
  762. method: 'post',
  763. url: '/api/api_gateway?method=lpsxy.views.device_control',
  764. data: {
  765. device_id: this.equipInfoImei,
  766. ...obj,
  767. },
  768. })
  769. if (res) {
  770. uni.showToast({
  771. title: '指令下发成功',
  772. duration: 1000,
  773. icon: "none"
  774. });
  775. // this.$message.success('指令下发成功');
  776. this.photoTimeLayer = false;
  777. } else {
  778. uni.showToast({
  779. title: '指令下发失败',
  780. icon: "none",
  781. duration: 1000
  782. });
  783. // this.$message.error(res.data.message);
  784. }
  785. },
  786. async takePhoto(order_type) {
  787. let res = await this.$myRequest({
  788. method: 'post',
  789. url: '/api/api_gateway?method=lpsxy.views.send_control',
  790. data: {
  791. device_id: this.equipInfoImei,
  792. order_type,
  793. },
  794. })
  795. if (res) {
  796. uni.showToast({
  797. title: '指令下发成功',
  798. duration: 1000,
  799. icon: "none"
  800. });
  801. // this.$message.success('指令下发成功');
  802. } else {
  803. uni.showToast({
  804. title: '指令下发失败',
  805. icon: "none",
  806. duration: 1000
  807. });
  808. // this.$message.error(res.data.message);
  809. }
  810. },
  811. async changeExpireFun() {
  812. if (this.decoy == '') {
  813. uni.showToast({
  814. title: '请输入信息素名称',
  815. duration: 1000,
  816. icon: "none"
  817. });
  818. // this.$message.error('请输入信息素名称');
  819. return;
  820. }
  821. let res = await this.$myRequest({
  822. method: 'post',
  823. url: '/api/api_gateway?method=lpsxy.views.update_xy_expire_time',
  824. data: {
  825. device_id: this.equipInfoImei,
  826. xy_expire_time: this.xy_expire_time,
  827. decoy: this.decoy,
  828. },
  829. })
  830. if (res) {
  831. uni.showToast({
  832. title: '操作成功',
  833. icon: "none",
  834. duration: 1000
  835. });
  836. // this.$message.success('操作成功');
  837. this.expireInfoLayer = false;
  838. this.getEquipInfo();
  839. } else {
  840. uni.showToast({
  841. title: '操作失败',
  842. icon: "none",
  843. duration: 1000
  844. });
  845. // this.$message.error(res.data.message);
  846. }
  847. },
  848. async getPhotoList(search) {
  849. let {
  850. photoTimeRange
  851. } = this;
  852. // console.log(photoTimeRange);
  853. // if(photoTimeRange) {
  854. // this.page = 1;
  855. // }
  856. // 当筛选的时候 清空图片列表
  857. if (search) {
  858. this.page = 1;
  859. this.photoList = [];
  860. }
  861. let res = await this.$myRequest({
  862. method: 'post',
  863. url: '/api/api_gateway?method=lpsxy.views.photo_list',
  864. data: {
  865. d_id: this.equipInfo_d_id,
  866. page: this.page,
  867. start: photoTimeRange ? (photoTimeRange[0] / 1000) : '',
  868. end: photoTimeRange ? (photoTimeRange[1] / 1000) : '',
  869. },
  870. })
  871. this.photoLoading = false;
  872. if (res) {
  873. this.photoList = [...this.photoList, ...res.data];
  874. this.total = res.count;
  875. if (this.total > this.page * 10) {
  876. this.loadStatus = 'loadmore'
  877. } else if (this.total <= this.page * 10) {
  878. this.loadStatus = 'nomore'
  879. }
  880. } else {
  881. uni.showToast({
  882. title: '请求失败',
  883. icon: "none",
  884. duration: 1000
  885. });;
  886. }
  887. },
  888. changePhotoTime(dateObj, type) {
  889. console.log(dateObj);
  890. this.photoTimeRangeText = `${dateObj.startDate}~${dateObj.endDate}`;
  891. this.photoTimeRange = [new Date(dateObj.startDate).getTime(),new Date(dateObj.endDate).getTime()];
  892. if(type == 'photo') {
  893. this.getPhotoList('search')
  894. } else {
  895. this.lineChartPest('search')
  896. }
  897. },
  898. clearTimeFun(type) {
  899. this.photoTimeRangeText = '请选择日期';
  900. this.photoTimeRange = '';
  901. if(type == 'photo') {
  902. this.getPhotoList('search');
  903. } else {
  904. this.lineChartPest('search')
  905. }
  906. },
  907. loadMore() {
  908. this.page++;
  909. this.getPhotoList()
  910. },
  911. change(index) {
  912. this.current = index;
  913. if (index == 3) {
  914. this.getControlInfo();
  915. } else if (index == 2) {
  916. this.photoList = [];
  917. this.page = 1;
  918. this.photoTimeRangeText = '请选择日期';
  919. this.photoTimeRange = '';
  920. this.getPhotoList();
  921. } else if(index == 1) {
  922. this.photoTimeRangeText = '请选择日期';
  923. this.photoTimeRange = '';
  924. this.lineChartPest();
  925. this.getAnsyInfo();
  926. }
  927. },
  928. copy(item) {
  929. console.log(item)
  930. uni.setClipboardData({
  931. data: item,
  932. success: function() {
  933. console.log('success');
  934. }
  935. });
  936. },
  937. async getControlInfo() {
  938. let res = await this.$myRequest({
  939. method: "POST",
  940. url: "/api/api_gateway?method=lpsxy.views.device_config",
  941. data: {
  942. d_id: this.equipInfo_d_id,
  943. config_type: 1
  944. },
  945. })
  946. if (res && Object.keys(res).length > 0) {
  947. let data = res;
  948. console.log(data);
  949. let newObj = {
  950. ...data,
  951. show_st: false,
  952. show_et: false,
  953. };
  954. newObj.dev_work_time = data.dev_work_time + '';
  955. newObj.dev_work_time = newObj.dev_work_time.length > 7 ? newObj.dev_work_time : newObj
  956. .dev_work_time.padStart(8, '0');
  957. newObj.st = `${newObj.dev_work_time.substring(0, 2)}:${newObj.dev_work_time.substring(2, 4)}`;
  958. newObj.et = `${newObj.dev_work_time.substring(4, 6)}:${newObj.dev_work_time.substring(6, 8)}`;
  959. // console.log(newObj);
  960. this.equipContrlForm1 = newObj;
  961. }
  962. },
  963. async equipControlSubm() {
  964. let newForm = Object.assign({}, this.equipContrlForm1); //深拷贝
  965. newForm.dev_work_time = (newForm.st + newForm.et).replace(/:/g, "") * 1;
  966. console.log(newForm);
  967. // console.log(obj);
  968. let res = await this.$myRequest({
  969. method: "POST",
  970. url: "/api/api_gateway?method=lpsxy.views.device_control",
  971. data: {
  972. device_id: this.equipInfoImei,
  973. ...newForm
  974. },
  975. })
  976. if (res) {
  977. uni.showToast({
  978. title: '指令下发成功',
  979. duration: 1000,
  980. icon: "none"
  981. });
  982. // this.$message.success('指令下发成功');
  983. } else {
  984. uni.showToast({
  985. title: '指令下发失败',
  986. icon: "none",
  987. duration: 1000
  988. });
  989. // this.$message.error(res.data.message);
  990. }
  991. },
  992. async equipBtnControl(cmd) {
  993. if (this.ota_url == '') {
  994. uni.showToast({
  995. title: '请输入地址',
  996. duration: 1000,
  997. icon: "none"
  998. });
  999. return
  1000. }
  1001. let op_type = '';
  1002. if (cmd == "reboot") {
  1003. var name = "重启";
  1004. op_type = 1;
  1005. } else if (cmd == "update") {
  1006. var name = "升级";
  1007. op_type = 2;
  1008. }
  1009. let res = await this.$myRequest({
  1010. method: "POST",
  1011. url: "/api/api_gateway?method=lpsxy.views.device_root_control",
  1012. data: {
  1013. op_type,
  1014. d_id: this.equipInfo_d_id,
  1015. ota_url: this.ota_url
  1016. },
  1017. });
  1018. if (res) {
  1019. uni.showToast({
  1020. title: '指令下发成功',
  1021. duration: 1000,
  1022. icon: "none"
  1023. });
  1024. // this.$message.success('指令下发成功');
  1025. } else {
  1026. uni.showToast({
  1027. title: '指令下发失败',
  1028. icon: "none",
  1029. duration: 1000
  1030. });
  1031. // this.$message.error(res.data.message);
  1032. }
  1033. }
  1034. }
  1035. }
  1036. </script>
  1037. <style lang="less" scoped>
  1038. /deep/ .u-calendar__action {
  1039. display: flex;
  1040. justify-content: space-between;
  1041. }
  1042. .green {
  1043. background: #14a478;
  1044. }
  1045. /deep/ .u-radio__icon-wrap__icon {
  1046. .u-icon__icon {
  1047. top: -8rpx !important;
  1048. }
  1049. }
  1050. .yellow {
  1051. background: #f4a72f;
  1052. }
  1053. .danger {
  1054. background: #ff5951;
  1055. }
  1056. .blue {
  1057. background: #1890FF;
  1058. }
  1059. .bigBox {
  1060. position: relative;
  1061. width: 100vw;
  1062. height: calc(100vh);
  1063. background: #f7f7f7;
  1064. overflow: hidden;
  1065. .timeBox {
  1066. display: flex;
  1067. justify-content: space-between;
  1068. align-items: center;
  1069. padding: 30rpx 32rpx;
  1070. border: 1rpx #E5EBE9 solid;
  1071. background: #fff;
  1072. color: #666;
  1073. font-size: 30rpx;
  1074. height: 100rpx;
  1075. box-sizing: border-box;
  1076. .iconBox {
  1077. display: flex;
  1078. align-items: center;
  1079. // margin-top: 4rpx
  1080. }
  1081. .text {
  1082. width: 80vw;
  1083. margin-left: 16rpx;
  1084. }
  1085. }
  1086. }
  1087. .currentBox {
  1088. height: 100%;
  1089. overflow: auto;
  1090. }
  1091. .info {
  1092. padding: 20rpx 40rpx;
  1093. color: #fff;
  1094. line-height: 50rpx;
  1095. font-size: 26rpx;
  1096. background-size: 100% auto;
  1097. background-repeat: no-repeat;
  1098. background-color: #0DC6B6;
  1099. background-position: top left;
  1100. box-sizing: border-box;
  1101. width: 100%;
  1102. border-radius: 5rpx;
  1103. margin: 0 auto;
  1104. p:first-child {
  1105. font-size: 32rpx;
  1106. }
  1107. .expiretishi {
  1108. font-size: 24rpx;
  1109. color: #FF0000;
  1110. }
  1111. .tishi {
  1112. width: 28rpx;
  1113. height: 28rpx;
  1114. margin: 0rpx 0 0 20rpx;
  1115. }
  1116. .fillin {
  1117. display: flex;
  1118. input {
  1119. width: 200rpx;
  1120. font-size: 24rpx;
  1121. height: 50rpx;
  1122. line-height: 50rpx;
  1123. text-indent: 1em;
  1124. }
  1125. }
  1126. }
  1127. .on {
  1128. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png')
  1129. }
  1130. .off {
  1131. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png')
  1132. }
  1133. .infoBox {
  1134. width: 100%;
  1135. padding: 10rpx 24rpx;
  1136. height: calc(100vh - 92rpx);
  1137. box-sizing: border-box;
  1138. overflow: auto;
  1139. }
  1140. .cardInfo {
  1141. margin-top: 24rpx;
  1142. .title {
  1143. font-size: 28rpx;
  1144. color: #999;
  1145. }
  1146. .controlCard {
  1147. display: flex;
  1148. align-items: center;
  1149. justify-content: space-between;
  1150. width: 100%;
  1151. margin-top: 30rpx;
  1152. background: #fff;
  1153. box-sizing: border-box;
  1154. overflow: hidden;
  1155. .preBtn {
  1156. display: flex;
  1157. align-items: center;
  1158. justify-content: space-around;
  1159. flex-direction: column;
  1160. width: 22%;
  1161. padding: 20rpx;
  1162. height: 80px;
  1163. font-size: 24rpx;
  1164. }
  1165. .btnBox {
  1166. display: flex;
  1167. align-items: center;
  1168. justify-content: center;
  1169. height: 96rpx;
  1170. width: 96rpx;
  1171. border-radius: 96rpx;
  1172. color: #fff;
  1173. text {
  1174. font-size: 20px;
  1175. }
  1176. }
  1177. .preInfo {
  1178. float: left;
  1179. display: flex;
  1180. align-items: center;
  1181. box-sizing: border-box;
  1182. padding: 32rpx !important;
  1183. background: #fff;
  1184. margin-bottom: 32rpx;
  1185. width: 49%;
  1186. margin-right: 2%;
  1187. .btnBox {
  1188. width: 72rpx;
  1189. height: 72rpx;
  1190. background: #14a478;
  1191. }
  1192. .textBox {
  1193. margin-left: 40rpx;
  1194. font-size: 32rpx;
  1195. .name {
  1196. font-size: 24rpx;
  1197. color: #999;
  1198. }
  1199. }
  1200. }
  1201. .preInfo:nth-child(2n) {
  1202. margin-right: 0;
  1203. /* 每个第 3 个元素的右边距为 0 */
  1204. }
  1205. }
  1206. .noBg {
  1207. background: none;
  1208. }
  1209. .widthSet {
  1210. width: 100%;
  1211. }
  1212. .u-border-bottom:after,
  1213. .u-border-left:after,
  1214. .u-border-right:after,
  1215. .u-border-top-bottom:after,
  1216. .u-border-top:after,
  1217. .u-border:after {
  1218. content: " ";
  1219. position: absolute;
  1220. left: 0;
  1221. top: 0;
  1222. pointer-events: none;
  1223. box-sizing: border-box;
  1224. -webkit-transform-origin: 0 0;
  1225. transform-origin: 0 0;
  1226. width: 199.8%;
  1227. height: 199.7%;
  1228. -webkit-transform: scale(.5);
  1229. transform: scale(.5);
  1230. border: .5px solid #E5EBE9;
  1231. z-index: 2;
  1232. }
  1233. }
  1234. .expireBox {
  1235. padding: 20rpx;
  1236. box-sizing: border-box;
  1237. max-height: 60vh;
  1238. overflow: auto;
  1239. .delBtn {
  1240. margin-left: 40rpx;
  1241. }
  1242. }
  1243. .bgColor {
  1244. width: 100%;
  1245. box-sizing: border-box;
  1246. background: #fff;
  1247. padding: 0 20rpx;
  1248. overflow: auto;
  1249. /deep/ .u-form {
  1250. height: calc(100vh - 88rpx);
  1251. overflow: auto;
  1252. box-sizing: border-box;
  1253. padding: 20rpx 0;
  1254. }
  1255. .btn {
  1256. margin-left: 20rpx;
  1257. }
  1258. }
  1259. .chartBox {
  1260. min-height: 400rpx;
  1261. background: #fff;
  1262. margin: 20rpx 0;
  1263. padding: 32rpx;
  1264. box-sizing: border-box;
  1265. background: #fff;
  1266. .noEmpty{
  1267. height: 400rpx;
  1268. display: flex;
  1269. justify-content: center;
  1270. align-items: center;
  1271. }
  1272. .pestInfo {
  1273. padding: 32rpx 0;
  1274. box-sizing: border-box;
  1275. .pest {
  1276. font-size: 24rpx;
  1277. color: #666;
  1278. margin-bottom: 16rpx;
  1279. .name {
  1280. margin-left: 10rpx;
  1281. color: #333;
  1282. font-weight: 600;
  1283. }
  1284. }
  1285. }
  1286. .pestStatus {
  1287. box-sizing: border-box;
  1288. display: flex;
  1289. align-items: center;
  1290. justify-content: space-between;
  1291. background: #fff;
  1292. height: 284rpx;
  1293. .block {
  1294. display: flex;
  1295. align-items: center;
  1296. flex-direction: column;
  1297. justify-content: space-around;
  1298. width: 33%;
  1299. height: 100%;
  1300. text-align: center;
  1301. }
  1302. .active {
  1303. background: #f7f7f7;
  1304. }
  1305. .iconBox {
  1306. display: flex;
  1307. align-items: center;
  1308. justify-content: center;
  1309. width: 128rpx;
  1310. height: 128rpx;
  1311. border-radius: 128rpx;
  1312. color: #fff;
  1313. .yficonfont {
  1314. font-size: 80rpx;
  1315. }
  1316. }
  1317. .blueText {
  1318. color: #14a478;
  1319. }
  1320. .yellowText {
  1321. color: #f4a72f;
  1322. }
  1323. .redText {
  1324. color: #FF0000;
  1325. }
  1326. }
  1327. }
  1328. .imgList {
  1329. height: calc(100vh - 232rpx);
  1330. overflow: auto;
  1331. box-sizing: border-box;
  1332. padding: 20rpx 0;
  1333. .preImg {
  1334. position: relative;
  1335. float: left;
  1336. width: 49%;
  1337. margin-right: 2%;
  1338. margin-bottom: 20rpx;
  1339. .text {
  1340. position: absolute;
  1341. bottom: 0;
  1342. left: 0;
  1343. width: 100%;
  1344. height: 40rpx;
  1345. line-height: 40rpx;
  1346. text-align: center;
  1347. color: #fff;
  1348. background: rgba(0, 0, 0, .4);
  1349. font-size: 24rpx;
  1350. z-index: 2;
  1351. }
  1352. }
  1353. .preImg:nth-child(2n) {
  1354. margin-right: 0;
  1355. /* 每个第 3 个元素的右边距为 0 */
  1356. }
  1357. .loadBox {
  1358. float: left;
  1359. width: 100%;
  1360. }
  1361. /deep/ .u-calendar__action {
  1362. display: flex;
  1363. justify-content: space-between;
  1364. }
  1365. }
  1366. </style>