gsequipment.vue 8.0 KB

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