index.vue 11 KB

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