datails.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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?'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. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png" mode="" class="bgi"></image>
  14. <p style="font-size: 32rpx;" @click="copy(eqinfo.item.imei || eqinfo.item.device_id)">设备
  15. ID:{{eqinfo.item.imei || eqinfo.item.device_id}}
  16. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode=""
  17. class="tishi"></image>
  18. </p>
  19. <p>设备名称:{{eqinfo.item.device_name}}</p>
  20. <p>设备型号:水肥一体化</p>
  21. <p>最近上报时间:{{eqinfo.item.uptime|timeFormat()}}</p>
  22. <p>设备地址:{{city}}</p>
  23. </view>
  24. </view>
  25. <view class="control">
  26. <view class="control_item" v-if="$QueryPermission(196)" @click="control">
  27. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/8.png'" mode=""></image>
  28. <p>设备状态</p>
  29. </view>
  30. <view class="control_item" v-if="$QueryPermission(197)" @click="charts">
  31. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/10.png'" mode=""></image>
  32. <p>要素数据</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_tishi" v-if="olddatas.length==0 && dataloadingtf == false">
  42. 暂无数据
  43. </view>
  44. <view class="realtime_text" v-else>
  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_pc/sf/dev/icon_'+item.icon+'.png'"
  49. mode=""></image>
  50. </view>
  51. <view class="item_info_text">
  52. <p>{{item.txt}}</p>
  53. <p style="margin-top: 20rpx;">{{item.value}}</p>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="realtime_tishi" v-if="dataloadingtf">
  59. <p class="dataloading">加载中</p>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import elelist from "../../static/json/eleList.json"
  67. export default {
  68. data() {
  69. return {
  70. eqinfo: {
  71. },
  72. olddata: {},
  73. olddatas: [],
  74. newdatesTF: false, //暂无数据显示隐藏
  75. work: "",
  76. zttf: false,
  77. ystf: false,
  78. city: "",
  79. dataloadingtf: true, //加载中显示隐藏
  80. }
  81. },
  82. methods: {
  83. async history() { //设备列表
  84. var newtime = +new Date() / 1000
  85. var oldtime = newtime - 24 * 60 * 60
  86. this.dataloadingtf = true
  87. const res = await this.$myRequest({
  88. url: '/api/api_gateway?method=weather.weather.sf_status',
  89. data: {
  90. device_id: this.eqinfo.item.device_id
  91. }
  92. })
  93. this.dataloadingtf = false
  94. console.log(res)
  95. this.olddatas = []
  96. var dataarr = res.conf.eleName.split("/")
  97. var elearr = res.conf.eleNum.split("/")
  98. var numarr = JSON.stringify(res.dat.device_status).slice(2, -2)
  99. numarr = numarr.split(",")
  100. var numobj = {}
  101. for (var i = 0; i < numarr.length; i++) {
  102. numarr[i] = numarr[i].split(":")
  103. var index = numarr[i][0].indexOf("e")==-1?numarr[i][0].indexOf("j"):numarr[i][0].indexOf("e")
  104. numobj[numarr[i][0].slice(index, -1)] = Number(numarr[i][1])
  105. }
  106. console.log(numobj)
  107. // for(var key in numarr){
  108. // console.log(numarr[key])
  109. // }
  110. for (var i = 0; i < dataarr.length; i++) {
  111. if(dataarr[i]!="-"){
  112. var obj = {
  113. txt: dataarr[i],
  114. icon: elearr[i],
  115. value: numobj['e'+(i+1)] + elelist[elearr[i]].unit
  116. }
  117. this.olddatas.push(obj)
  118. }
  119. }
  120. console.log(this.olddatas)
  121. },
  122. clickLeft() {
  123. uni.navigateBack({
  124. delta: 1
  125. })
  126. },
  127. repairs() {
  128. console.log(this.eqinfo.item)
  129. var device_id = this.eqinfo.item.device_id
  130. uni.navigateTo({
  131. url: "../afterSale/addafter?device_id=" + device_id + "&device_type=" + 13
  132. })
  133. },
  134. control() { //设备控制
  135. uni.navigateTo({
  136. url: "./basestate?device_id=" + this.eqinfo.item.device_id
  137. })
  138. },
  139. charts() { //历史数据
  140. uni.navigateTo({
  141. url: "./elementdata?device_id=" + this.eqinfo.item.device_id
  142. })
  143. },
  144. copy(item) {
  145. uni.setClipboardData({
  146. data: item,
  147. success: function() {
  148. console.log('success');
  149. }
  150. });
  151. },
  152. selectaddress(lat, lng) { //获取分布位置
  153. uni.request({
  154. type: "GET",
  155. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  156. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  157. dataType: "json",
  158. complete: ress => {
  159. console.log(ress.data.regeocode.formatted_address)
  160. if (ress.data.regeocode.formatted_address.length == 0) {
  161. this.city = "暂无"
  162. } else {
  163. this.city = ress.data.regeocode.formatted_address
  164. }
  165. }
  166. });
  167. },
  168. },
  169. onLoad(option) {
  170. this.$forceUpdate()
  171. this.eqinfo.item = JSON.parse(option.shebei)
  172. console.log(JSON.parse(option.shebei))
  173. this.history()
  174. this.selectaddress(this.eqinfo.item.lat, this.eqinfo.item.lng)
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. .info {
  180. width: 100%;
  181. position: absolute;
  182. top: 44px;
  183. .info_item {
  184. width: 90%;
  185. margin: 0 auto;
  186. height: 280rpx;
  187. padding: 26rpx 50rpx;
  188. position: relative;
  189. box-sizing: border-box;
  190. .bgi {
  191. width: 100%;
  192. height: 280rpx;
  193. position: absolute;
  194. top: 0;
  195. left: 0;
  196. z-index: -1;
  197. }
  198. p {
  199. font-size: 24rpx;
  200. color: #FFFFFF;
  201. margin-bottom: 10rpx;
  202. .tishi {
  203. width: 30rpx;
  204. height: 30rpx;
  205. margin: 0rpx 0 0 20rpx;
  206. }
  207. }
  208. }
  209. }
  210. .control {
  211. width: 90%;
  212. position: absolute;
  213. top: 392rpx;
  214. left: 5%;
  215. display: flex;
  216. justify-content: space-between;
  217. text-align: center;
  218. padding: 0 30rpx;
  219. box-sizing: border-box;
  220. .control_item {
  221. width: 120rpx;
  222. height: 120rpx;
  223. image {
  224. width: 70rpx;
  225. height: 70rpx;
  226. }
  227. p {
  228. font-size: 24rpx;
  229. }
  230. }
  231. }
  232. .realtime {
  233. width: 100%;
  234. position: absolute;
  235. top: 520rpx;
  236. .realtime_title {
  237. font-weight: 700;
  238. width: 90%;
  239. margin: 0 auto;
  240. }
  241. .dataloading:after {
  242. overflow: hidden;
  243. display: inline-block;
  244. vertical-align: bottom;
  245. animation: ellipsis 2s infinite;
  246. content: "\2026";
  247. }
  248. @keyframes ellipsis {
  249. from {
  250. width: 2px;
  251. }
  252. to {
  253. width: 15px;
  254. }
  255. }
  256. .realtime_tishi {
  257. width: 90%;
  258. margin: 0 auto;
  259. text-align: center;
  260. font-size: 32rpx;
  261. padding-top: 40rpx;
  262. }
  263. .realtime_text {
  264. width: 90%;
  265. margin: 0 auto;
  266. .realtime_text_item {
  267. width: 100%;
  268. display: flex;
  269. justify-content: space-between;
  270. flex-wrap: wrap;
  271. margin-bottom: 50rpx;
  272. .realtime_text_item_info {
  273. width: 48%;
  274. box-shadow: 0 0 10rpx #bcb9ca;
  275. margin-top: 20rpx;
  276. display: flex;
  277. padding: 20rpx 20rpx;
  278. box-sizing: border-box;
  279. .item_info_img {
  280. width: 30%;
  281. text-align: center;
  282. margin-right: 30rpx;
  283. background-image: linear-gradient(to bottom,#5ee3ee,#3cbaef);
  284. border-radius: 50%;
  285. image {
  286. width: 64rpx;
  287. height: 64rpx;
  288. margin-top: 10rpx;
  289. }
  290. }
  291. .item_info_text {
  292. font-size: 24rpx;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>