gsequipment.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png" mode="" class="bgi"></image>
  11. <p style="font-size: 32rpx;" @click="copy(eqinfo.device_id)">设备 ID:{{eqinfo.device_id}}
  12. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode=""
  13. class="tishi"></image>
  14. </p>
  15. <p>设备名称:{{eqinfo.device_name||"无"}}</p>
  16. <p>最近上报时间:<span v-if="eqinfo.uptime">{{eqinfo.uptime|timeFormat()}}</span><span
  17. v-else>{{eqinfo.addtime|timeFormat()}}</span></p>
  18. <p>地址:{{city}}</p>
  19. <p @click="setlongfun('')" v-if="$QueryPermission(250)">
  20. <text space="emsp">设置步长</text>
  21. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  22. </p>
  23. </view>
  24. </view>
  25. <u-modal v-model="modalshow" @confirm="confirm" show-cancel-button>
  26. <view class="modalbox" v-for="items,index in depthlist">
  27. <p>第{{ index + 1 }}层步长值:</p>
  28. <input type="number" v-model="depthlist[index]" class="uinput" placeholder="请输入步长" />
  29. <p>cm</p>
  30. </view>
  31. </u-modal>
  32. <view class="newdatas">
  33. <view class="newdatas_title">
  34. <span>实时数据</span>
  35. <p @click="tohistory" v-if="$QueryPermission(189)">历史数据>>></p>
  36. </view>
  37. <view class="newdatas_land" v-for="item,index in newdataobj.temp" :key="index">
  38. <p class="newdatas_land_title">{{newdataobj.depth[index]}}cm</p>
  39. <view class="newdatas_land_info">
  40. <view class="newdatas_land_box">
  41. <view class="imgbox">
  42. <image
  43. :src="'http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/trs'+(index+1)+'.png'"
  44. mode="" class="img"></image>
  45. </view>
  46. <view class="infobox">
  47. <p>土壤湿度</p>
  48. <p>{{newdataobj.swc[index]}}%RH</p>
  49. </view>
  50. </view>
  51. <view class="newdatas_land_box">
  52. <view class="imgbox">
  53. <image
  54. :src="'http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/trw'+(index+1)+'.png'"
  55. mode="" class="img"></image>
  56. </view>
  57. <view class="infobox">
  58. <p>土壤温度</p>
  59. <p>{{newdataobj.temp[index]}}℃</p>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. eqinfo: {},
  73. city: "",
  74. modalshow: false, //设置步长弹框,
  75. stepsize: "", //步长值
  76. newdataobj: {}, //实时数据
  77. depthlist:[]
  78. }
  79. },
  80. methods: {
  81. reverseGeocode(lat, lng) {
  82. uni.request({
  83. type: "GET",
  84. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  85. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  86. dataType: "json",
  87. complete: ress => {
  88. console.log(ress)
  89. // this.city = ress.data.regeocode.formatted_address
  90. if (ress.data.regeocode.formatted_address.length == 0) {
  91. this.city = "--"
  92. } else {
  93. this.city = ress.data.regeocode.formatted_address
  94. }
  95. }
  96. });
  97. },
  98. // weather.weather.nd_topic_change 设置 获取步长
  99. async setlongfun(stepsize) { //设备列表
  100. this.modalshow = !this.modalshow
  101. const res = await this.$myRequest({
  102. url: '/api/api_gateway?method=weather.weather.nd_topic_change',
  103. data: {
  104. device_id: this.eqinfo.device_id,
  105. depth: stepsize
  106. }
  107. })
  108. // this.stepsize = res.topic
  109. console.log(res)
  110. if(stepsize==""){
  111. this.depthlist = res.depth.split(",")
  112. }else{
  113. if(res){
  114. uni.showToast({
  115. title: "设置成功",
  116. icon: "none"
  117. })
  118. }else{
  119. uni.showToast({
  120. title: "设置失败",
  121. icon: "none"
  122. })
  123. }
  124. }
  125. },
  126. //weather.weather.nd_status 实时数据
  127. async newdatafun() { //设备列表
  128. const res = await this.$myRequest({
  129. url: '/api/api_gateway?method=weather.weather.nd_status',
  130. data: {
  131. device_id: this.eqinfo.device_id,
  132. }
  133. })
  134. this.newdataobj = res
  135. this.newdataobj.depth = this.newdataobj.depth.split(",")
  136. // this.depthlist = JSON.parse(JSON.stringify(this.newdataobj.depth))
  137. this.newdataobj.temp = this.newdataobj.temp.split(",")
  138. this.newdataobj.swc = this.newdataobj.swc.split(",")
  139. console.log(this.newdataobj)
  140. },
  141. confirm() {
  142. this.modalshow = !this.modalshow
  143. this.setlongfun(this.depthlist)
  144. },
  145. clickLeft() {
  146. // uni.navigateTo({
  147. // url: "./index"
  148. // })
  149. uni.navigateBack({
  150. delta:1
  151. })
  152. },
  153. tohistory() {
  154. uni.navigateTo({
  155. url: "./gshistory?id="+ this.eqinfo.device_id
  156. })
  157. },
  158. copy(item) {
  159. uni.setClipboardData({
  160. data: item,
  161. success: function() {
  162. console.log('success');
  163. }
  164. });
  165. },
  166. },
  167. onLoad(option) {
  168. this.eqinfo = JSON.parse(option.shebei)
  169. this.reverseGeocode(this.eqinfo.lat, this.eqinfo.lng)
  170. this.newdatafun()
  171. console.log(this.eqinfo)
  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: 290rpx;
  184. padding: 26rpx 50rpx;
  185. position: relative;
  186. box-sizing: border-box;
  187. .bgi {
  188. width: 100%;
  189. height: 100%;
  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. .modalbox {
  208. display: flex;
  209. padding: 20rpx 10rpx;
  210. font-size: 14px;
  211. .uinput {
  212. width: 50%;
  213. border-radius: 22px;
  214. background-color: #f4f4f4;
  215. margin: 0 10px;
  216. text-indent: 1rem;
  217. font-size: 28rpx;
  218. }
  219. }
  220. .newdatas {
  221. width: 100%;
  222. position: absolute;
  223. top: 195px;
  224. .newdatas_title {
  225. width: 90%;
  226. margin: 0 auto;
  227. display: flex;
  228. justify-content: space-between;
  229. height: 50rpx;
  230. line-height: 50rpx;
  231. span,p {
  232. font-size: 13px;
  233. }
  234. span:first-child {
  235. font-size: 16px;
  236. font-weight: 700;
  237. }
  238. }
  239. .newdatas_air {
  240. width: 90%;
  241. margin: 0 auto 20rpx;
  242. display: flex;
  243. justify-content: space-between;
  244. flex-wrap: wrap;
  245. .newdatas_air_box {
  246. width: 48%;
  247. padding: 20rpx;
  248. box-sizing: border-box;
  249. box-shadow: 0 0 10rpx #bcb9ca;
  250. margin-top: 20rpx;
  251. display: flex;
  252. .imgbox {
  253. width: 60rpx;
  254. height: 60rpx;
  255. margin: 16rpx 30rpx 0rpx 20rpx;
  256. .img {
  257. width: 60rpx;
  258. height: 60rpx;
  259. }
  260. }
  261. .infobox {
  262. font-size: 28rpx;
  263. p {
  264. margin-bottom: 10rpx;
  265. }
  266. }
  267. }
  268. }
  269. .newdatas_land {
  270. width: 90%;
  271. margin: 0 auto 20rpx;
  272. .newdatas_land_title{
  273. font-size: 28rpx;
  274. }
  275. .newdatas_land_info {
  276. width: 100%;
  277. display: flex;
  278. justify-content: space-between;
  279. flex-wrap: wrap;
  280. .newdatas_land_box {
  281. width: 48%;
  282. padding: 20rpx;
  283. box-sizing: border-box;
  284. box-shadow: 0 0 10rpx #bcb9ca;
  285. margin-top: 20rpx;
  286. display: flex;
  287. .imgbox {
  288. width: 60rpx;
  289. height: 60rpx;
  290. margin: 16rpx 30rpx 0rpx 20rpx;
  291. .img {
  292. width: 60rpx;
  293. height: 60rpx;
  294. }
  295. }
  296. .infobox {
  297. font-size: 28rpx;
  298. p {
  299. margin-bottom: 10rpx;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. }
  306. </style>