weathdata.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view style="padding-top: 20rpx;">
  3. <view class="datainfo">
  4. <view class="datainfo_item">
  5. <view class="">
  6. {{item.device_name}}
  7. </view>
  8. <view class="" :style="{'color':item.status==1?'#00B075':'#f64a4a'}">
  9. {{item.status==1?"已开启":"已禁用"}}
  10. </view>
  11. </view>
  12. <view class="datainfo_item">
  13. 设备ID:{{item.device_id}}
  14. </view>
  15. <view class="datainfo_item">
  16. 设备备注:{{item.device_notes==''?"--":item.device_notes}}
  17. </view>
  18. <view class="datainfo_item">
  19. 设备状态:{{item.device_status==1?"在线":"离线"}}
  20. </view>
  21. <view class="datainfo_item">
  22. <view class="datainfo_item_1">
  23. 地址:{{item.city}}
  24. </view>
  25. <view class="">
  26. <u-icon name="map" size="40" color="#00B075" @click="selectaddress(item.city,item.device_name)">
  27. </u-icon>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="datadetails">
  32. <view class="datadetails_box1">
  33. <view class="">
  34. 设备变量名称
  35. </view>
  36. <view class="">
  37. 当前值
  38. </view>
  39. </view>
  40. <!-- datadetails_box_item -->
  41. <view class="datadetails_box" v-for="item,index in data" :key="index">
  42. <view class="datadetails_box_name">
  43. {{item.name}}
  44. </view>
  45. <view class="datadetails_box_conf" v-if="compile && item.device_status==1">
  46. <u-switch v-model="item.values" size="35" active-color="#00B075" style="margin-top: 30rpx;" inactive-color="#f00"
  47. v-if="item.types==1" @change="switchchange2($event,item,index)">
  48. </u-switch>
  49. <view class="" v-if="item.types==0 || item.types==4" style="display: flex;">
  50. <!-- <u-input v-model="item.values" :type="item.values==0?'number':'text'" :clearable="false" style="width: 200rpx;margin: 10rpx 10rpx 0 0;" input-align="right"/> -->
  51. <view class="">
  52. {{item.values}}{{item.unit}}
  53. </view>
  54. <view class="">
  55. <u-icon name="edit-pen" size="36" color="#00B075" @click="inputfill(item,index)">
  56. </u-icon>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="datadetails_box_conf" v-else>
  61. <view class="" v-if="item.types==1">
  62. {{item.values==true?"开":"关"}}{{item.unit}}
  63. </view>
  64. <view class="" v-if="item.types==0 || item.types==4">
  65. {{item.values?item.values:"--"}}{{item.unit}}
  66. </view>
  67. </view>
  68. </view>
  69. <u-modal v-model="show" :show-cancel-button="true" :title="baseinfo.title" @confirm="modalconfirm"
  70. @cancel="modalcancel">
  71. <view class="slot-content">
  72. <u-input v-model="baseinfo.content" type="number" />{{baseinfo.unit}}
  73. </view>
  74. </u-modal>
  75. <!-- <view class="loading" v-if="maskshow">
  76. <image src="../../static/images/cb/6286299.gif" mode="" class="img"></image>
  77. </view> -->
  78. <u-mask :show="maskshow">
  79. <view class="loading" v-if="maskshow">
  80. <image src="../../static/images/cb/6286299.gif" mode="" class="img"></image>
  81. </view>
  82. </u-mask>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. item: {},
  91. data: {},
  92. show: false,
  93. baseinfo: {
  94. title: "",
  95. unit: "",
  96. d_id: "",
  97. content: "",
  98. index: "",
  99. types: ""
  100. },
  101. maskshow: false,
  102. compile:false
  103. }
  104. },
  105. onLoad(option) {
  106. this.item = JSON.parse(option.item)
  107. this.getbaseinfo()
  108. },
  109. methods: {
  110. async getbaseinfo(){
  111. const res = await this.$myRequest({
  112. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fertilizer_list',
  113. data: {
  114. content: this.item.device_id,
  115. }
  116. })
  117. console.log(res)
  118. this.item = res.data[0]
  119. if(this.item.status==1){
  120. this.compile = true
  121. }else{
  122. this.compile = false
  123. }
  124. this.tubulareqlist()
  125. },
  126. async tubulareqlist() { //实时数据
  127. this.maskshow = true
  128. const res = await this.$myRequest({
  129. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fertilizer_data_list',
  130. data: {
  131. device_id: this.item.device_id,
  132. }
  133. })
  134. this.maskshow = false
  135. console.log(res)
  136. for (var i = 0; i < res.length; i++) {
  137. if (res[i].types == 1) {
  138. res[i].values = res[i].values == 1 ? true : false
  139. }
  140. }
  141. this.data = res
  142. },
  143. async controlfill() { //设备控制
  144. this.maskshow = true
  145. const res = await this.$myRequest({
  146. url: '/api/api_gateway?method=irrigation_system.waterfertilizer.water_fer_parametric_control',
  147. data: {
  148. device_id: this.item.device_id,
  149. d_id: this.baseinfo.d_id,
  150. content: this.baseinfo.content
  151. }
  152. })
  153. this.maskshow = false
  154. console.log(res)
  155. if (res.status == 200) {
  156. uni.showToast({
  157. title: "下发成功",
  158. icon: "none"
  159. })
  160. if (this.baseinfo.types == 1) {
  161. this.data[this.baseinfo.index].values = this.baseinfo.content==1?true:false
  162. }else{
  163. this.data[this.baseinfo.index].values = this.baseinfo.content
  164. }
  165. } else {
  166. uni.showToast({
  167. title: "下发失败",
  168. icon: "none"
  169. })
  170. if (this.baseinfo.types == 1) {
  171. this.data[this.baseinfo.index].values = !this.data[this.baseinfo.index].values
  172. }
  173. }
  174. // this.data = res
  175. },
  176. selectaddress(city, name) { //获取分布位置
  177. uni.request({
  178. type: "GET",
  179. url: "https://restapi.amap.com/v3/geocode/geo?address=" + city +
  180. "&key=78ce288400f4fc6d9458989875c833c2",
  181. dataType: "json",
  182. complete: ress => {
  183. console.log(ress)
  184. if (ress.data.status == 1) {
  185. // ress.data.geocodes[0].location
  186. uni.navigateTo({
  187. url: "./irrmap?lnglat=" + ress.data.geocodes[0].location +
  188. "&basename=" + name
  189. })
  190. } else {
  191. uni.showToast({
  192. title: "地址编译失败",
  193. icon: "none"
  194. })
  195. }
  196. }
  197. });
  198. },
  199. switchchange2(e, item, index) {
  200. console.log(e)
  201. this.baseinfo.title = item.name
  202. this.baseinfo.unit = item.unit
  203. this.baseinfo.d_id = item.d_id
  204. this.baseinfo.index = index
  205. this.baseinfo.types = item.types
  206. this.baseinfo.content = e == true ? "1" : "0"
  207. this.controlfill()
  208. },
  209. inputfill(e, index) {
  210. console.log(e)
  211. this.show = true
  212. this.baseinfo.title = e.name
  213. this.baseinfo.unit = e.unit
  214. this.baseinfo.d_id = e.d_id
  215. this.baseinfo.index = index
  216. },
  217. modalconfirm() {
  218. this.controlfill()
  219. },
  220. modalcancel() {
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. page {
  227. background: $uni-bg-color-grey;
  228. }
  229. .datainfo {
  230. width: 100%;
  231. background-color: #fff;
  232. padding: 20rpx 30rpx;
  233. box-sizing: border-box;
  234. .datainfo_item {
  235. display: flex;
  236. justify-content: space-between;
  237. height: 60rpx;
  238. font-size: 28rpx;
  239. color: #909696;
  240. .datainfo_item_1 {
  241. width: 80%;
  242. overflow: hidden; //溢出隐藏
  243. white-space: nowrap; //禁止换行
  244. text-overflow: ellipsis; //...
  245. }
  246. }
  247. .datainfo_item:first-child {
  248. font-size: 32rpx;
  249. color: #000;
  250. }
  251. }
  252. .datadetails {
  253. width: 100%;
  254. margin-top: 20rpx;
  255. background-color: #fff;
  256. padding: 20rpx 30rpx;
  257. box-sizing: border-box;
  258. .datadetails_box1 {
  259. font-size: 30rpx;
  260. font-weight: 700;
  261. display: flex;
  262. justify-content: space-between;
  263. height: 60rpx;
  264. border-bottom: 1px solid #efefef;
  265. line-height: 60rpx;
  266. }
  267. .datadetails_box {
  268. height: 100rpx;
  269. display: flex;
  270. justify-content: space-between;
  271. border-bottom: 1px solid #efefef;
  272. line-height: 100rpx;
  273. .datadetails_box_item {}
  274. .datadetails_box_name {
  275. width: 50%;
  276. overflow: hidden; //溢出隐藏
  277. white-space: nowrap; //禁止换行
  278. text-overflow: ellipsis; //...
  279. }
  280. .datadetails_box_conf_lng {
  281. display: flex;
  282. margin-top: 10rpx;
  283. }
  284. }
  285. }
  286. .slot-content {
  287. width: 50%;
  288. margin: 30rpx auto;
  289. display: flex;
  290. line-height: 70rpx;
  291. }
  292. .loading {
  293. position: fixed;
  294. top: 200px;
  295. width: 95%;
  296. left: 2.5%;
  297. text-align: center;
  298. .img {
  299. width: 300rpx;
  300. height: 300rpx;
  301. }
  302. }
  303. </style>