equipmentdetails.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  5. <view style="position: fixed;z-index: 100;width: 100%;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备详情"></uni-nav-bar>
  7. </view>
  8. <view class="info">
  9. <view class="info_item">
  10. <image
  11. :src="eqinfo.item.is_online==1?'http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png':'http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png'"
  12. mode="" class="bgi"></image>
  13. <p style="font-size: 32rpx;" @click="copy(eqinfo.item.imei || eqinfo.item.device_id)">设备
  14. ID:{{eqinfo.item.imei || eqinfo.item.device_id}}
  15. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode=""
  16. class="tishi"></image>
  17. </p>
  18. <p>设备名称:{{eqinfo.item.device_name?eqinfo.item.device_name:"无"}}</p>
  19. <p>设备型号:{{eqinfo.item.dtype}}</p>
  20. <p>最近上报时间:{{eqinfo.item.addtime|timeFormat()}}</p>
  21. <p>设备地址:{{city||eqinfo.item.address}}</p>
  22. </view>
  23. </view>
  24. <view class="control">
  25. <view class="control_item" v-if="kongtf" @click="control">
  26. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/8.png'" mode=""></image>
  27. <p>设备控制</p>
  28. </view>
  29. <view class="control_item" v-if="shujutf" @click="charts">
  30. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/10.png'" mode=""></image>
  31. <p>历史数据</p>
  32. </view>
  33. <view class="control_item" v-if="simtf" @click="sim">
  34. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/9.png'" mode=""></image>
  35. <p>SIM卡详情</p>
  36. </view>
  37. <view class="control_item" @click="repairs">
  38. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/7.png'" mode=""></image>
  39. <p>一键报修</p>
  40. </view>
  41. </view>
  42. <view class="realtime">
  43. <p class="realtime_title">实时数据</p>
  44. <view class="realtime_text">
  45. <view class="realtime_text_item">
  46. <view class="realtime_text_item_info" v-for="item,index in olddatas" :key="index">
  47. <view class="item_info_img">
  48. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+item.icon" mode=""></image>
  49. </view>
  50. <view class="item_info_text">
  51. <p>{{item.txt}}</p>
  52. <p style="margin-top: 20rpx;">{{item.value}}</p>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="realtime_tishi" v-if="!newdatesTF && !dataloadingtf">
  58. 暂无数据
  59. </view>
  60. <view class="realtime_tishi" v-if="dataloadingtf">
  61. <p class="dataloading">加载中</p>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. eqinfo: {
  72. item: {
  73. }
  74. },
  75. olddata: {},
  76. olddatas: [],
  77. newdatesTF: false, //暂无数据提示
  78. dataloadingtf: false, //加载中提示
  79. work: "",
  80. shujutf: false,
  81. kongtf: false,
  82. simtf: false
  83. }
  84. },
  85. methods: {
  86. modification() {
  87. this.olddatas = [{
  88. icon: '/image/cb/icon02.png',
  89. txt: '设备开关',
  90. value: Number(this.olddata.ds) == 1 ? '开机' : "关机",
  91. },
  92. {
  93. icon: '/image/cb/icon05.png',
  94. txt: '工作状态',
  95. value: this.work
  96. },
  97. {
  98. icon: '/image/prevention/44.png',
  99. txt: '电击次数',
  100. value: this.olddata.ct
  101. },
  102. {
  103. icon: '/image/prevention/33.png',
  104. txt: '定时时长',
  105. value: this.olddata.tt
  106. }, {
  107. icon: '/image/cb/icon08.png',
  108. txt: '环境温度(℃)',
  109. value: this.olddata.at == "" ? "--" : this.olddata.at
  110. }, {
  111. icon: '/image/cb/icon07.png',
  112. txt: '环境湿度(%)',
  113. value: this.olddata.ah == "" ? "--" : this.olddata.ah
  114. }, {
  115. icon: '/image/prevention/icon16.png',
  116. txt: '信号强度',
  117. value: this.olddata.csq
  118. }, {
  119. icon: '/image/prevention/100.png',
  120. txt: '清虫间隔(min)',
  121. value: this.olddata.clt_t
  122. }, {
  123. icon: '/image/prevention/101.png',
  124. txt: '雨控状态',
  125. value: Number(this.olddata.rps) == 1 ? "雨控" : '正常'
  126. }, {
  127. icon: '/image/prevention/102.png',
  128. txt: '温控状态',
  129. value: Number(this.olddata.tps) == 1 ? "温控" : '正常'
  130. },
  131. {
  132. icon: '/image/prevention/105.png',
  133. txt: '充电电压',
  134. value: this.olddata.cv
  135. },
  136. {
  137. icon: '/image/prevention/106.png',
  138. txt: '电池电压',
  139. value: Number(this.olddata.bv)
  140. }
  141. ]
  142. },
  143. async history() { //设备列表
  144. var newtime = +new Date() / 1000
  145. var oldtime = newtime - 24 * 60 * 60
  146. this.dataloadingtf = true
  147. const res = await this.$myRequest({
  148. url: '/api/api_gateway?method=forecast.worm_lamp.device_history_data',
  149. data: {
  150. device_type_id: 2,
  151. device_id: this.eqinfo.item.imei,
  152. start_time: parseInt(oldtime),
  153. end_time: parseInt(newtime)
  154. }
  155. })
  156. this.dataloadingtf = false
  157. if (res.data.length != 0) {
  158. this.olddata = res.data[0].d_h_t
  159. this.newdatesTF = true
  160. if (Number(this.olddata.ws) == 0) {
  161. this.work = "待机"
  162. } else if (Number(this.olddata.ws) == 1) {
  163. this.work = "工作"
  164. } else {
  165. this.work = "充电"
  166. }
  167. } else {
  168. this.newdatesTF = false
  169. }
  170. this.modification()
  171. },
  172. async eqlist(id) { //搜索
  173. const res = await this.$myRequest({
  174. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  175. data: {
  176. device_type_id: 2,
  177. device_id: id
  178. }
  179. })
  180. this.eqinfo.item = res.data[0]
  181. this.dataloadingtf = true
  182. this.history()
  183. },
  184. clickLeft() {
  185. uni.navigateBack({
  186. delta: 1
  187. })
  188. },
  189. sim() {
  190. // sim卡详情
  191. uni.navigateTo({
  192. url: "./sim?id=" + this.eqinfo.item.d_id
  193. })
  194. },
  195. repairs() {
  196. console.log(this.eqinfo.item)
  197. var device_id = this.eqinfo.item.equip_id || this.eqinfo.item.device_id
  198. uni.navigateTo({
  199. url: "../afterSale/addafter?device_id=" + device_id + "&device_type=" + 2
  200. })
  201. },
  202. control() { //设备控制
  203. uni.navigateTo({
  204. url: "./control?id=" + this.eqinfo.item.d_id
  205. })
  206. },
  207. charts() { //历史数据
  208. uni.navigateTo({
  209. url: "./ucharts?d_id=" + this.eqinfo.item.d_id + "&imei=" + this.eqinfo.item.imei
  210. })
  211. },
  212. copy(item) {
  213. uni.setClipboardData({
  214. data: item,
  215. success: function() {
  216. console.log('success');
  217. }
  218. });
  219. },
  220. selectaddress(lat, lng) { //获取分布位置
  221. uni.request({
  222. type: "GET",
  223. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  224. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  225. dataType: "json",
  226. complete: ress => {
  227. console.log(ress.data.regeocode.formatted_address)
  228. this.city = ress.data.regeocode.formatted_address
  229. }
  230. });
  231. },
  232. },
  233. onLoad(option) {
  234. this.$forceUpdate()
  235. this.eqinfo.item = JSON.parse(option.shebei)
  236. console.log(JSON.parse(option.shebei))
  237. this.eqlist(JSON.parse(option.shebei).device_id || JSON.parse(option.shebei).imei)
  238. this.selectaddress(this.eqinfo.item.lat, this.eqinfo.item.lng)
  239. uni.getStorage({
  240. key: "jurisdiction",
  241. success: (res) => {
  242. console.log(JSON.parse(res.data))
  243. let items = JSON.parse(res.data).filter((item) => {
  244. return item.purview_name == "防治系统"
  245. })
  246. let items2 = items[0].children.filter((item) => {
  247. return item.purview_name == "杀虫灯"
  248. })
  249. var arr = items2[0].children
  250. console.log(arr)
  251. for (var i = 0; i < arr.length; i++) {
  252. switch (arr[i].purview_name) {
  253. case "设备操作":
  254. this.kongtf = true
  255. break
  256. case "设备控制":
  257. this.kongtf = true
  258. break
  259. case "SIM卡状态":
  260. this.simtf = true
  261. break
  262. case "SIM卡":
  263. this.simtf = true
  264. break
  265. case "数据详情":
  266. this.shujutf = true
  267. break
  268. }
  269. }
  270. },
  271. })
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .info {
  277. width: 100%;
  278. position: absolute;
  279. top: 44px;
  280. .info_item {
  281. width: 90%;
  282. margin: 0 auto;
  283. height: 260rpx;
  284. padding: 26rpx 50rpx;
  285. position: relative;
  286. box-sizing: border-box;
  287. .bgi {
  288. width: 100%;
  289. height: 260rpx;
  290. position: absolute;
  291. top: 0;
  292. left: 0;
  293. z-index: -1;
  294. }
  295. p {
  296. font-size: 24rpx;
  297. color: #FFFFFF;
  298. margin-bottom: 10rpx;
  299. .tishi {
  300. width: 30rpx;
  301. height: 30rpx;
  302. margin: 0rpx 0 0 20rpx;
  303. }
  304. }
  305. }
  306. }
  307. .control {
  308. width: 90%;
  309. position: absolute;
  310. top: 372rpx;
  311. left: 5%;
  312. display: flex;
  313. justify-content: space-between;
  314. text-align: center;
  315. padding: 0 30rpx;
  316. box-sizing: border-box;
  317. .control_item {
  318. width: 120rpx;
  319. height: 120rpx;
  320. image {
  321. width: 70rpx;
  322. height: 70rpx;
  323. }
  324. p {
  325. font-size: 24rpx;
  326. }
  327. }
  328. }
  329. .realtime {
  330. width: 100%;
  331. position: absolute;
  332. top: 500rpx;
  333. .realtime_title {
  334. font-weight: 700;
  335. width: 90%;
  336. margin: 0 auto;
  337. }
  338. .realtime_tishi {
  339. width: 90%;
  340. margin: 0 auto;
  341. text-align: center;
  342. font-size: 32rpx;
  343. padding-top: 40rpx;
  344. .dataloading:after {
  345. overflow: hidden;
  346. display: inline-block;
  347. vertical-align: bottom;
  348. animation: ellipsis 2s infinite;
  349. content: "\2026";
  350. }
  351. @keyframes ellipsis {
  352. from {
  353. width: 2px;
  354. }
  355. to {
  356. width: 15px;
  357. }
  358. }
  359. }
  360. .realtime_text {
  361. width: 90%;
  362. margin: 0 auto;
  363. .realtime_text_item {
  364. width: 100%;
  365. display: flex;
  366. justify-content: space-between;
  367. flex-wrap: wrap;
  368. margin-bottom: 50rpx;
  369. .realtime_text_item_info {
  370. width: 48%;
  371. box-shadow: 0 0 10rpx #bcb9ca;
  372. margin-top: 20rpx;
  373. display: flex;
  374. padding: 20rpx 20rpx;
  375. box-sizing: border-box;
  376. .item_info_img {
  377. width: 30%;
  378. text-align: center;
  379. margin-right: 30rpx;
  380. image {
  381. width: 64rpx;
  382. height: 64rpx;
  383. margin-top: 10rpx;
  384. }
  385. }
  386. .item_info_text {
  387. font-size: 24rpx;
  388. }
  389. }
  390. }
  391. }
  392. }
  393. </style>