thxydetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view>
  3. <view :class="['info', equipInfo.is_online == 1 ? 'on' : 'off']">
  4. <view class="" @click="copy(equipInfo)">
  5. 设备ID:{{ equipInfo.imei || equipInfo.device_id }}
  6. <image
  7. src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png"
  8. mode=""
  9. class="tishi"
  10. >
  11. </image>
  12. </view>
  13. <view class="">
  14. 设备名称:{{
  15. equipInfo.device_name == '' ? '无' : equipInfo.device_name
  16. }}
  17. </view>
  18. <view class=""> 设备类型:性诱3.0 </view>
  19. <view class="">
  20. 最新上报时间:{{ equipInfo.uptime || equipInfo.uptime | timeFormat }}
  21. </view>
  22. <view class=""> 设备地址:{{ equipInfo.address }} </view>
  23. <view class="" @click="setdecoy">
  24. 诱芯名称:{{ equipInfo.decoy }}
  25. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  26. </view>
  27. <view class="" @click="setdecoy">
  28. 诱芯到期时间:{{ equipInfo.xy_expire }}
  29. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  30. </view>
  31. </view>
  32. <u-popup v-model="yxShow" mode="center" width="600rpx">
  33. <u-field
  34. label="害虫名称"
  35. label-width="240"
  36. required
  37. :error-message="xyErr"
  38. v-model="decoy"
  39. class="field"
  40. :field-style="fieldstyle"
  41. placeholder="请填写害虫名称"
  42. >
  43. </u-field>
  44. <u-field
  45. label="诱芯到期时间"
  46. label-width="240"
  47. required
  48. :error-message="xyErrtime"
  49. v-model="decoytime"
  50. @click="settime"
  51. class="field"
  52. :field-style="fieldstyle"
  53. placeholder="请填写到期时间"
  54. >
  55. </u-field>
  56. <view class="" style="text-align: center; color: #fa3534">
  57. {{ tishitext }}
  58. </view>
  59. <view class="btn-box">
  60. <u-button @click="yxSubmit" size="mini" type="success" class="box-item"
  61. >确定</u-button
  62. >
  63. </view>
  64. </u-popup>
  65. <u-calendar
  66. v-model="tiemshow"
  67. mode="date"
  68. :max-date="date"
  69. @change="tiemchange"
  70. ></u-calendar>
  71. <view class="caobox">
  72. <view class="caobox_item" v-if="$QueryPermission(200)" @click="tophoto">
  73. <image
  74. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/1.png"
  75. mode="widthFix"
  76. ></image>
  77. <view class=""> 查看图片 </view>
  78. </view>
  79. <view class="caobox_item" v-if="$QueryPermission(248)" @click="toset">
  80. <image
  81. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/4.png"
  82. mode="widthFix"
  83. ></image>
  84. <view class=""> 设备控制 </view>
  85. </view>
  86. <view class="caobox_item" v-if="$QueryPermission(247)" @click="tosim">
  87. <image
  88. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/6.png"
  89. mode="widthFix"
  90. ></image>
  91. <view class=""> SIM卡 </view>
  92. </view>
  93. <view class="caobox_item" v-if="$QueryPermission(199)" @click="tohis">
  94. <image
  95. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/2.png"
  96. mode="widthFix"
  97. ></image>
  98. <view class=""> 历史数据 </view>
  99. </view>
  100. </view>
  101. <view class="realtime">
  102. <view class="realtime_title">
  103. <p>实时数据</p>
  104. </view>
  105. <view class="realtime_text">
  106. <view class="realtime_item">
  107. <image
  108. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/wendu.png"
  109. mode=""
  110. ></image>
  111. <view class="text">
  112. <p>环境温度</p>
  113. <p>{{ at }}℃</p>
  114. </view>
  115. </view>
  116. <view class="realtime_item">
  117. <image
  118. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/shidu.png"
  119. mode=""
  120. ></image>
  121. <view class="text">
  122. <p>环境湿度</p>
  123. <p>{{ ah }}%</p>
  124. </view>
  125. </view>
  126. <view class="realtime_item">
  127. <image
  128. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/tianqi.png"
  129. mode=""
  130. ></image>
  131. <view class="text">
  132. <p>天气</p>
  133. <p>{{ wea }}</p>
  134. </view>
  135. </view>
  136. <view class="realtime_item">
  137. <image
  138. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/xiayu.png"
  139. mode=""
  140. ></image>
  141. <view class="text">
  142. <p>是否下雨</p>
  143. <p>{{ rain }}</p>
  144. </view>
  145. </view>
  146. <view class="realtime_item">
  147. <image
  148. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/fengxiang.png"
  149. mode=""
  150. ></image>
  151. <view class="text">
  152. <p>风力风向</p>
  153. <p>{{ wind }}</p>
  154. </view>
  155. </view>
  156. <view class="realtime_item">
  157. <image
  158. src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/xy2.0/yujing.png"
  159. mode=""
  160. ></image>
  161. <view class="text">
  162. <p>诱虫次数</p>
  163. <p>{{ wormnum }}</p>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. </template>
  170. <script>
  171. export default {
  172. data() {
  173. return {
  174. baseimei: '',
  175. equipInfo: {},
  176. trapnum: 1,
  177. at: '',
  178. ah: '',
  179. wind: '',
  180. wea: '',
  181. rain: '',
  182. wormnum: '',
  183. decoy: '',
  184. xyErr: '',
  185. xyErrtime: '',
  186. decoytime: '',
  187. yxShow: false,
  188. tiemshow: false,
  189. date: '',
  190. fieldstyle: {
  191. //输入框样式
  192. border: '2rpx solid #f6f6f6',
  193. 'border-radius': '24px',
  194. 'padding-left': '20rpx',
  195. 'background-color': '#f6f6f6',
  196. },
  197. tishitext: '',
  198. };
  199. },
  200. methods: {
  201. tosim() {
  202. uni.navigateTo({
  203. url:
  204. '/pages/prevention/sim?d_id=' +
  205. this.equipInfo.d_id +
  206. '&device_id=' +
  207. this.equipInfo.imei +
  208. '&device_type=' +
  209. this.equipInfo.type +
  210. '&disable=' +
  211. this.equipInfo.disable,
  212. });
  213. },
  214. tophoto() {
  215. uni.navigateTo({
  216. url:
  217. './photolist?device_id=' +
  218. this.equipInfo.imei +
  219. '&d_id=' +
  220. this.equipInfo.d_id,
  221. });
  222. },
  223. toset() {
  224. uni.navigateTo({
  225. url:
  226. './thxyset?device_id=' +
  227. this.equipInfo.imei +
  228. '&d_id=' +
  229. this.equipInfo.d_id +
  230. '&dtype=' +
  231. this.equipInfo.dtype +
  232. '&device_name=' +
  233. this.equipInfo.device_name,
  234. });
  235. },
  236. tohis() {
  237. uni.navigateTo({
  238. url:
  239. './thxyhisdata?device_id=' +
  240. this.equipInfo.imei +
  241. '&d_id=' +
  242. this.equipInfo.d_id,
  243. });
  244. },
  245. copy(item) {
  246. console.log(item);
  247. uni.setClipboardData({
  248. data: item.imei || item.device_id,
  249. success: function () {
  250. console.log('success');
  251. },
  252. });
  253. },
  254. async getbaseinfo() {
  255. const res = await this.$myRequest({
  256. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_list',
  257. data: {
  258. device_id: this.baseimei,
  259. device_type_id: '8',
  260. page: '1',
  261. page_size: '10',
  262. },
  263. });
  264. console.log(res.data[0]);
  265. this.equipInfo = res.data[0];
  266. this.getatah();
  267. this.getwind();
  268. this.getweather();
  269. this.getworm();
  270. },
  271. async getatah() {
  272. const res = await this.$myRequest({
  273. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_at_ah',
  274. data: {
  275. device_type_id: 8,
  276. d_id: this.equipInfo.d_id,
  277. start_time: Math.floor(+new Date() / 1000 - 30 * 24 * 60 * 60),
  278. end_time: Math.floor(+new Date() / 1000),
  279. },
  280. });
  281. console.log(res);
  282. if (res.length) {
  283. this.at = res[0].at;
  284. this.ah = res[0].ah;
  285. } else {
  286. this.at = '暂无';
  287. this.ah = '暂无';
  288. }
  289. },
  290. async getwind() {
  291. const res = await this.$myRequest({
  292. url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_history_data',
  293. data: {
  294. d_id: this.equipInfo.d_id,
  295. start_time: Math.floor(+new Date() / 1000 - 30 * 24 * 60 * 60),
  296. end_time: Math.floor(+new Date() / 1000),
  297. device_id: this.equipInfo.imei,
  298. page: 1,
  299. },
  300. });
  301. // console.log(res.data[0].d_h_t)
  302. if (res.data[0]) {
  303. var fs = res.data[0].d_h_t.wind_sped;
  304. let fx = res.data[0].d_h_t.wind_drec;
  305. // if (fx > 337.5 || fx < 22.5) {
  306. if (
  307. (fx < 360 && fx > 337.5) ||
  308. (fx < 22.5 && fx > 0) ||
  309. fx == 0 ||
  310. fx == 360
  311. ) {
  312. fx = '北';
  313. } else if (fx > 22.5 && fx < 67.5) {
  314. fx = '东北';
  315. } else if (fx > 67.5 && fx < 112.5) {
  316. fx = '东';
  317. } else if (fx > 112.5 && fx < 157.5) {
  318. fx = '东南';
  319. } else if (fx > 157.5 && fx < 202.5) {
  320. fx = '南';
  321. } else if (fx > 202.5 && fx < 247.5) {
  322. fx = '西南';
  323. } else if (fx > 247.5 && fx < 292.5) {
  324. fx = '西';
  325. } else if (fx > 292.5 && fx < 337.5) {
  326. fx = '西北';
  327. } else if (fx == 666) {
  328. fx = '无';
  329. }
  330. if (fs >= 66.6) {
  331. fs = 0;
  332. }
  333. // this.monitordata[4].key = fx + "风" + fs + "级";
  334. this.wind = fx + '风' + fs + '级';
  335. } else {
  336. this.wind = '暂无';
  337. }
  338. },
  339. async getweather() {
  340. const res = await this.$myRequest({
  341. url: '/api/api_gateway?method=device.device_manage.weathers',
  342. data: {
  343. lng: Number(this.equipInfo.lng),
  344. lat: Number(this.equipInfo.lat),
  345. },
  346. });
  347. console.log(res);
  348. // this.
  349. if (res[0]) {
  350. this.wea = res[0].wea;
  351. this.rain = res[0].wea.indexOf('雨') == -1 ? '否' : '是';
  352. } else {
  353. this.wea = '暂无';
  354. this.rain = '暂无';
  355. }
  356. },
  357. async getworm() {
  358. const res = await this.$myRequest({
  359. url: '/api/api_gateway?method=forecast.worm_lamp.xycb_pest_chart',
  360. data: {
  361. d_id: this.equipInfo.d_id,
  362. start_time: Math.floor(+new Date() / 1000 - 30 * 24 * 60 * 60),
  363. end_time: Math.floor(+new Date() / 1000),
  364. device_type_id: '8',
  365. },
  366. });
  367. console.log(res);
  368. if (res.pest_data.length) {
  369. this.wormnum = res.pest_data[0].pest_num;
  370. } else {
  371. this.wormnum = '暂无';
  372. }
  373. },
  374. setdecoy() {
  375. this.decoy = this.equipInfo.decoy;
  376. this.decoytime = this.equipInfo.xy_expire;
  377. this.yxShow = true;
  378. },
  379. settime() {
  380. console.log(12);
  381. this.tiemshow = true;
  382. },
  383. tiemchange(e) {
  384. console.log(e);
  385. this.decoytime = e.result;
  386. },
  387. async yxSubmit() {
  388. var time = Math.floor(+new Date(this.decoytime) / 1000);
  389. console.log(time);
  390. if (this.decoy == '') {
  391. this.tishitext = '请填写诱芯名称';
  392. return;
  393. } else if (isNaN(time)) {
  394. this.tishitext = '请填写诱芯到期时间';
  395. return;
  396. }
  397. this.tishitext = '';
  398. const res = await this.$myRequest({
  399. url: '/api/api_gateway?method=forecast.worm_lamp.set_decopy',
  400. data: {
  401. decoy: this.decoy,
  402. device_id: this.equipInfo.imei,
  403. device_type_id: '8',
  404. expire_time: time,
  405. },
  406. });
  407. console.log(res);
  408. if (res.status) {
  409. uni.showToast({
  410. title: '设置成功',
  411. icon: 'none',
  412. });
  413. this.yxShow = false;
  414. this.getbaseinfo();
  415. }
  416. },
  417. },
  418. onLoad(option) {
  419. var times = new Date();
  420. this.date =
  421. times.getFullYear() +
  422. 1 +
  423. '-' +
  424. Number(times.getMonth() + 1) +
  425. '-' +
  426. times.getDate();
  427. this.baseimei = option.imei;
  428. // console.log(this.equipInfo)
  429. this.getbaseinfo();
  430. },
  431. };
  432. </script>
  433. <style lang="less">
  434. page {
  435. padding: 20rpx;
  436. box-sizing: border-box;
  437. .info {
  438. padding: 20rpx 40rpx;
  439. color: #fff;
  440. line-height: 50rpx;
  441. font-size: 26rpx;
  442. background-size: 100% auto;
  443. background-repeat: no-repeat;
  444. background-color: #0dc6b6;
  445. background-position: top left;
  446. box-sizing: border-box;
  447. width: 100%;
  448. .tishi {
  449. width: 28rpx;
  450. height: 28rpx;
  451. margin: 0rpx 0 0 20rpx;
  452. }
  453. }
  454. .on {
  455. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png');
  456. }
  457. .off {
  458. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png');
  459. }
  460. .caobox {
  461. display: flex;
  462. flex-wrap: wrap;
  463. text-align: center;
  464. font-size: 28rpx;
  465. color: #666;
  466. line-height: 50rpx;
  467. image {
  468. width: 52rpx;
  469. }
  470. .caobox_item {
  471. padding: 20rpx 0;
  472. box-sizing: border-box;
  473. flex-basis: 25%;
  474. }
  475. }
  476. .realtime {
  477. width: 95%;
  478. margin: 0rpx auto;
  479. .realtime_title {
  480. font-size: 32rpx;
  481. display: flex;
  482. justify-content: space-between;
  483. font-weight: 700;
  484. .span {
  485. color: #6e6c76;
  486. font-size: 24rpx;
  487. display: flex;
  488. justify-content: space-between;
  489. margin-top: 12rpx;
  490. }
  491. }
  492. .realtime_text {
  493. margin-top: 20rpx;
  494. display: flex;
  495. justify-content: space-between;
  496. flex-wrap: wrap;
  497. .realtime_item {
  498. width: 48%;
  499. height: 100rpx;
  500. display: flex;
  501. box-shadow: 0 0 10rpx #bcb9ca;
  502. margin-top: 20rpx;
  503. padding: 20rpx 0;
  504. image {
  505. width: 60rpx;
  506. height: 60rpx;
  507. margin: 20rpx 20rpx 20rpx 40rpx;
  508. }
  509. .text {
  510. padding: 10rpx 0 10rpx 30rpx;
  511. }
  512. }
  513. }
  514. }
  515. }
  516. .btn-box {
  517. text-align: center;
  518. padding: 20rpx 30rpx;
  519. }
  520. ::v-deep .u-calendar__action {
  521. display: flex;
  522. justify-content: space-around;
  523. .u-calendar__action__text {
  524. line-height: 25px;
  525. }
  526. }
  527. </style>