index.vue 17 KB

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