gsequipment.vue 7.9 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 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. },
  169. tohistory() {
  170. uni.navigateTo({
  171. url: "./gshistory?id="+ this.eqinfo.device_id
  172. })
  173. },
  174. copy(item) {
  175. uni.setClipboardData({
  176. data: item,
  177. success: function() {
  178. console.log('success');
  179. }
  180. });
  181. },
  182. },
  183. onLoad(option) {
  184. this.eqinfo = JSON.parse(option.shebei)
  185. this.reverseGeocode(this.eqinfo.lat, this.eqinfo.lng)
  186. this.newdatafun()
  187. console.log(this.eqinfo)
  188. }
  189. }
  190. </script>
  191. <style lang="scss">
  192. .info {
  193. width: 100%;
  194. position: absolute;
  195. top: 44px;
  196. .info_item {
  197. width: 90%;
  198. margin: 0 auto;
  199. // height: 290rpx;
  200. padding: 26rpx 50rpx;
  201. position: relative;
  202. box-sizing: border-box;
  203. .bgi {
  204. width: 100%;
  205. height: 100%;
  206. position: absolute;
  207. top: 0;
  208. left: 0;
  209. z-index: -1;
  210. }
  211. p {
  212. font-size: 24rpx;
  213. color: #FFFFFF;
  214. margin-bottom: 10rpx;
  215. .tishi {
  216. width: 30rpx;
  217. height: 30rpx;
  218. margin: 0rpx 0 0 20rpx;
  219. }
  220. }
  221. }
  222. }
  223. .modalbox {
  224. display: flex;
  225. padding: 20px 10px;
  226. .uinput {
  227. width: 50%;
  228. border-radius: 22px;
  229. background-color: #f4f4f4;
  230. margin: 0 10px;
  231. text-indent: 1rem;
  232. font-size: 28rpx;
  233. }
  234. }
  235. .newdatas {
  236. width: 100%;
  237. position: absolute;
  238. top: 195px;
  239. .newdatas_title {
  240. width: 90%;
  241. margin: 0 auto;
  242. display: flex;
  243. justify-content: space-between;
  244. height: 50rpx;
  245. line-height: 50rpx;
  246. span,p {
  247. font-size: 13px;
  248. }
  249. span:first-child {
  250. font-size: 16px;
  251. font-weight: 700;
  252. }
  253. }
  254. .newdatas_air {
  255. width: 90%;
  256. margin: 0 auto 20rpx;
  257. display: flex;
  258. justify-content: space-between;
  259. flex-wrap: wrap;
  260. .newdatas_air_box {
  261. width: 48%;
  262. padding: 20rpx;
  263. box-sizing: border-box;
  264. box-shadow: 0 0 10rpx #bcb9ca;
  265. margin-top: 20rpx;
  266. display: flex;
  267. .imgbox {
  268. width: 60rpx;
  269. height: 60rpx;
  270. margin: 16rpx 30rpx 0rpx 20rpx;
  271. .img {
  272. width: 60rpx;
  273. height: 60rpx;
  274. }
  275. }
  276. .infobox {
  277. font-size: 28rpx;
  278. p {
  279. margin-bottom: 10rpx;
  280. }
  281. }
  282. }
  283. }
  284. .newdatas_land {
  285. width: 90%;
  286. margin: 0 auto 20rpx;
  287. .newdatas_land_title{
  288. font-size: 28rpx;
  289. }
  290. .newdatas_land_info {
  291. width: 100%;
  292. display: flex;
  293. justify-content: space-between;
  294. flex-wrap: wrap;
  295. .newdatas_land_box {
  296. width: 48%;
  297. padding: 20rpx;
  298. box-sizing: border-box;
  299. box-shadow: 0 0 10rpx #bcb9ca;
  300. margin-top: 20rpx;
  301. display: flex;
  302. .imgbox {
  303. width: 60rpx;
  304. height: 60rpx;
  305. margin: 16rpx 30rpx 0rpx 20rpx;
  306. .img {
  307. width: 60rpx;
  308. height: 60rpx;
  309. }
  310. }
  311. .infobox {
  312. font-size: 28rpx;
  313. p {
  314. margin-bottom: 10rpx;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. </style>