detail.vue 35 KB

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