datails.vue 7.6 KB

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