detail.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368
  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">
  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="90%" :async-close="true" :show-cancel-button="true"
  202. @confirm="devicePhotoTime">
  203. <view class="slot-content">
  204. <view class="expireBox">
  205. <u-form>
  206. <u-form-item :label="`时间${index + 1}`" :label-width="180"
  207. v-for="(time, index) in photoTimeArray" :key="time.key">
  208. <text @click="time.show = true">{{time.value}}</text> <u-button size="mini" type="error"
  209. @click="removeTime(index)">删除</u-button>
  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. padding: 20rpx;
  1214. box-sizing: border-box;
  1215. max-height: 60vh;
  1216. overflow: auto;
  1217. }
  1218. .bgColor {
  1219. width: 100%;
  1220. box-sizing: border-box;
  1221. background: #fff;
  1222. padding: 0 20rpx;
  1223. .u-form{
  1224. height: calc(100vh - 68rpx);
  1225. overflow: auto;
  1226. box-sizing: border-box;
  1227. padding: 20rpx 0;
  1228. }
  1229. .btn {
  1230. margin-left: 20rpx;
  1231. }
  1232. }
  1233. .chartBox{
  1234. min-height: 400rpx;
  1235. background: #fff;
  1236. margin: 20rpx 0;
  1237. padding: 32rpx;
  1238. box-sizing: border-box;
  1239. background: #fff;
  1240. width: 100%;
  1241. .noEmpty{
  1242. height: 400rpx;
  1243. display: flex;
  1244. justify-content: center;
  1245. align-items: center;
  1246. }
  1247. .pestInfo{
  1248. padding: 32rpx 0;
  1249. box-sizing: border-box;
  1250. .pest{
  1251. font-size: 24rpx;
  1252. color: #666;
  1253. margin-bottom: 16rpx;
  1254. .name{
  1255. margin-left: 10rpx;
  1256. color: #333;
  1257. font-weight: 600;
  1258. }
  1259. }
  1260. }
  1261. .pestStatus{
  1262. box-sizing: border-box;
  1263. display: flex;
  1264. align-items: center;
  1265. justify-content: space-between;
  1266. background: #fff;
  1267. height: 284rpx;
  1268. .block{
  1269. display: flex;
  1270. align-items: center;
  1271. flex-direction: column;
  1272. justify-content: space-around;
  1273. width: 33%;
  1274. height: 100%;
  1275. text-align: center;
  1276. }
  1277. .active{
  1278. background: #f7f7f7;
  1279. }
  1280. .iconBox{
  1281. display: flex;
  1282. align-items: center;
  1283. justify-content: center;
  1284. width: 128rpx;
  1285. height: 128rpx;
  1286. border-radius: 128rpx;
  1287. color: #fff;
  1288. .yficonfont{
  1289. font-size: 80rpx;
  1290. }
  1291. }
  1292. .blueText{
  1293. color: #14a478;
  1294. }
  1295. .yellowText{
  1296. color: #f4a72f;
  1297. }
  1298. .redText{
  1299. color: #FF0000;
  1300. }
  1301. }
  1302. }
  1303. .imgList{
  1304. height: calc(100vh - 220rpx);
  1305. overflow: auto;
  1306. box-sizing: border-box;
  1307. padding: 20rpx 0;
  1308. .preImg{
  1309. position: relative;
  1310. float: left;
  1311. width: 49%;
  1312. margin-right: 2%;
  1313. margin-bottom: 20rpx;
  1314. .text{
  1315. position: absolute;
  1316. bottom: 0;
  1317. left: 0;
  1318. width: 100%;
  1319. height: 40rpx;
  1320. line-height: 40rpx;
  1321. text-align: center;
  1322. color: #fff;
  1323. background: rgba(0, 0, 0, .4);
  1324. font-size: 24rpx;
  1325. z-index: 2;
  1326. }
  1327. }
  1328. .preImg:nth-child(2n) {
  1329. margin-right: 0; /* 每个第 3 个元素的右边距为 0 */
  1330. }
  1331. .loadBox{
  1332. width: 100%;
  1333. }
  1334. /deep/ .u-calendar__action{
  1335. display: flex;
  1336. justify-content: space-between;
  1337. }
  1338. }
  1339. </style>