index.vue 11 KB

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