thxydetail.vue 14 KB

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