index.vue 13 KB

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