equip-detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view>
  3. <view :class="['info',equipInfo.device_status==1?'on':'off']">
  4. <view class="">
  5. 设备ID:{{equipInfo.device_id}}
  6. </view>
  7. <view class="">
  8. 设备名称:{{equipInfo.device_name}}
  9. </view>
  10. <view class="">
  11. 设备类型:{{equipInfo.type|equipType}}
  12. </view>
  13. <view class="">
  14. 最近上报时间:{{equipInfo.status_time | timeFormat}}
  15. </view>
  16. <view class="">
  17. 设备地址:{{equipInfo.address}}
  18. </view>
  19. </view>
  20. <view class="equip_part">
  21. <template v-if="equipInfo.type==7">
  22. <view class="item1" v-for="item in bzy" @click="partClick(item.path)">
  23. <image :src="item.icon" mode="widthFix"></image>
  24. <view class="">
  25. {{item.tex}}
  26. </view>
  27. </view>
  28. </template>
  29. <template v-else>
  30. <view class="item2" v-for="item in curEquip" @click="partClick(item.path)">
  31. <image :src="item.icon" mode="widthFix"></image>
  32. <view class="">
  33. {{item.tex}}
  34. </view>
  35. </view>
  36. </template>
  37. </view>
  38. <view class="tit">
  39. 实时数据
  40. </view>
  41. <view class="newState">
  42. <view class="item" v-for="item in curState">
  43. <image :src="item.icon" mode="widthFix"></image>
  44. <view class="info-con">
  45. <view class="active">
  46. {{item.txt}}
  47. </view>
  48. <view class="val" >
  49. {{item.value | formatValue(item.txt,type)}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. type:null,//设备类型
  61. device_status:null,
  62. equipInfo:{},
  63. cbd:[
  64. {
  65. icon:'/static/image/cb/1.png',
  66. tex:'查看图片',
  67. path:'',
  68. }, {
  69. icon:'/static/image/cb/2.png',
  70. tex:'历史数据',
  71. path:'',
  72. }, {
  73. icon:'/static/image/cb/3.png',
  74. tex:'害虫统计',
  75. path:'',
  76. }, {
  77. icon:'/static/image/cb/4.png',
  78. tex:'设备控制',
  79. path:'/pages/cb/cbd/equip-set/equip-set',
  80. }, {
  81. icon:'/static/image/cb/5.png',
  82. tex:'短信预警',
  83. path:'',
  84. }, {
  85. icon:'/static/image/cb/6.png',
  86. tex:'sim卡详情',
  87. path:'',
  88. }
  89. ],
  90. bzy:[
  91. {
  92. icon:'/static/image/cb/4.png',
  93. tex:'设备控制',
  94. path:''
  95. },{
  96. icon:'/static/image/cb/1.png',
  97. tex:'查看图片',
  98. path:''
  99. },{
  100. icon:'/static/image/cb/2.png',
  101. tex:'历史数据',
  102. path:''
  103. },{
  104. icon:'/static/image/cb/6.png',
  105. tex:'sim卡详情',
  106. path:''
  107. }
  108. ],
  109. xy:[
  110. {
  111. icon:'/static/image/cb/4.png',
  112. tex:'设备控制',
  113. path:''
  114. },{
  115. icon:'/static/image/cb/6.png',
  116. tex:'sim卡详情',
  117. path:''
  118. },{
  119. icon:'/static/image/cb/2.png',
  120. tex:'历史数据',
  121. path:''
  122. }
  123. ],
  124. newState:{},//设备最新状态
  125. }
  126. },
  127. computed:{
  128. curEquip(){
  129. switch(this.type){
  130. case 3:
  131. return this.cbd;
  132. case 7:
  133. return this.bzy;
  134. case 4:
  135. return this.xy
  136. }
  137. },
  138. curState(){
  139. switch(this.type){
  140. case 3:
  141. let blbs=""//灯管状态
  142. if (this.newState.lamp != undefined) {
  143. if (this.newState.ws == 1) {
  144. if (this.newState.lamp == 1) {
  145. blbs = "工作中";
  146. } else if (dht.lux == 0) {
  147. blbs = "N/A(未检测到传感器)";
  148. } else {
  149. blbs = "异常";
  150. }
  151. } else {
  152. blbs = "关闭";
  153. }
  154. } else {
  155. blbs = "--";
  156. }
  157. return [
  158. {
  159. icon:'/static/image/cb/icon02.png',
  160. txt:'在线状态',
  161. value:this.device_status==1?'在线':'离线',
  162. },
  163. {
  164. icon:'/static/image/cb/icon02.png',
  165. txt:'开关状态',
  166. value:this.newState.ds==1?'关机':'开机'
  167. },
  168. {
  169. icon:'/static/image/cb/icon02.png',
  170. txt:'通道状态',
  171. value:this.newState.upds==1?'落虫':'排水'
  172. },
  173. {
  174. icon:'/static/image/cb/icon02.png',
  175. txt:'加热状态',
  176. value:this.newState.hs==1?'加热':'正常'
  177. },{
  178. icon:'/static/image/cb/icon02.png',
  179. txt:'环境温度(℃)',
  180. value:this.newState.at
  181. },{
  182. icon:'/static/image/cb/icon02.png',
  183. txt:'环境湿度(%)',
  184. value:this.newState.ah
  185. },{
  186. icon:'/static/image/cb/icon02.png',
  187. txt:'信号强度',
  188. value:this.newState.csq
  189. },{
  190. icon:'/static/image/cb/icon02.png',
  191. txt:'设备版本',
  192. value:this.newState.dver
  193. },
  194. {
  195. icon:'/static/image/cb/icon02.png',
  196. txt:'雨控状态',
  197. value:this.newState.rps==1?"雨控":'正常'
  198. },{
  199. icon:'/static/image/cb/icon02.png',
  200. txt:'温控状态',
  201. value:this.newState.tps==1?"温控":'正常'
  202. },{
  203. icon:'/static/image/cb/icon02.png',
  204. txt:'光控状态',
  205. value:this.newState.lps==1?"光控":'正常'
  206. },{
  207. icon:'/static/image/cb/icon02.png',
  208. txt:'灯管状态',
  209. value:blbs
  210. },{
  211. icon:'/static/image/cb/icon02.png',
  212. txt:'上仓门',
  213. value:this.newState.upds==1?"打开":'关闭'
  214. },{
  215. icon:'/static/image/cb/icon02.png',
  216. txt:'下仓门',
  217. value:this.newState.dnds==1?"打开":'关闭'
  218. }
  219. ]
  220. case 7:
  221. return [{
  222. icon:'/static/image/cb/icon02.png',
  223. txt:'在线状态',
  224. value:this.device_status==1?'在线':'离线',
  225. },
  226. {
  227. icon:'/static/image/cb/icon02.png',
  228. txt:'设备开关',
  229. value:this.newState.on_off==1?'开启':'关闭'
  230. },
  231. {
  232. icon:'/static/image/cb/icon02.png',
  233. txt:'摄像头状态',
  234. value:this.newState.usb_sta==1?'异常':'正常'
  235. },
  236. {
  237. icon:'/static/image/cb/icon02.png',
  238. txt:'当前电压',
  239. value:this.newState.v_bat
  240. },{
  241. icon:'/static/image/cb/icon02.png',
  242. txt:'环境温度(℃)',
  243. value:this.newState.at
  244. },{
  245. icon:'/static/image/cb/icon02.png',
  246. txt:'环境湿度(%)',
  247. value:this.newState.ah
  248. },{
  249. icon:'/static/image/cb/icon02.png',
  250. txt:'信号强度',
  251. value:this.newState.csq
  252. },{
  253. icon:'/static/image/cb/icon02.png',
  254. txt:'已培养时间',
  255. value:this.newState.staytime
  256. },{
  257. icon:'/static/image/cb/icon02.png',
  258. txt:'设备版本',
  259. value:this.newState.dver
  260. },{
  261. icon:'/static/image/cb/icon02.png',
  262. txt:'保温仓当前温度',
  263. value:this.newState.dver
  264. },{
  265. icon:'/static/image/cb/icon02.png',
  266. txt:'保温仓设定温度',
  267. value:this.newState.dver
  268. },{
  269. icon:'/static/image/cb/icon02.png',
  270. txt:'经度',
  271. value:this.newState.lng
  272. },{
  273. icon:'/static/image/cb/icon02.png',
  274. txt:'纬度',
  275. value:this.newState.lat
  276. },];
  277. case 4:
  278. return [{
  279. icon:'/static/image/cb/icon02.png',
  280. txt:'在线状态',
  281. value:this.device_status==1?'在线':'离线',
  282. },
  283. {
  284. icon:'/static/image/cb/icon02.png',
  285. txt:'设备开关',
  286. value:this.newState.ds==1?'开启':'关闭'
  287. },
  288. {
  289. icon:'/static/image/cb/icon02.png',
  290. txt:'工作状态',
  291. value:this.newState.ws==1?'工作':' 待机'
  292. },
  293. {
  294. icon:'/static/image/cb/icon02.png',
  295. txt:'环境温度(℃)',
  296. value:this.newState.at
  297. },
  298. {
  299. icon:'/static/image/cb/icon02.png',
  300. txt:'环境湿度(%)',
  301. value:this.newState.ah
  302. },
  303. {
  304. icon:'/static/image/cb/icon02.png',
  305. txt:'充电电压',
  306. value:this.newState.cv
  307. },
  308. {
  309. icon:'/static/image/cb/icon02.png',
  310. txt:'电池电压',
  311. value:this.newState.bv
  312. },
  313. {
  314. icon:'/static/image/cb/icon02.png',
  315. txt:'信号强度',
  316. value:this.newState.csq
  317. },
  318. {
  319. icon:'/static/image/cb/icon02.png',
  320. txt:'设备版本',
  321. value:this.newState.dver
  322. },
  323. {
  324. icon:'/static/image/cb/icon02.png',
  325. txt:'充电状态',
  326. value:this.newState.cs==1?'充电':'正常'
  327. },
  328. {
  329. icon:'/static/image/cb/icon02.png',
  330. txt:'电池状态',
  331. value:this.newState.bs
  332. },
  333. ]
  334. }
  335. }
  336. },
  337. filters:{
  338. equipType(type){
  339. switch(type){
  340. case 3:
  341. return "虫情测报灯";
  342. case 7:
  343. return "孢子仪";
  344. case 4:
  345. return "性诱测报"
  346. }
  347. },
  348. formatValue(val,a1,a2){
  349. if(a2==4&&a1=="电池状态"){
  350. switch(val){
  351. case 0:
  352. return '正常';
  353. break;
  354. case 1:
  355. return '欠压';
  356. break;
  357. case 2:
  358. return '过压';
  359. break;
  360. }
  361. }else{
  362. return val?val:'无'
  363. }
  364. }
  365. },
  366. onLoad(option){
  367. this.equipInfo=JSON.parse(option.info)
  368. this.type=this.equipInfo.type
  369. this.device_status=this.equipInfo.device_status
  370. this.getState()
  371. console.log(this.equipInfo)
  372. },
  373. methods: {
  374. async getState(){
  375. const res=await this.$myRequest({
  376. url:'/api/api_gateway?method=forecast.worm_lamp.device_history_data',
  377. data:{
  378. device_type_id:this.equipInfo.type,
  379. device_id:this.equipInfo.device_id,
  380. page: 1,
  381. page_size:1,
  382. }
  383. })
  384. this.newState=res.data[0].d_h_t
  385. },
  386. partClick(path){
  387. console.log(this.equipInfo)
  388. uni.navigateTo({
  389. url:path+ '?d_id=' + this.equipInfo.d_id
  390. });
  391. }
  392. },
  393. }
  394. </script>
  395. <style lang='scss'>
  396. page{
  397. padding:20rpx;
  398. .info{
  399. padding:20rpx 40rpx;
  400. color:#fff;
  401. line-height:50rpx;
  402. font-size:26rpx;
  403. background-size:100% auto;
  404. background-repeat: no-repeat;
  405. background-color:#0DC6B6;
  406. background-position: top left;
  407. }
  408. .on{
  409. background-image:url('../../../static/image/cb/onBg.png')
  410. }
  411. .off{
  412. background-image:url('../../../static/image/cb/offBg.png')
  413. }
  414. .equip_part{
  415. display:flex;
  416. flex-wrap:wrap;
  417. text-align: center;
  418. font-size:28rpx;
  419. color:#666;
  420. line-height:50rpx;
  421. image{
  422. width:52rpx;
  423. }
  424. .item1{
  425. padding:20rpx 10rpx;
  426. box-sizing: border-box;
  427. flex-basis:25%;
  428. }
  429. .item2{
  430. padding:20rpx;
  431. box-sizing: border-box;
  432. flex-basis:33%;
  433. flex-grow:1;
  434. }
  435. }
  436. .tit{
  437. font-weight:800;
  438. line-height:50rpx;
  439. font-size:30rpx;
  440. margin-bottom:20rpx;
  441. }
  442. .newState{
  443. display:flex;
  444. flex-wrap:wrap;
  445. text-align: center;
  446. margin:0 -10rpx;
  447. .item{
  448. display:flex;
  449. flex-wrap: wrap;
  450. margin:10rpx;
  451. width: 345rpx;
  452. justify-content:flex-start;
  453. padding:20rpx;
  454. box-sizing: border-box;
  455. border-radius: 4px;
  456. box-shadow: 0px 0px 5px 3px rgba(136,136,136,.1);
  457. font-size:24rpx;
  458. .info-con{
  459. padding-left:30rpx;
  460. text-align: left;
  461. line-height:40rpx;
  462. }
  463. image{width:70rpx;}
  464. }
  465. }
  466. }
  467. </style>