equipmentdetails.vue 9.4 KB

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