gsequipment.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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('')">
  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">
  27. <p>设置步长:</p>
  28. <input type="number" v-model="stepsize" 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">历史数据>>></p>
  36. </view>
  37. <view class="newdatas_air">
  38. <view class="newdatas_air_box">
  39. <view class="imgbox">
  40. <image src="http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/daqi.png"
  41. mode="" class="img"></image>
  42. </view>
  43. <view class="infobox">
  44. <p>大气压强</p>
  45. <p>{{newdataobj.atm}}Pa</p>
  46. </view>
  47. </view>
  48. <view class="newdatas_air_box">
  49. <view class="imgbox">
  50. <image src="http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/kqs.png"
  51. mode="" class="img"></image>
  52. </view>
  53. <view class="infobox">
  54. <p>空气湿度</p>
  55. <p>{{newdataobj.ats}}%RH</p>
  56. </view>
  57. </view>
  58. <view class="newdatas_air_box">
  59. <view class="imgbox">
  60. <image src="http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/kqw.png"
  61. mode="" class="img"></image>
  62. </view>
  63. <view class="infobox">
  64. <p>空气温度</p>
  65. <p>{{newdataobj.at}}℃</p>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="newdatas_land" v-for="item,index in newdataobj.temp" :key="index">
  70. <p class="newdatas_land_title">{{newdataobj.topic * (index+1)}}cm</p>
  71. <view class="newdatas_land_info">
  72. <view class="newdatas_land_box">
  73. <view class="imgbox">
  74. <image
  75. :src="'http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/trs'+(index+1)+'.png'"
  76. mode="" class="img"></image>
  77. </view>
  78. <view class="infobox">
  79. <p>土壤湿度</p>
  80. <p>{{newdataobj.swc[index]}}%RH</p>
  81. </view>
  82. </view>
  83. <view class="newdatas_land_box">
  84. <view class="imgbox">
  85. <image
  86. :src="'http://www.hnyfwlw.com:8006//bigdata_app/image/environment/tubular/trw'+(index+1)+'.png'"
  87. mode="" class="img"></image>
  88. </view>
  89. <view class="infobox">
  90. <p>土壤温度</p>
  91. <p>{{newdataobj.temp[index]}}℃</p>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. export default {
  102. data() {
  103. return {
  104. eqinfo: {},
  105. city: "",
  106. modalshow: false, //设置步长弹框,
  107. stepsize: "", //步长值
  108. newdataobj: {}, //实时数据
  109. }
  110. },
  111. methods: {
  112. reverseGeocode(lat, lng) {
  113. uni.request({
  114. type: "GET",
  115. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  116. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  117. dataType: "json",
  118. complete: ress => {
  119. console.log(ress)
  120. // this.city = ress.data.regeocode.formatted_address
  121. if (ress.data.regeocode.formatted_address.length == 0) {
  122. this.city = "--"
  123. } else {
  124. this.city = ress.data.regeocode.formatted_address
  125. }
  126. }
  127. });
  128. },
  129. // weather.weather.nd_topic_change 设置 获取步长
  130. async setlongfun(stepsize) { //设备列表
  131. this.modalshow = !this.modalshow
  132. const res = await this.$myRequest({
  133. url: '/api/api_gateway?method=weather.weather.nd_topic_change',
  134. data: {
  135. device_id: this.eqinfo.device_id,
  136. topic: stepsize
  137. }
  138. })
  139. this.stepsize = res.topic
  140. if (stepsize) {
  141. uni.showToast({
  142. title: "设置成功",
  143. icon: "none"
  144. })
  145. }
  146. },
  147. //weather.weather.nd_status 实时数据
  148. async newdatafun() { //设备列表
  149. const res = await this.$myRequest({
  150. url: '/api/api_gateway?method=weather.weather.nd_status',
  151. data: {
  152. device_id: this.eqinfo.device_id,
  153. }
  154. })
  155. this.newdataobj = res
  156. this.newdataobj.temp = this.newdataobj.temp.split(",")
  157. this.newdataobj.swc = this.newdataobj.swc.split(",")
  158. console.log(this.newdataobj)
  159. },
  160. confirm() {
  161. this.modalshow = !this.modalshow
  162. this.setlongfun(this.stepsize)
  163. },
  164. clickLeft() {
  165. // uni.navigateTo({
  166. // url: "./index"
  167. // })
  168. uni.navigateBack({
  169. delta:1
  170. })
  171. },
  172. tohistory() {
  173. uni.navigateTo({
  174. url: "./gshistory?id="+ this.eqinfo.device_id
  175. })
  176. },
  177. copy(item) {
  178. uni.setClipboardData({
  179. data: item,
  180. success: function() {
  181. console.log('success');
  182. }
  183. });
  184. },
  185. },
  186. onLoad(option) {
  187. this.eqinfo = JSON.parse(option.shebei)
  188. this.reverseGeocode(this.eqinfo.lat, this.eqinfo.lng)
  189. this.newdatafun()
  190. console.log(this.eqinfo)
  191. }
  192. }
  193. </script>
  194. <style lang="scss">
  195. .info {
  196. width: 100%;
  197. position: absolute;
  198. top: 44px;
  199. .info_item {
  200. width: 90%;
  201. margin: 0 auto;
  202. // height: 290rpx;
  203. padding: 26rpx 50rpx;
  204. position: relative;
  205. box-sizing: border-box;
  206. .bgi {
  207. width: 100%;
  208. height: 100%;
  209. position: absolute;
  210. top: 0;
  211. left: 0;
  212. z-index: -1;
  213. }
  214. p {
  215. font-size: 24rpx;
  216. color: #FFFFFF;
  217. margin-bottom: 10rpx;
  218. .tishi {
  219. width: 30rpx;
  220. height: 30rpx;
  221. margin: 0rpx 0 0 20rpx;
  222. }
  223. }
  224. }
  225. }
  226. .modalbox {
  227. display: flex;
  228. padding: 20px 10px;
  229. .uinput {
  230. width: 50%;
  231. border-radius: 22px;
  232. background-color: #f4f4f4;
  233. margin: 0 10px;
  234. text-indent: 1rem;
  235. font-size: 28rpx;
  236. }
  237. }
  238. .newdatas {
  239. width: 100%;
  240. position: absolute;
  241. top: 195px;
  242. .newdatas_title {
  243. width: 90%;
  244. margin: 0 auto;
  245. display: flex;
  246. justify-content: space-between;
  247. height: 50rpx;
  248. line-height: 50rpx;
  249. span,p {
  250. font-size: 13px;
  251. }
  252. span:first-child {
  253. font-size: 16px;
  254. font-weight: 700;
  255. }
  256. }
  257. .newdatas_air {
  258. width: 90%;
  259. margin: 0 auto 20rpx;
  260. display: flex;
  261. justify-content: space-between;
  262. flex-wrap: wrap;
  263. .newdatas_air_box {
  264. width: 48%;
  265. padding: 20rpx;
  266. box-sizing: border-box;
  267. box-shadow: 0 0 10rpx #bcb9ca;
  268. margin-top: 20rpx;
  269. display: flex;
  270. .imgbox {
  271. width: 60rpx;
  272. height: 60rpx;
  273. margin: 16rpx 30rpx 0rpx 20rpx;
  274. .img {
  275. width: 60rpx;
  276. height: 60rpx;
  277. }
  278. }
  279. .infobox {
  280. font-size: 28rpx;
  281. p {
  282. margin-bottom: 10rpx;
  283. }
  284. }
  285. }
  286. }
  287. .newdatas_land {
  288. width: 90%;
  289. margin: 0 auto 20rpx;
  290. .newdatas_land_title{
  291. font-size: 28rpx;
  292. }
  293. .newdatas_land_info {
  294. width: 100%;
  295. display: flex;
  296. justify-content: space-between;
  297. flex-wrap: wrap;
  298. .newdatas_land_box {
  299. width: 48%;
  300. padding: 20rpx;
  301. box-sizing: border-box;
  302. box-shadow: 0 0 10rpx #bcb9ca;
  303. margin-top: 20rpx;
  304. display: flex;
  305. .imgbox {
  306. width: 60rpx;
  307. height: 60rpx;
  308. margin: 16rpx 30rpx 0rpx 20rpx;
  309. .img {
  310. width: 60rpx;
  311. height: 60rpx;
  312. }
  313. }
  314. .infobox {
  315. font-size: 28rpx;
  316. p {
  317. margin-bottom: 10rpx;
  318. }
  319. }
  320. }
  321. }
  322. }
  323. }
  324. </style>