index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view>
  3. <!-- <view class="status_bar"></view>
  4. <view style="position: fixed;top:44px;z-index: 100;width: 100%;">
  5. <uni-nav-bar right-icon="search" title="设备列表" @clickRight="clickRight"></uni-nav-bar>
  6. </view> -->
  7. <view class="textbox">
  8. <view class="inputs">
  9. <!-- <u-input v-model="imports" type="text" :border="true" /> -->
  10. <u-search
  11. placeholder="请输入设备ID"
  12. v-model="imports"
  13. placeholder-color="#909696"
  14. :show-action="false"
  15. search-icon-color="#909696"
  16. @input="searchinput"
  17. >
  18. </u-search>
  19. <!-- <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinput"
  20. class="inputbox" :clearable="false" />
  21. <u-icon name="search" size="40" class="icon" @click="search"></u-icon> -->
  22. </view>
  23. <view class="listbox">
  24. <view class="listbox_left">
  25. <view
  26. :class="
  27. currents == index
  28. ? 'listbox_left_item_act listbox_left_item'
  29. : 'listbox_left_item'
  30. "
  31. v-for="(item, index) in list"
  32. :key="index"
  33. @click="change(index)"
  34. >
  35. {{ item.name }}
  36. </view>
  37. </view>
  38. <!-- <view class="list" @scroll='showOut' ref="sollo" id="list"> -->
  39. <scroll-view
  40. :scroll-top="0"
  41. :scroll-y="true"
  42. class="list scroll-Y"
  43. @scrolltoupper="upper"
  44. @scrolltolower="lower"
  45. @scroll="scroll"
  46. >
  47. <view
  48. class="list_item"
  49. v-for="(item, index) in eqlistdata"
  50. :key="index"
  51. @click="historys(item)"
  52. >
  53. <view class="list_item_top">
  54. <p class="p1">
  55. <image
  56. :src="
  57. 'http://www.hnyfwlw.com:8006/bigdata_app/image/fourMoodBase/' +
  58. type_id +
  59. '.png'
  60. "
  61. mode=""
  62. ></image>
  63. {{ item.device_name == "" ? "--" : item.device_name }}
  64. </p>
  65. <p
  66. v-if="![11, 19, 20].includes(type_id)"
  67. :class="[item.is_online ? 'p2' : 'p_out']"
  68. >
  69. {{ item.is_online ? "在线" : "离线" }}
  70. </p>
  71. </view>
  72. <view class="list_item_text">
  73. <p>设备ID:{{ item.imei || item.device_id }}</p>
  74. <p>
  75. 适配用户:{{ item.real_name == "" ? "无" : item.real_name }}
  76. </p>
  77. <p>最新上报时间:{{ item.addtime | timeFormat() }}</p>
  78. <p v-if="item.uptime === 0">添加设备时间:- -</p>
  79. <p v-else>添加设备时间:{{ item.uptime | timeFormat() }}</p>
  80. <p>设备已运行:{{ item.days }}天</p>
  81. </view>
  82. <view
  83. class="list_item_btn"
  84. v-if="$QueryPermission(108) && ![13, 17, 18, 11, 19, 20, 14].includes(type_id)"
  85. @click.stop="modification(item)"
  86. >
  87. 信息修改
  88. </view>
  89. </view>
  90. </scroll-view>
  91. <!-- </view> -->
  92. </view>
  93. </view>
  94. <!-- <view class="utabs_box">
  95. <view class="utabs">
  96. <u-tabs :list="list" :is-scroll="true" :current="currents" @change="change" item-width="140"
  97. font-size="24" gutter="20" bar-width="60" active-color="#42b983" v-if="list.length"></u-tabs>
  98. </view>
  99. </view> -->
  100. <view class="loading" v-if="loadingtf">
  101. <image
  102. src="../../static/images/ajax-loader.gif"
  103. mode=""
  104. class="img"
  105. ></image>
  106. </view>
  107. <view class="top" v-if="isTop" @click="top">
  108. <image
  109. :src="
  110. 'http://www.hnyfwlw.com:8006/bigdata_app' +
  111. '/image/6209a98f0cb3b5086f2ca36152c9269.png'
  112. "
  113. mode=""
  114. ></image>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import { Debounce, Throttle } from "../../util/anitthro.js";
  120. export default {
  121. data() {
  122. return {
  123. list: [],
  124. current: 0,
  125. currents: 0,
  126. page: 1,
  127. size: 10,
  128. eqlistdata: [],
  129. isTop: false,
  130. infoalter: false, // 权限设置,
  131. type_id: 0, //设备类型,
  132. imgpath: [],
  133. loadingtf: false,
  134. width: 0, //顶部搜索栏宽度
  135. imports: "", //搜索设备ID
  136. };
  137. },
  138. methods: {
  139. async eqlist(tf) {
  140. //设备列表
  141. this.loadingtf = true;
  142. const res = await this.$myRequest({
  143. url: "/api/api_gateway?method=forecast.worm_lamp.lamp_list",
  144. data: {
  145. device_type_id: this.type_id,
  146. page: this.page,
  147. page_size: this.size,
  148. device_id: this.imports,
  149. },
  150. });
  151. this.loadingtf = false;
  152. if ([11, 19, 20].includes(Number(this.type_id))) {
  153. var newtime = +new Date() / 1000;
  154. } else {
  155. var newtime = +new Date() / 1000;
  156. }
  157. if (tf) {
  158. this.eqlistdata = this.eqlistdata.concat(res.data);
  159. } else {
  160. this.eqlistdata = res.data;
  161. }
  162. console.log(this.eqlistdata);
  163. for (var i = 0; i < this.eqlistdata.length; i++) {
  164. var days = (newtime - this.eqlistdata[i].uptime) / 60 / 60 / 24;
  165. this.eqlistdata[i].days = Math.round(days);
  166. }
  167. },
  168. async xyeqlist(tf) {
  169. //设备列表
  170. this.loadingtf = true;
  171. const res = await this.$myRequest({
  172. url: "/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list",
  173. data: {
  174. device_type_id: this.type_id,
  175. page: this.page,
  176. page_size: this.size,
  177. device_id: this.imports,
  178. },
  179. });
  180. this.loadingtf = false;
  181. var newtime = +new Date() / 1000;
  182. if (tf) {
  183. this.eqlistdata = this.eqlistdata.concat(res.data);
  184. } else {
  185. this.eqlistdata = res.data;
  186. }
  187. for (var i = 0; i < this.eqlistdata.length; i++) {
  188. var days = (newtime - this.eqlistdata[i].uptime) / 60 / 60 / 24;
  189. this.eqlistdata[i].days = Math.round(days);
  190. }
  191. console.log(res);
  192. },
  193. //camera.camera_manage.list_camera
  194. async camera() {
  195. //监控
  196. const res = await this.$myRequest({
  197. url: "/api/api_gateway?method=camera.camera_manage.list_camera",
  198. data: {
  199. page_size: 1,
  200. },
  201. });
  202. this.accessToken = res.accessToken;
  203. },
  204. // homes.user_device_type
  205. async usertype() {
  206. //设备列表
  207. const res = await this.$myRequest({
  208. url: "/api/api_gateway?method=home.homes.user_device_type",
  209. });
  210. console.log(res);
  211. for (var i = 0; i < res.length; i++) {
  212. if (
  213. res[i].type_name == "温室大棚"
  214. ) {
  215. continue;
  216. }
  217. var obj = {
  218. name: res[i].type_name,
  219. id: res[i].id,
  220. };
  221. this.list.push(obj);
  222. }
  223. console.log("设备列表11111111111111", this.list);
  224. if (res.length) {
  225. this.type_id = this.list[0].id;
  226. if (this.list[0].id == 10) {
  227. this.xyeqlist();
  228. } else {
  229. this.eqlist();
  230. }
  231. }
  232. },
  233. change(index) {
  234. console.log(index);
  235. //头部导航栏的点击
  236. this.imports = "";
  237. this.current = index;
  238. this.currents = index;
  239. this.page = 1;
  240. this.eqlistdata = [];
  241. this.type_id = this.list[index].id;
  242. console.log(this.type_id);
  243. if (this.list[index].id == 10) {
  244. this.xyeqlist();
  245. } else {
  246. this.eqlist();
  247. }
  248. },
  249. clickRight() {
  250. //搜索
  251. this.width = "90%";
  252. },
  253. modification(item) {
  254. uni.navigateTo({
  255. url:
  256. "./modification?data=" + JSON.stringify(item) + "&id=" + this.type_id,
  257. });
  258. },
  259. top() {
  260. uni.pageScrollTo({
  261. scrollTop: 0,
  262. duration: 500,
  263. });
  264. },
  265. historys(item) {
  266. console.log("item", item);
  267. switch (this.type_id) {
  268. // 病虫害可视监测
  269. case 14:
  270. uni.navigateTo({
  271. url: "../cb/sy/detail?detail=" + JSON.stringify(item),
  272. });
  273. break
  274. case 2:
  275. uni.navigateTo({
  276. url:
  277. "../prevention/equipmentdetails?shebei=" + JSON.stringify(item),
  278. });
  279. break;
  280. case 5:
  281. console.log(item);
  282. var obj = {};
  283. obj.d_id = item.d_id;
  284. obj.equip_id = item.imei;
  285. obj.is_online = item.is_online;
  286. obj.lat = item.lat;
  287. obj.lng = item.lng;
  288. obj.equip_name = item.device_name;
  289. obj.uptime = item.addtime;
  290. uni.navigateTo({
  291. url: "../environment/equipment?shebei=" + JSON.stringify(obj),
  292. });
  293. break;
  294. case 6:
  295. uni.navigateTo({
  296. url:
  297. "/pages/webview?device_id=" +
  298. item.imei +
  299. "&accessToken=" +
  300. this.accessToken,
  301. });
  302. break;
  303. case 3:
  304. item.type = this.type_id;
  305. uni.navigateTo({
  306. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  307. });
  308. break;
  309. case 4:
  310. item.type = this.type_id;
  311. uni.navigateTo({
  312. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  313. });
  314. break;
  315. case 7:
  316. item.type = this.type_id;
  317. uni.navigateTo({
  318. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  319. });
  320. break;
  321. case 8:
  322. // item.type = this.type_id;
  323. uni.navigateTo({
  324. url: "../cb/thxydetail/thxydetail?imei=" + item.imei
  325. });
  326. break;
  327. case 12:
  328. console.log(item);
  329. uni.navigateTo({
  330. url: "../cb/xctdetail/xctdetail?info=" + JSON.stringify(item),
  331. });
  332. break;
  333. case 13:
  334. console.log(item);
  335. var obj = {};
  336. obj.d_id = item.d_id;
  337. obj.device_id = item.imei;
  338. obj.is_online = item.is_online;
  339. obj.lat = item.lat;
  340. obj.lng = item.lng;
  341. obj.equip_name = item.device_name;
  342. obj.uptime = item.addtime;
  343. uni.navigateTo({
  344. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj),
  345. });
  346. break;
  347. case 15:
  348. console.log(item);
  349. var obj = {};
  350. obj.d_id = item.d_id;
  351. obj.device_id = item.imei;
  352. obj.is_online = item.is_online;
  353. obj.lat = item.lat;
  354. obj.lng = item.lng;
  355. obj.equip_name = item.device_name;
  356. obj.uptime = item.addtime;
  357. uni.navigateTo({
  358. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj),
  359. });
  360. break;
  361. case 17:
  362. break;
  363. case 18:
  364. break;
  365. case 11:
  366. var obj = {};
  367. obj.d_id = item.d_id;
  368. obj.device_id = item.imei;
  369. obj.is_online = item.is_online;
  370. obj.lat = item.lat;
  371. obj.lng = item.lng;
  372. obj.equip_name = item.device_name;
  373. obj.uptime = item.addtime;
  374. obj.location = item.address;
  375. obj.type = 11;
  376. uni.navigateTo({
  377. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  378. });
  379. break;
  380. case 19:
  381. var obj = {};
  382. obj.d_id = item.d_id;
  383. obj.device_id = item.imei;
  384. obj.is_online = item.is_online;
  385. obj.lat = item.lat;
  386. obj.lng = item.lng;
  387. obj.equip_name = item.device_name;
  388. obj.uptime = item.addtime;
  389. obj.location = item.address;
  390. obj.type = 19;
  391. uni.navigateTo({
  392. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  393. });
  394. break;
  395. case 20:
  396. var obj = {};
  397. obj.d_id = item.d_id;
  398. obj.device_id = item.imei;
  399. obj.is_online = item.is_online;
  400. obj.lat = item.lat;
  401. obj.lng = item.lng;
  402. obj.equip_name = item.device_name;
  403. obj.uptime = item.addtime;
  404. obj.location = item.address;
  405. obj.type = 20;
  406. uni.navigateTo({
  407. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  408. });
  409. break;
  410. default:
  411. item.type = this.type_id;
  412. uni.navigateTo({
  413. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item),
  414. });
  415. break;
  416. }
  417. },
  418. search() {
  419. //搜索
  420. this.eqlistdata = [];
  421. this.page = 1;
  422. if (this.list[this.currents].id == 10) {
  423. this.xyeqlist();
  424. } else {
  425. this.eqlist();
  426. }
  427. },
  428. searchinput() {
  429. Debounce(() => {
  430. this.eqlistdata = [];
  431. this.page = 1;
  432. if (this.list[this.currents].id == 10) {
  433. this.xyeqlist();
  434. } else {
  435. this.eqlist();
  436. }
  437. }, 1000)();
  438. },
  439. scrollTop(e) {
  440. console.log(e);
  441. },
  442. upper() {},
  443. lower() {
  444. console.log(11);
  445. this.page++;
  446. if (this.type_id == 10) {
  447. this.xyeqlist(true);
  448. } else {
  449. this.eqlist(true);
  450. }
  451. },
  452. scroll() {},
  453. },
  454. onLoad() {
  455. this.list = [];
  456. this.camera();
  457. this.current = 0;
  458. this.currents = 0;
  459. this.page = 1;
  460. this.usertype();
  461. this.width = 0;
  462. },
  463. onReachBottom() {
  464. this.page++;
  465. if (this.type_id == 10) {
  466. this.xyeqlist(true);
  467. } else {
  468. this.eqlist(true);
  469. }
  470. },
  471. onPageScroll(e) {
  472. //nvue暂不支持滚动监听,可用bindingx代替
  473. if (e.scrollTop > 200) {
  474. //距离大于200时显示
  475. this.isTop = true;
  476. } else {
  477. //距离小于200时隐藏
  478. this.isTop = false;
  479. }
  480. },
  481. };
  482. </script>
  483. <style lang="scss">
  484. page {
  485. background-color: #00b075;
  486. }
  487. /deep/.uni-icons {
  488. font-size: 40rpx !important;
  489. }
  490. .textbox {
  491. width: 100%;
  492. height: 100vh;
  493. padding: 20rpx 30rpx;
  494. box-sizing: border-box;
  495. border-top-left-radius: 80rpx;
  496. border-top-right-radius: 80rpx;
  497. margin-top: 30rpx;
  498. background-color: #f9f9f9;
  499. }
  500. .inputs {
  501. /deep/.u-content {
  502. background-color: #fff !important;
  503. }
  504. /deep/.uni-input-wrapper {
  505. background-color: #fff !important;
  506. }
  507. }
  508. .utabs_box {
  509. width: 100%;
  510. position: fixed;
  511. top: 88px;
  512. background-color: #ffffff;
  513. z-index: 100;
  514. .utabs {
  515. width: 95%;
  516. margin: 0 auto;
  517. }
  518. }
  519. .loading {
  520. position: fixed;
  521. top: 440px;
  522. width: 95%;
  523. left: 2.5%;
  524. text-align: center;
  525. .img {
  526. width: 300rpx;
  527. height: 40rpx;
  528. }
  529. }
  530. .listbox {
  531. display: flex;
  532. justify-content: space-around;
  533. height: calc(100vh - 84px);
  534. margin-top: 20rpx;
  535. .listbox_left {
  536. background-color: #fff;
  537. padding: 20rpx;
  538. width: 140rpx;
  539. .listbox_left_item {
  540. height: 50rpx;
  541. width: 100%;
  542. margin-bottom: 20rpx;
  543. text-align: center;
  544. border-radius: 10rpx;
  545. line-height: 50rpx;
  546. overflow: hidden; //溢出隐藏
  547. white-space: nowrap; //禁止换行
  548. text-overflow: ellipsis; //...
  549. }
  550. .listbox_left_item_act {
  551. background-color: rgba(0, 176, 117, 0.2);
  552. color: #00b075;
  553. }
  554. }
  555. }
  556. .list {
  557. width: 70%;
  558. background-color: #fdfdfd;
  559. // margin-bottom: 100rpx;
  560. overflow-y: auto;
  561. .list_item {
  562. width: 100%;
  563. margin: 0 auto 20rpx;
  564. padding: 20rpx 20rpx;
  565. box-sizing: border-box;
  566. position: relative;
  567. background-color: #ffffff;
  568. box-shadow: 0 0 10rpx #bcb9ca;
  569. .list_item_top {
  570. display: flex;
  571. justify-content: space-between;
  572. .p1 {
  573. height: 60rpx;
  574. line-height: 60rpx;
  575. font-size: 28rpx;
  576. image {
  577. width: 40rpx;
  578. height: 40rpx;
  579. vertical-align: text-top;
  580. margin-right: 20rpx;
  581. }
  582. }
  583. .p2 {
  584. height: 60rpx;
  585. line-height: 60rpx;
  586. font-size: 28rpx;
  587. color: #42b983;
  588. }
  589. .p_out {
  590. height: 60rpx;
  591. line-height: 60rpx;
  592. font-size: 28rpx;
  593. color: red;
  594. }
  595. }
  596. .list_item_text {
  597. margin-top: 20rpx;
  598. p {
  599. font-size: 24rpx;
  600. color: #636363;
  601. margin-top: 10rpx;
  602. }
  603. p:first-child {
  604. font-size: 28rpx;
  605. font-weight: 700;
  606. }
  607. }
  608. .list_item_btn {
  609. width: 126rpx;
  610. color: #42b983;
  611. height: 40rpx;
  612. text-align: center;
  613. border: 1rpx solid #42b983;
  614. border-radius: 25rpx;
  615. font-size: 24rpx;
  616. line-height: 35rpx;
  617. position: absolute;
  618. bottom: 15rpx;
  619. right: 20rpx;
  620. }
  621. }
  622. }
  623. .top {
  624. position: fixed;
  625. right: 30px;
  626. bottom: 100px;
  627. z-index: 100;
  628. image {
  629. width: 100rpx;
  630. height: 100rpx;
  631. }
  632. }
  633. </style>