index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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].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. res[i].type_name == "温室大棚"
  215. ) {
  216. continue;
  217. }
  218. var obj = {
  219. name: res[i].type_name,
  220. id: res[i].id,
  221. };
  222. this.list.push(obj);
  223. }
  224. console.log("设备列表11111111111111", this.list);
  225. if (res.length) {
  226. this.type_id = this.list[0].id;
  227. if (this.list[0].id == 10) {
  228. this.xyeqlist();
  229. } else {
  230. this.eqlist();
  231. }
  232. }
  233. },
  234. change(index) {
  235. console.log(index);
  236. //头部导航栏的点击
  237. this.imports = "";
  238. this.current = index;
  239. this.currents = index;
  240. this.page = 1;
  241. this.eqlistdata = [];
  242. this.type_id = this.list[index].id;
  243. console.log(this.type_id);
  244. if (this.list[index].id == 10) {
  245. this.xyeqlist();
  246. } else {
  247. this.eqlist();
  248. }
  249. },
  250. clickRight() {
  251. //搜索
  252. this.width = "90%";
  253. },
  254. modification(item) {
  255. uni.navigateTo({
  256. url:
  257. "./modification?data=" + JSON.stringify(item) + "&id=" + this.type_id,
  258. });
  259. },
  260. top() {
  261. uni.pageScrollTo({
  262. scrollTop: 0,
  263. duration: 500,
  264. });
  265. },
  266. historys(item) {
  267. console.log("item", item);
  268. switch (this.type_id) {
  269. case 2:
  270. uni.navigateTo({
  271. url:
  272. "../prevention/equipmentdetails?shebei=" + JSON.stringify(item),
  273. });
  274. break;
  275. case 5:
  276. console.log(item);
  277. var obj = {};
  278. obj.d_id = item.d_id;
  279. obj.equip_id = item.imei;
  280. obj.is_online = item.is_online;
  281. obj.lat = item.lat;
  282. obj.lng = item.lng;
  283. obj.equip_name = item.device_name;
  284. obj.uptime = item.addtime;
  285. uni.navigateTo({
  286. url: "../environment/equipment?shebei=" + JSON.stringify(obj),
  287. });
  288. break;
  289. case 6:
  290. uni.navigateTo({
  291. url:
  292. "/pages/webview?device_id=" +
  293. item.imei +
  294. "&accessToken=" +
  295. this.accessToken,
  296. });
  297. break;
  298. case 3:
  299. item.type = this.type_id;
  300. uni.navigateTo({
  301. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  302. });
  303. break;
  304. case 4:
  305. item.type = this.type_id;
  306. uni.navigateTo({
  307. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  308. });
  309. break;
  310. case 7:
  311. item.type = this.type_id;
  312. uni.navigateTo({
  313. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  314. });
  315. break;
  316. case 8:
  317. // item.type = this.type_id;
  318. uni.navigateTo({
  319. url: "../cb/thxydetail/thxydetail?imei=" + item.imei
  320. });
  321. break;
  322. case 12:
  323. console.log(item);
  324. uni.navigateTo({
  325. url: "../cb/xctdetail/xctdetail?info=" + JSON.stringify(item),
  326. });
  327. break;
  328. case 13:
  329. console.log(item);
  330. var obj = {};
  331. obj.d_id = item.d_id;
  332. obj.device_id = item.imei;
  333. obj.is_online = item.is_online;
  334. obj.lat = item.lat;
  335. obj.lng = item.lng;
  336. obj.equip_name = item.device_name;
  337. obj.uptime = item.addtime;
  338. uni.navigateTo({
  339. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj),
  340. });
  341. break;
  342. case 15:
  343. console.log(item);
  344. var obj = {};
  345. obj.d_id = item.d_id;
  346. obj.device_id = item.imei;
  347. obj.is_online = item.is_online;
  348. obj.lat = item.lat;
  349. obj.lng = item.lng;
  350. obj.equip_name = item.device_name;
  351. obj.uptime = item.addtime;
  352. uni.navigateTo({
  353. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj),
  354. });
  355. break;
  356. case 17:
  357. break;
  358. case 18:
  359. break;
  360. case 11:
  361. var obj = {};
  362. obj.d_id = item.d_id;
  363. obj.device_id = item.imei;
  364. obj.is_online = item.is_online;
  365. obj.lat = item.lat;
  366. obj.lng = item.lng;
  367. obj.equip_name = item.device_name;
  368. obj.uptime = item.addtime;
  369. obj.location = item.address;
  370. obj.type = 11;
  371. uni.navigateTo({
  372. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  373. });
  374. break;
  375. case 19:
  376. var obj = {};
  377. obj.d_id = item.d_id;
  378. obj.device_id = item.imei;
  379. obj.is_online = item.is_online;
  380. obj.lat = item.lat;
  381. obj.lng = item.lng;
  382. obj.equip_name = item.device_name;
  383. obj.uptime = item.addtime;
  384. obj.location = item.address;
  385. obj.type = 19;
  386. uni.navigateTo({
  387. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  388. });
  389. break;
  390. case 20:
  391. var obj = {};
  392. obj.d_id = item.d_id;
  393. obj.device_id = item.imei;
  394. obj.is_online = item.is_online;
  395. obj.lat = item.lat;
  396. obj.lng = item.lng;
  397. obj.equip_name = item.device_name;
  398. obj.uptime = item.addtime;
  399. obj.location = item.address;
  400. obj.type = 20;
  401. uni.navigateTo({
  402. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  403. });
  404. break;
  405. default:
  406. item.type = this.type_id;
  407. uni.navigateTo({
  408. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item),
  409. });
  410. break;
  411. }
  412. },
  413. search() {
  414. //搜索
  415. this.eqlistdata = [];
  416. this.page = 1;
  417. if (this.list[this.currents].id == 10) {
  418. this.xyeqlist();
  419. } else {
  420. this.eqlist();
  421. }
  422. },
  423. searchinput() {
  424. Debounce(() => {
  425. this.eqlistdata = [];
  426. this.page = 1;
  427. if (this.list[this.currents].id == 10) {
  428. this.xyeqlist();
  429. } else {
  430. this.eqlist();
  431. }
  432. }, 1000)();
  433. },
  434. scrollTop(e) {
  435. console.log(e);
  436. },
  437. upper() {},
  438. lower() {
  439. console.log(11);
  440. this.page++;
  441. if (this.type_id == 10) {
  442. this.xyeqlist(true);
  443. } else {
  444. this.eqlist(true);
  445. }
  446. },
  447. scroll() {},
  448. },
  449. onLoad() {
  450. this.list = [];
  451. this.camera();
  452. this.current = 0;
  453. this.currents = 0;
  454. this.page = 1;
  455. this.usertype();
  456. this.width = 0;
  457. },
  458. onReachBottom() {
  459. this.page++;
  460. if (this.type_id == 10) {
  461. this.xyeqlist(true);
  462. } else {
  463. this.eqlist(true);
  464. }
  465. },
  466. onPageScroll(e) {
  467. //nvue暂不支持滚动监听,可用bindingx代替
  468. if (e.scrollTop > 200) {
  469. //距离大于200时显示
  470. this.isTop = true;
  471. } else {
  472. //距离小于200时隐藏
  473. this.isTop = false;
  474. }
  475. },
  476. };
  477. </script>
  478. <style lang="scss">
  479. page {
  480. background-color: #00b075;
  481. }
  482. /deep/.uni-icons {
  483. font-size: 40rpx !important;
  484. }
  485. .textbox {
  486. width: 100%;
  487. height: 100vh;
  488. padding: 20rpx 30rpx;
  489. box-sizing: border-box;
  490. border-top-left-radius: 80rpx;
  491. border-top-right-radius: 80rpx;
  492. margin-top: 30rpx;
  493. background-color: #f9f9f9;
  494. }
  495. .inputs {
  496. /deep/.u-content {
  497. background-color: #fff !important;
  498. }
  499. /deep/.uni-input-wrapper {
  500. background-color: #fff !important;
  501. }
  502. }
  503. .utabs_box {
  504. width: 100%;
  505. position: fixed;
  506. top: 88px;
  507. background-color: #ffffff;
  508. z-index: 100;
  509. .utabs {
  510. width: 95%;
  511. margin: 0 auto;
  512. }
  513. }
  514. .loading {
  515. position: fixed;
  516. top: 440px;
  517. width: 95%;
  518. left: 2.5%;
  519. text-align: center;
  520. .img {
  521. width: 300rpx;
  522. height: 40rpx;
  523. }
  524. }
  525. .listbox {
  526. display: flex;
  527. justify-content: space-around;
  528. height: calc(100vh - 84px);
  529. margin-top: 20rpx;
  530. .listbox_left {
  531. background-color: #fff;
  532. padding: 20rpx;
  533. width: 140rpx;
  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. height: 60rpx;
  569. line-height: 60rpx;
  570. font-size: 28rpx;
  571. image {
  572. width: 40rpx;
  573. height: 40rpx;
  574. vertical-align: text-top;
  575. margin-right: 20rpx;
  576. }
  577. }
  578. .p2 {
  579. height: 60rpx;
  580. line-height: 60rpx;
  581. font-size: 28rpx;
  582. color: #42b983;
  583. }
  584. .p_out {
  585. height: 60rpx;
  586. line-height: 60rpx;
  587. font-size: 28rpx;
  588. color: red;
  589. }
  590. }
  591. .list_item_text {
  592. margin-top: 20rpx;
  593. p {
  594. font-size: 24rpx;
  595. color: #636363;
  596. margin-top: 10rpx;
  597. }
  598. p:first-child {
  599. font-size: 28rpx;
  600. font-weight: 700;
  601. }
  602. }
  603. .list_item_btn {
  604. width: 126rpx;
  605. color: #42b983;
  606. height: 40rpx;
  607. text-align: center;
  608. border: 1rpx solid #42b983;
  609. border-radius: 25rpx;
  610. font-size: 24rpx;
  611. line-height: 35rpx;
  612. position: absolute;
  613. bottom: 15rpx;
  614. right: 20rpx;
  615. }
  616. }
  617. }
  618. .top {
  619. position: fixed;
  620. right: 30px;
  621. bottom: 100px;
  622. z-index: 100;
  623. image {
  624. width: 100rpx;
  625. height: 100rpx;
  626. }
  627. }
  628. </style>