detail.vue 34 KB

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