thxydetail.vue 12 KB

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