index.vue 17 KB

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