equipmentdetails.vue 9.4 KB

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