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