datails.vue 8.3 KB

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