datails.vue 7.4 KB

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