thxydetail.vue 14 KB

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