datails.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. },
  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. uni.getStorage({
  176. key: "jurisdiction",
  177. success: (res) => {
  178. // console.log(JSON.parse(res.data))
  179. let items = JSON.parse(res.data).filter((item) => {
  180. return item.pur_id == 202 //灌溉控制系统
  181. })
  182. let items2 = items[0].children.filter((item) => {
  183. return item.pur_id == 195//"水肥一体化(X)"
  184. })
  185. console.log(items2)
  186. var arr = items2[0].children
  187. console.log(arr)
  188. for (var i = 0; i < arr.length; i++) {
  189. switch (arr[i].pur_id) {
  190. case 196:
  191. this.zttf = true//"设备状态"
  192. break
  193. case 197:
  194. this.ystf = true//"要素数据"
  195. break
  196. }
  197. }
  198. },
  199. })
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. .info {
  205. width: 100%;
  206. position: absolute;
  207. top: 44px;
  208. .info_item {
  209. width: 90%;
  210. margin: 0 auto;
  211. height: 280rpx;
  212. padding: 26rpx 50rpx;
  213. position: relative;
  214. box-sizing: border-box;
  215. .bgi {
  216. width: 100%;
  217. height: 280rpx;
  218. position: absolute;
  219. top: 0;
  220. left: 0;
  221. z-index: -1;
  222. }
  223. p {
  224. font-size: 24rpx;
  225. color: #FFFFFF;
  226. margin-bottom: 10rpx;
  227. .tishi {
  228. width: 30rpx;
  229. height: 30rpx;
  230. margin: 0rpx 0 0 20rpx;
  231. }
  232. }
  233. }
  234. }
  235. .control {
  236. width: 90%;
  237. position: absolute;
  238. top: 392rpx;
  239. left: 5%;
  240. display: flex;
  241. justify-content: space-between;
  242. text-align: center;
  243. padding: 0 30rpx;
  244. box-sizing: border-box;
  245. .control_item {
  246. width: 120rpx;
  247. height: 120rpx;
  248. image {
  249. width: 70rpx;
  250. height: 70rpx;
  251. }
  252. p {
  253. font-size: 24rpx;
  254. }
  255. }
  256. }
  257. .realtime {
  258. width: 100%;
  259. position: absolute;
  260. top: 520rpx;
  261. .realtime_title {
  262. font-weight: 700;
  263. width: 90%;
  264. margin: 0 auto;
  265. }
  266. .dataloading:after {
  267. overflow: hidden;
  268. display: inline-block;
  269. vertical-align: bottom;
  270. animation: ellipsis 2s infinite;
  271. content: "\2026";
  272. }
  273. @keyframes ellipsis {
  274. from {
  275. width: 2px;
  276. }
  277. to {
  278. width: 15px;
  279. }
  280. }
  281. .realtime_tishi {
  282. width: 90%;
  283. margin: 0 auto;
  284. text-align: center;
  285. font-size: 32rpx;
  286. padding-top: 40rpx;
  287. }
  288. .realtime_text {
  289. width: 90%;
  290. margin: 0 auto;
  291. .realtime_text_item {
  292. width: 100%;
  293. display: flex;
  294. justify-content: space-between;
  295. flex-wrap: wrap;
  296. margin-bottom: 50rpx;
  297. .realtime_text_item_info {
  298. width: 48%;
  299. box-shadow: 0 0 10rpx #bcb9ca;
  300. margin-top: 20rpx;
  301. display: flex;
  302. padding: 20rpx 20rpx;
  303. box-sizing: border-box;
  304. .item_info_img {
  305. width: 30%;
  306. text-align: center;
  307. margin-right: 30rpx;
  308. background-image: linear-gradient(to bottom,#5ee3ee,#3cbaef);
  309. border-radius: 50%;
  310. image {
  311. width: 64rpx;
  312. height: 64rpx;
  313. margin-top: 10rpx;
  314. }
  315. }
  316. .item_info_text {
  317. font-size: 24rpx;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. </style>