gsequipment.vue 7.9 KB

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