index.vue 9.6 KB

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