detail.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  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. const ctx = uni.createCanvasContext(id, this);
  533. canvaColumnA = new uCharts({
  534. context: ctx,
  535. type: 'line',
  536. legend: {
  537. position: "top"
  538. },
  539. fontSize: 11,
  540. background: '#FFFFFF',
  541. pixelRatio: 1,
  542. animation: true,
  543. dataLabel: false,
  544. categories: xtitle,
  545. series: xinfo,
  546. enableScroll: true, //开启图表拖拽功能
  547. xAxis: {
  548. disableGrid: true,
  549. type: 'grid',
  550. gridType: 'dash',
  551. itemCount: 4, //x轴单屏显示数据的数量,默认为5个
  552. scrollShow: true, //新增是否显示滚动条,默认false
  553. // scrollAlign: 'left', //滚动条初始位置
  554. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  555. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  556. },
  557. width: _self.cWidth * 1,
  558. height: _self.cHeight * 1,
  559. yAxis: {},
  560. extra: {
  561. line: {
  562. type: 'curve'
  563. }
  564. }
  565. });
  566. },
  567. touchLineA(e) {
  568. console.log(e)
  569. canvaColumnA.scrollStart(e);
  570. },
  571. moveLineA(e) {
  572. canvaColumnA.scroll(e);
  573. },
  574. touchEndLineA(e) {
  575. canvaColumnA.scrollEnd(e);
  576. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  577. canvaColumnA.showToolTip(e, {
  578. format: function(item, category) {
  579. return category + ' ' + item.name + ':' + item.data
  580. }
  581. });
  582. },
  583. async lineChartPest(type) {
  584. let {
  585. photoTimeRange
  586. } = this;
  587. let res = await this.$myRequest({
  588. method: 'post',
  589. url: '/api/api_gateway?method=lpsxy.views.pest_count',
  590. data: {
  591. d_id: this.equipInfo_d_id,
  592. start: photoTimeRange ? (photoTimeRange[0] / 1000) : '',
  593. end: photoTimeRange ? (photoTimeRange[1] / 1000) : '',
  594. },
  595. })
  596. if (res.length > 0) {
  597. this.showCanvas = true;
  598. let name = [];
  599. let ydata = [];
  600. res.forEach(item => {
  601. name.push(item.date);
  602. ydata.push(item.total);
  603. });
  604. var obj = [{
  605. name: '诱虫数量',
  606. data: ydata,
  607. color: '#FF3F3F'
  608. }]
  609. if (type == 'search') {
  610. // 当前是搜索
  611. this.showColumn("canvasColumnA", name, obj)
  612. } else {
  613. this.showColumn("canvasColumnA", name, obj)
  614. }
  615. } else {
  616. this.showCanvas = false;
  617. }
  618. },
  619. examine(index) {
  620. var imgarr = []
  621. for (var i = 0; i < this.photoList.length; i++) {
  622. imgarr.push(this.photoList[i].addr)
  623. }
  624. // console.log(imgarr)
  625. uni.previewImage({
  626. urls: imgarr,
  627. current: index
  628. });
  629. },
  630. async getEquipInfo() {
  631. let res = await this.$myRequest({
  632. method: 'post',
  633. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  634. data: {
  635. device_id: this.equipInfoImei,
  636. page: 1,
  637. page_size: 10,
  638. device_model: 0,
  639. device_type_id: 25
  640. },
  641. })
  642. console.log(res);
  643. // console.log(res.data.data);
  644. this.equipInfo = res.data[0];
  645. },
  646. async getAnsyInfo() {
  647. let res = await this.$myRequest({
  648. method: 'post',
  649. url: '/api/api_gateway?method=lpsxy.views.pest_info',
  650. data: {
  651. d_id: this.equipInfo_d_id,
  652. },
  653. })
  654. console.log(res);
  655. // console.log(res.data.data);
  656. this.analyInfo = res;
  657. },
  658. btnFun(code) {
  659. switch (code) {
  660. case 'clear':
  661. this.takePhoto(3);
  662. break;
  663. case 'tackPhoto':
  664. this.takePhoto(1);
  665. break;
  666. case 'photoTime':
  667. this.getPhotoTime();
  668. this.photoTimeLayer = true;
  669. break;
  670. case 'changeInfo':
  671. this.decoy = '';
  672. this.xy_expire_time = 2;
  673. this.expireInfoLayer = true;
  674. break;
  675. default:
  676. break;
  677. }
  678. // if(code == 'clear') {
  679. // this.takePhoto(3)
  680. // }
  681. },
  682. async getData() {
  683. let res = await this.$myRequest({
  684. method: 'post',
  685. url: '/api/api_gateway?method=lpsxy.views.monitor_data',
  686. data: {
  687. device_id: this.equipInfoImei,
  688. },
  689. })
  690. console.log(res);
  691. // console.log(res.data.data);
  692. this.newDataObj = res;
  693. },
  694. async getDeviceData() {
  695. let res = await this.$myRequest({
  696. method: 'post',
  697. url: '/api/api_gateway?method=lpsxy.views.device_config',
  698. data: {
  699. d_id: this.equipInfo_d_id,
  700. },
  701. })
  702. console.log(res);
  703. this.deviceObj = res;
  704. console.log(this.deviceObj);
  705. },
  706. // 获取当前拍照时间控制
  707. async getPhotoTime() {
  708. this.photoTimeLayer = true;
  709. this.photoTimeArray = [];
  710. let res = await this.$myRequest({
  711. method: 'POST',
  712. url: '/api/api_gateway?method=lpsxy.views.device_config',
  713. data: {
  714. d_id: this.equipInfo_d_id,
  715. config_type: 1
  716. },
  717. })
  718. if (res && Object.keys(res).length > 0) {
  719. let data = res;
  720. for (const key in data) {
  721. if (key.includes('snaptime')) {
  722. let text = (data[key] + '').padStart(4, '0');
  723. // console.log(`${text.substring(0, 2)}${text.substring(2, 4)}`);
  724. this.photoTimeArray.push({
  725. value: `${text.substring(0, 2)}:${text.substring(2, 4)}`,
  726. key,
  727. show: false,
  728. });
  729. }
  730. }
  731. // console.log(this.photoTimeArray);
  732. }
  733. },
  734. removeTime(index) {
  735. this.photoTimeArray.splice(index, 1);
  736. },
  737. addTime(index) {
  738. this.photoTimeArray.push({
  739. value: `00:00`,
  740. key: `snaptime${index}`,
  741. show: false,
  742. });
  743. },
  744. changeSnapTime(e, key, index) {
  745. this.photoTimeArray[index].value = `${e.hour}:${e.minute}`
  746. },
  747. changeControlTime(e, type) {
  748. this.equipContrlForm1[type] = `${e.hour}:${e.minute}`
  749. },
  750. async devicePhotoTime() {
  751. // console.log(this.photoTimeArray);
  752. let obj = {};
  753. this.photoTimeArray.forEach((item, index) => {
  754. if (item.value) {
  755. obj[`snaptime${index + 1}`] = (item.value.replace(/:/g, "")) * 1;
  756. }
  757. });
  758. // console.log(obj);
  759. let res = await this.$myRequest({
  760. method: 'post',
  761. url: '/api/api_gateway?method=lpsxy.views.device_control',
  762. data: {
  763. device_id: this.equipInfoImei,
  764. ...obj,
  765. },
  766. })
  767. if (res) {
  768. uni.showToast({
  769. title: '指令下发成功',
  770. duration: 1000,
  771. icon: "none"
  772. });
  773. // this.$message.success('指令下发成功');
  774. this.photoTimeLayer = false;
  775. } else {
  776. uni.showToast({
  777. title: '指令下发失败',
  778. icon: "none",
  779. duration: 1000
  780. });
  781. // this.$message.error(res.data.message);
  782. }
  783. },
  784. async takePhoto(order_type) {
  785. let res = await this.$myRequest({
  786. method: 'post',
  787. url: '/api/api_gateway?method=lpsxy.views.send_control',
  788. data: {
  789. device_id: this.equipInfoImei,
  790. order_type,
  791. },
  792. })
  793. if (res) {
  794. uni.showToast({
  795. title: '指令下发成功',
  796. duration: 1000,
  797. icon: "none"
  798. });
  799. // this.$message.success('指令下发成功');
  800. } else {
  801. uni.showToast({
  802. title: '指令下发失败',
  803. icon: "none",
  804. duration: 1000
  805. });
  806. // this.$message.error(res.data.message);
  807. }
  808. },
  809. async changeExpireFun() {
  810. if (this.decoy == '') {
  811. uni.showToast({
  812. title: '请输入信息素名称',
  813. duration: 1000,
  814. icon: "none"
  815. });
  816. // this.$message.error('请输入信息素名称');
  817. return;
  818. }
  819. let res = await this.$myRequest({
  820. method: 'post',
  821. url: '/api/api_gateway?method=lpsxy.views.update_xy_expire_time',
  822. data: {
  823. device_id: this.equipInfoImei,
  824. xy_expire_time: this.xy_expire_time,
  825. decoy: this.decoy,
  826. },
  827. })
  828. if (res) {
  829. uni.showToast({
  830. title: '操作成功',
  831. icon: "none",
  832. duration: 1000
  833. });
  834. // this.$message.success('操作成功');
  835. this.expireInfoLayer = false;
  836. this.getEquipInfo();
  837. } else {
  838. uni.showToast({
  839. title: '操作失败',
  840. icon: "none",
  841. duration: 1000
  842. });
  843. // this.$message.error(res.data.message);
  844. }
  845. },
  846. async getPhotoList(search) {
  847. let { photoTimeRange } = this;
  848. // console.log(photoTimeRange);
  849. // if(photoTimeRange) {
  850. // this.page = 1;
  851. // }
  852. // 当筛选的时候 清空图片列表
  853. if(search) {
  854. this.page = 1;
  855. this.photoList = [];
  856. }
  857. let res = await this.$myRequest({
  858. method: 'post',
  859. url: '/api/api_gateway?method=lpsxy.views.photo_list',
  860. data: {
  861. d_id: this.equipInfo_d_id,
  862. page: this.page,
  863. start: photoTimeRange ? (photoTimeRange[0]/1000) : '',
  864. end: photoTimeRange ? (photoTimeRange[1]/1000) : '',
  865. },
  866. })
  867. this.photoLoading = false;
  868. if (res) {
  869. this.photoList = [...this.photoList ,...res.data];
  870. this.total = res.count;
  871. if(this.total > this.page * 10) {
  872. this.loadStatus = 'loadmore'
  873. } else if(this.total <= this.page * 10) {
  874. this.loadStatus = 'nomore'
  875. }
  876. } else {
  877. uni.showToast({
  878. title: '请求失败',
  879. icon: "none",
  880. duration: 1000
  881. });;
  882. }
  883. },
  884. changePhotoTime(dateObj, type) {
  885. console.log(dateObj);
  886. this.photoTimeRangeText = `${dateObj.startDate}~${dateObj.endDate}`;
  887. this.photoTimeRange = [new Date(dateObj.startDate).getTime(),new Date(dateObj.endDate).getTime()];
  888. if(type == 'photo') {
  889. this.getPhotoList('search')
  890. } else {
  891. this.lineChartPest('search')
  892. }
  893. },
  894. clearTimeFun(type) {
  895. this.photoTimeRangeText = '请选择日期';
  896. this.photoTimeRange = '';
  897. if(type == 'photo') {
  898. this.getPhotoList('search');
  899. } else {
  900. this.lineChartPest('search')
  901. }
  902. },
  903. loadMore() {
  904. this.page ++;
  905. this.getPhotoList()
  906. },
  907. change(index) {
  908. this.current = index;
  909. if(index == 3) {
  910. this.getControlInfo();
  911. }else if(index == 2) {
  912. this.photoList = [];
  913. this.page = 1;
  914. this.photoTimeRangeText = '请选择日期';
  915. this.photoTimeRange = '';
  916. this.getPhotoList();
  917. } else if(index == 1) {
  918. this.photoTimeRangeText = '请选择日期';
  919. this.photoTimeRange = '';
  920. this.lineChartPest();
  921. this.getAnsyInfo();
  922. }
  923. },
  924. copy(item) {
  925. console.log(item)
  926. uni.setClipboardData({
  927. data: item,
  928. success: function() {
  929. console.log('success');
  930. }
  931. });
  932. },
  933. async getControlInfo() {
  934. let res = await this.$myRequest({
  935. method: "POST",
  936. url: "/api/api_gateway?method=lpsxy.views.device_config",
  937. data: {
  938. d_id: this.equipInfo_d_id,
  939. config_type: 1
  940. },
  941. })
  942. if (res && Object.keys(res).length > 0) {
  943. let data = res;
  944. console.log(data);
  945. let newObj = {
  946. ...data,
  947. show_st: false,
  948. show_et: false,
  949. };
  950. newObj.dev_work_time = data.dev_work_time + '';
  951. newObj.dev_work_time = newObj.dev_work_time.length > 7 ? newObj.dev_work_time : newObj
  952. .dev_work_time.padStart(8, '0');
  953. newObj.st = `${newObj.dev_work_time.substring(0, 2)}:${newObj.dev_work_time.substring(2, 4)}`;
  954. newObj.et = `${newObj.dev_work_time.substring(4, 6)}:${newObj.dev_work_time.substring(6, 8)}`;
  955. // console.log(newObj);
  956. this.equipContrlForm1 = newObj;
  957. }
  958. },
  959. async equipControlSubm() {
  960. let newForm = Object.assign({}, this.equipContrlForm1); //深拷贝
  961. newForm.dev_work_time = (newForm.st + newForm.et).replace(/:/g, "") * 1;
  962. console.log(newForm);
  963. // console.log(obj);
  964. let res = await this.$myRequest({
  965. method: "POST",
  966. url: "/api/api_gateway?method=lpsxy.views.device_control",
  967. data: {
  968. device_id: this.equipInfoImei,
  969. ...newForm
  970. },
  971. })
  972. if (res) {
  973. uni.showToast({
  974. title: '指令下发成功',
  975. duration: 1000,
  976. icon: "none"
  977. });
  978. // this.$message.success('指令下发成功');
  979. } else {
  980. uni.showToast({
  981. title: '指令下发失败',
  982. icon: "none",
  983. duration: 1000
  984. });
  985. // this.$message.error(res.data.message);
  986. }
  987. },
  988. async equipBtnControl(cmd) {
  989. if (this.ota_url == '') {
  990. uni.showToast({
  991. title: '请输入地址',
  992. duration: 1000,
  993. icon: "none"
  994. });
  995. return
  996. }
  997. let op_type = '';
  998. if (cmd == "reboot") {
  999. var name = "重启";
  1000. op_type = 1;
  1001. } else if (cmd == "update") {
  1002. var name = "升级";
  1003. op_type = 2;
  1004. }
  1005. let res = await this.$myRequest({
  1006. method: "POST",
  1007. url: "/api/api_gateway?method=lpsxy.views.device_root_control",
  1008. data: {
  1009. op_type,
  1010. d_id: this.equipInfo_d_id,
  1011. ota_url: this.ota_url
  1012. },
  1013. });
  1014. if (res) {
  1015. uni.showToast({
  1016. title: '指令下发成功',
  1017. duration: 1000,
  1018. icon: "none"
  1019. });
  1020. // this.$message.success('指令下发成功');
  1021. } else {
  1022. uni.showToast({
  1023. title: '指令下发失败',
  1024. icon: "none",
  1025. duration: 1000
  1026. });
  1027. // this.$message.error(res.data.message);
  1028. }
  1029. }
  1030. }
  1031. }
  1032. </script>
  1033. <style lang="less" scoped>
  1034. /deep/ .u-calendar__action{
  1035. display: flex;
  1036. justify-content: space-between;
  1037. }
  1038. .green {
  1039. background: #14a478;
  1040. }
  1041. .yellow {
  1042. background: #f4a72f;
  1043. }
  1044. .danger {
  1045. background: #ff5951;
  1046. }
  1047. .blue {
  1048. background: #1890FF;
  1049. }
  1050. .bigBox {
  1051. position: relative;
  1052. width: 100vw;
  1053. height: calc(100vh);
  1054. background: #f7f7f7;
  1055. overflow: hidden;
  1056. }
  1057. .info {
  1058. padding: 20rpx 40rpx;
  1059. color: #fff;
  1060. line-height: 50rpx;
  1061. font-size: 26rpx;
  1062. background-size: 100% auto;
  1063. background-repeat: no-repeat;
  1064. background-color: #0DC6B6;
  1065. background-position: top left;
  1066. box-sizing: border-box;
  1067. width: 100%;
  1068. border-radius: 5rpx;
  1069. margin: 0 auto;
  1070. p:first-child {
  1071. font-size: 32rpx;
  1072. }
  1073. .expiretishi {
  1074. font-size: 24rpx;
  1075. color: #FF0000;
  1076. }
  1077. .tishi {
  1078. width: 28rpx;
  1079. height: 28rpx;
  1080. margin: 0rpx 0 0 20rpx;
  1081. }
  1082. .fillin {
  1083. display: flex;
  1084. input {
  1085. width: 200rpx;
  1086. font-size: 24rpx;
  1087. height: 50rpx;
  1088. line-height: 50rpx;
  1089. text-indent: 1em;
  1090. }
  1091. }
  1092. }
  1093. .on {
  1094. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png')
  1095. }
  1096. .off {
  1097. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png')
  1098. }
  1099. .infoBox {
  1100. width: 100%;
  1101. padding: 10rpx 24rpx;
  1102. height: calc(100vh - 80rpx);
  1103. box-sizing: border-box;
  1104. overflow: auto;
  1105. .timeBox{
  1106. display: flex;
  1107. justify-content: space-between;
  1108. align-items: center;
  1109. padding: 30rpx 32rpx;
  1110. border: 1rpx #E5EBE9 solid;
  1111. background: #fff;
  1112. color: #666;
  1113. font-size: 30rpx;
  1114. height: 100rpx;
  1115. box-sizing: border-box;
  1116. .iconBox{
  1117. display: flex;
  1118. align-items: center;
  1119. margin-top: 4rpx
  1120. }
  1121. .text{
  1122. width: 80vw;
  1123. margin-left: 16rpx;
  1124. }
  1125. }
  1126. }
  1127. .cardInfo {
  1128. margin-top: 24rpx;
  1129. width: 100%;
  1130. .title {
  1131. font-size: 28rpx;
  1132. color: #999;
  1133. }
  1134. .controlCard {
  1135. display: flex;
  1136. align-items: center;
  1137. justify-content: space-between;
  1138. width: 100%;
  1139. margin-top: 30rpx;
  1140. background: #fff;
  1141. box-sizing: border-box;
  1142. .preBtn {
  1143. display: flex;
  1144. align-items: center;
  1145. justify-content: space-around;
  1146. flex-direction: column;
  1147. width: 22%;
  1148. padding: 20rpx;
  1149. height: 80px;
  1150. font-size: 24rpx;
  1151. }
  1152. .btnBox {
  1153. display: flex;
  1154. align-items: center;
  1155. justify-content: center;
  1156. height: 48px;
  1157. width: 48px;
  1158. border-radius: 48px;
  1159. color: #fff;
  1160. .text {
  1161. display: inline-block;
  1162. width: 80vw;
  1163. font-size: 20px;
  1164. }
  1165. }
  1166. .preInfo {
  1167. display: flex;
  1168. align-items: center;
  1169. box-sizing: border-box;
  1170. padding: 32rpx !important;
  1171. background: #fff;
  1172. margin-bottom: 32rpx;
  1173. .btnBox {
  1174. width: 72rpx;
  1175. height: 72rpx;
  1176. background: #14a478;
  1177. }
  1178. .textBox {
  1179. margin-left: 40rpx;
  1180. font-size: 32rpx;
  1181. .name {
  1182. font-size: 24rpx;
  1183. color: #999;
  1184. }
  1185. }
  1186. }
  1187. }
  1188. .noBg {
  1189. background: none;
  1190. }
  1191. .u-border-bottom:after,
  1192. .u-border-left:after,
  1193. .u-border-right:after,
  1194. .u-border-top-bottom:after,
  1195. .u-border-top:after,
  1196. .u-border:after {
  1197. content: " ";
  1198. position: absolute;
  1199. left: 0;
  1200. top: 0;
  1201. pointer-events: none;
  1202. box-sizing: border-box;
  1203. -webkit-transform-origin: 0 0;
  1204. transform-origin: 0 0;
  1205. width: 199.8%;
  1206. height: 199.7%;
  1207. -webkit-transform: scale(.5);
  1208. transform: scale(.5);
  1209. border: .5px solid #E5EBE9;
  1210. z-index: 2;
  1211. }
  1212. }
  1213. .expireBox {
  1214. width: 80%;
  1215. margin: 0 auto;
  1216. padding: 20rpx;
  1217. box-sizing: border-box;
  1218. max-height: 60vh;
  1219. overflow: auto;
  1220. }
  1221. .bgColor {
  1222. width: 100%;
  1223. box-sizing: border-box;
  1224. background: #fff;
  1225. padding: 0 20rpx;
  1226. .u-form{
  1227. height: calc(100vh - 68rpx);
  1228. overflow: auto;
  1229. box-sizing: border-box;
  1230. padding: 20rpx 0;
  1231. }
  1232. .btn {
  1233. margin-left: 20rpx;
  1234. }
  1235. }
  1236. .chartBox{
  1237. min-height: 400rpx;
  1238. background: #fff;
  1239. margin: 20rpx 0;
  1240. padding: 32rpx;
  1241. box-sizing: border-box;
  1242. background: #fff;
  1243. width: 100%;
  1244. .noEmpty{
  1245. height: 400rpx;
  1246. display: flex;
  1247. justify-content: center;
  1248. align-items: center;
  1249. }
  1250. .pestInfo{
  1251. padding: 32rpx 0;
  1252. box-sizing: border-box;
  1253. .pest{
  1254. font-size: 24rpx;
  1255. color: #666;
  1256. margin-bottom: 16rpx;
  1257. .name{
  1258. margin-left: 10rpx;
  1259. color: #333;
  1260. font-weight: 600;
  1261. }
  1262. }
  1263. }
  1264. .pestStatus{
  1265. box-sizing: border-box;
  1266. display: flex;
  1267. align-items: center;
  1268. justify-content: space-between;
  1269. background: #fff;
  1270. height: 284rpx;
  1271. .block{
  1272. display: flex;
  1273. align-items: center;
  1274. flex-direction: column;
  1275. justify-content: space-around;
  1276. width: 33%;
  1277. height: 100%;
  1278. text-align: center;
  1279. }
  1280. .active{
  1281. background: #f7f7f7;
  1282. }
  1283. .iconBox{
  1284. display: flex;
  1285. align-items: center;
  1286. justify-content: center;
  1287. width: 128rpx;
  1288. height: 128rpx;
  1289. border-radius: 128rpx;
  1290. color: #fff;
  1291. .yficonfont{
  1292. font-size: 80rpx;
  1293. }
  1294. }
  1295. .blueText{
  1296. color: #14a478;
  1297. }
  1298. .yellowText{
  1299. color: #f4a72f;
  1300. }
  1301. .redText{
  1302. color: #FF0000;
  1303. }
  1304. }
  1305. }
  1306. .imgList{
  1307. height: calc(100vh - 220rpx);
  1308. overflow: auto;
  1309. box-sizing: border-box;
  1310. padding: 20rpx 0;
  1311. .preImg{
  1312. position: relative;
  1313. float: left;
  1314. width: 49%;
  1315. margin-right: 2%;
  1316. margin-bottom: 20rpx;
  1317. .text{
  1318. position: absolute;
  1319. bottom: 0;
  1320. left: 0;
  1321. width: 100%;
  1322. height: 40rpx;
  1323. line-height: 40rpx;
  1324. text-align: center;
  1325. color: #fff;
  1326. background: rgba(0, 0, 0, .4);
  1327. font-size: 24rpx;
  1328. z-index: 2;
  1329. }
  1330. }
  1331. .preImg:nth-child(2n) {
  1332. margin-right: 0; /* 每个第 3 个元素的右边距为 0 */
  1333. }
  1334. .loadBox{
  1335. width: 100%;
  1336. }
  1337. /deep/ .u-calendar__action{
  1338. display: flex;
  1339. justify-content: space-between;
  1340. }
  1341. }
  1342. </style>