index.vue 12 KB

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