index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="防治系统" right-icon="search"
  7. @clickRight="clickRight" size="16"></uni-nav-bar>
  8. <view class="inputs" :style="{'width':width+'rpx'}">
  9. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp"
  10. class="inputbox" :clearable="false" />
  11. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  12. </view>
  13. </view>
  14. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/prevention/1.png'" mode="" class="image">
  15. </image>
  16. <view class="loading" v-if="loadingtf">
  17. <image src="../../static/images/ajax-loader.gif" mode="" class="img"></image>
  18. </view>
  19. <view class="prevents">
  20. <view class="prevents_item" v-for="item,index in eqlistdata" :key="index" @click="eqdetails(item)">
  21. <image
  22. :src="item.is_online==1?'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/6.png':'http://www.hnyfwlw.com:8006/bigdata_app/image/prevention/7.png'"
  23. mode="" class="prevents_item_img"></image>
  24. <view class="prevents_item_top">
  25. <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
  26. <p :class="item.is_online==1?'green':'red'" v-text="item.is_online==1?'在线':'离线'"></p>
  27. </view>
  28. <view class="prevents_item_bot">
  29. <p>设备 ID:{{item.imei}}</p>
  30. <p>最新上报时间:{{item.addtime|timeFormat()}}</p>
  31. <view class="" style="display: flex;justify-content: space-between;">
  32. <p>设备到期情况:<span
  33. :class="'prevents_item_bot_sapn'+item.device_expire">{{item.device_expiretext}}</span>
  34. </p>
  35. <p style="color: #3C84FE;" v-if="item.device_expire!=0" @click.stop="examine(item)">查看详情</p>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <u-modal v-model="show" :title="title" :showConfirmButton="false"
  42. :title-style="{'text-align':'left','padding-left':'10px','font-weight':700}" :mask-close-able="true">
  43. <view class="slot-content">
  44. <rich-text :nodes="content"></rich-text>
  45. </view>
  46. </u-modal>
  47. <view class="top">
  48. <view class="backtop" @click="top" v-if="isTop">
  49. <image src="../../static/images/1.png" mode="" class="img0"></image>
  50. </view>
  51. <view class="more">
  52. <view class="box" @click="allwormdel" v-show="allqingchong && filtrateTF">
  53. <p>清虫</p>
  54. </view>
  55. <view class="box" @click="online" v-show="filtrateTF">
  56. <p>在线</p>
  57. </view>
  58. <view class="box" @click="offline" v-show="filtrateTF">
  59. <p>离线</p>
  60. </view>
  61. <view class="box" @click="complete" v-show="filtrateTF">
  62. <p>全部</p>
  63. </view>
  64. <view @click="filtrate">
  65. <image src="../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. Debounce
  74. } from "../../util/anitthro.js"
  75. export default {
  76. data() {
  77. return {
  78. page: 1,
  79. size: 10,
  80. eqlistdata: [],
  81. isTop: false,
  82. filtrateTF: false,
  83. device_status: "",
  84. width: 0,
  85. imports: "", //搜索内容
  86. loadingtf: false, //loading
  87. show: false,
  88. title: "",
  89. content: "",
  90. allqingchong: false
  91. }
  92. },
  93. methods: {
  94. async eqlist() { //设备列表
  95. this.loadingtf = true
  96. const res = await this.$myRequest({
  97. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  98. data: {
  99. device_type_id: 2,
  100. page: this.page,
  101. page_size: "10",
  102. device_status: this.device_status,
  103. device_id: this.imports
  104. }
  105. })
  106. this.loadingtf = false
  107. this.eqlistdata = this.eqlistdata.concat(res.data)
  108. for (var i = 0; i < this.eqlistdata.length; i++) {
  109. if (this.eqlistdata[i].device_expire == 0) {
  110. this.eqlistdata[i]['device_expiretext'] = "未到期"
  111. } else if (this.eqlistdata[i].device_expire == 1) {
  112. this.eqlistdata[i]['device_expiretext'] = "已到期"
  113. } else if (this.eqlistdata[i].device_expire == 2) {
  114. this.eqlistdata[i]['device_expiretext'] = "即将到期"
  115. }
  116. }
  117. console.log(this.eqlistdata)
  118. },
  119. clickLeft() {
  120. uni.switchTab({
  121. url: "../index/index"
  122. })
  123. },
  124. clickRight() {
  125. // uni.navigateTo({
  126. // url: "./search"
  127. // })
  128. this.width = 600
  129. },
  130. eqdetails(data) {
  131. uni.navigateTo({
  132. url: "./equipmentdetails?shebei=" + JSON.stringify(data)
  133. })
  134. },
  135. filtrate() {
  136. this.filtrateTF = !this.filtrateTF
  137. },
  138. top() {
  139. uni.pageScrollTo({
  140. scrollTop: 0,
  141. duration: 500
  142. })
  143. },
  144. online() {
  145. this.eqlistdata = []
  146. this.page = 1
  147. this.device_status = 1
  148. this.eqlist()
  149. this.filtrateTF = !this.filtrateTF
  150. },
  151. offline() {
  152. this.eqlistdata = []
  153. this.page = 1
  154. this.device_status = 0
  155. this.eqlist()
  156. this.filtrateTF = !this.filtrateTF
  157. },
  158. complete() {
  159. this.eqlistdata = []
  160. this.page = 1
  161. this.device_status = ""
  162. this.eqlist()
  163. this.filtrateTF = !this.filtrateTF
  164. },
  165. search() { //搜索按钮搜索
  166. // this.eqlistdata = []
  167. this.searchinp()
  168. },
  169. searchinp() { //自动搜索
  170. Debounce(() => {
  171. this.page = 1
  172. this.eqlistdata = []
  173. this.eqlist()
  174. }, 1000)()
  175. },
  176. examine(e) {
  177. // console.log(this)
  178. this.show = true
  179. this.title = e.device_expiretext
  180. this.content =
  181. `<p style="padding-left:10px;margin:10px 0;font-size:14px;">到期时间 ${this.timezhuan(e.device_expire_time)}
  182. </p><p style="font-size:14px;text-align:right;color:#3C84FE;margin-bottom:10px;padding-right:10px">注:请前往PC端进行充值</p>`
  183. },
  184. timezhuan(time) {
  185. function fun(a) {
  186. return String(a).length == 1 ? '0' + a : a
  187. }
  188. let date = new Date(time * 1000)
  189. let y = date.getFullYear()
  190. let m = date.getMonth() + 1
  191. let d = date.getDate()
  192. let h = date.getHours()
  193. let min = date.getMinutes()
  194. let sec = date.getSeconds()
  195. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  196. },
  197. async getworm() {
  198. const res = await this.$myRequest({
  199. url: '/api/api_gateway?method=forecast.send_control.clear_insects_permission',
  200. data: {}
  201. })
  202. console.log(res)
  203. this.allqingchong = res[1] == 1 ? true : false;
  204. },
  205. async allwormdel() {
  206. const res = await this.$myRequest({
  207. url: '/api/api_gateway?method=forecast.send_control.clear_insects',
  208. data: {}
  209. })
  210. console.log(res)
  211. uni.showToast({
  212. title: res ? "指令下发成功" : "指令下发失败",
  213. icon: "none"
  214. })
  215. }
  216. },
  217. onLoad() {
  218. this.getworm()
  219. this.eqlist()
  220. },
  221. onReachBottom() {
  222. this.page++
  223. this.eqlist()
  224. },
  225. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  226. if (e.scrollTop > 200) { //距离大于200时显示
  227. this.isTop = true
  228. } else { //距离小于200时隐藏
  229. this.isTop = false
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss">
  235. .inputs {
  236. height: 54rpx;
  237. background-color: #E4E4E4;
  238. border-radius: 27rpx;
  239. position: absolute;
  240. right: 20rpx;
  241. top: 24rpx;
  242. transition: width 0.5s;
  243. overflow: hidden;
  244. padding-top: 8rpx;
  245. box-sizing: border-box;
  246. .inputbox {
  247. width: 85%;
  248. text-indent: 1rem;
  249. font-size: 26rpx;
  250. }
  251. .icon {
  252. position: absolute;
  253. top: 8rpx;
  254. right: 26rpx;
  255. }
  256. }
  257. /deep/.uni-icons {
  258. font-size: 40rpx !important;
  259. }
  260. .image {
  261. position: fixed;
  262. top: 88px;
  263. width: 100%;
  264. height: 160rpx;
  265. z-index: 555;
  266. }
  267. .loading {
  268. position: fixed;
  269. top: 440px;
  270. width: 95%;
  271. left: 2.5%;
  272. text-align: center;
  273. .img {
  274. width: 300rpx;
  275. height: 40rpx;
  276. }
  277. }
  278. .prevents {
  279. width: 100%;
  280. position: absolute;
  281. top: 140px;
  282. .prevents_item {
  283. width: 95%;
  284. margin: 0 auto 30rpx;
  285. border-radius: 10rpx;
  286. box-shadow: 0 0 10rpx #bcb9ca;
  287. padding: 20rpx 40rpx 20rpx 80rpx;
  288. position: relative;
  289. box-sizing: border-box;
  290. .prevents_item_img {
  291. width: 30rpx;
  292. height: 50rpx;
  293. position: absolute;
  294. top: -4rpx;
  295. left: 30rpx;
  296. }
  297. .prevents_item_top {
  298. display: flex;
  299. justify-content: space-between;
  300. height: 60rpx;
  301. border-bottom: 2rpx solid #F4F4F4;
  302. line-height: 60rpx;
  303. font-size: 26rpx;
  304. .red {
  305. color: #FF4747;
  306. }
  307. .green {
  308. color: #00B075;
  309. }
  310. }
  311. .prevents_item_bot {
  312. margin-top: 20rpx;
  313. font-size: 26rpx;
  314. color: #BDBDBD;
  315. .prevents_item_bot_sapn0 {
  316. color: #00B075;
  317. }
  318. .prevents_item_bot_sapn1 {
  319. color: #FF4747;
  320. }
  321. .prevents_item_bot_sapn2 {
  322. color: #FFAB00;
  323. }
  324. }
  325. }
  326. }
  327. .top {
  328. position: fixed;
  329. right: 10px;
  330. bottom: 40px;
  331. z-index: 100;
  332. image {
  333. width: 100rpx;
  334. height: 100rpx;
  335. }
  336. .backtop {
  337. display: flex;
  338. justify-content: flex-end;
  339. margin-bottom: 10rpx;
  340. }
  341. .more {
  342. display: flex;
  343. }
  344. .box {
  345. width: 80rpx;
  346. height: 80rpx;
  347. background-color: rgba(161, 161, 161, 0.45);
  348. border-radius: 50%;
  349. text-align: center;
  350. line-height: 80rpx;
  351. box-sizing: border-box;
  352. margin: 14rpx 10rpx 0 0;
  353. color: #fff;
  354. }
  355. }
  356. </style>