equipmentdetails.vue 9.3 KB

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