thxydetail.vue 14 KB

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