thxydetail.vue 12 KB

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