index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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. this.device_model = this.list[0].device_model;
  189. if (this.list[0].id == 10) {
  190. this.xyeqlist();
  191. } else {
  192. this.eqlist();
  193. }
  194. }
  195. },
  196. change(index) {
  197. console.log(index);
  198. //头部导航栏的点击
  199. this.imports = "";
  200. this.current = index;
  201. this.currents = index;
  202. this.page = 1;
  203. this.eqlistdata = [];
  204. this.type_id = this.list[index].id;
  205. this.device_model = this.list[index].device_model;
  206. console.log(this.type_id);
  207. if (this.list[index].id == 10) {
  208. this.xyeqlist();
  209. } else {
  210. this.eqlist();
  211. }
  212. },
  213. clickRight() {
  214. //搜索
  215. this.width = "90%";
  216. },
  217. modification(item) {
  218. uni.navigateTo({
  219. url:
  220. "./modification?data=" + JSON.stringify(item) + "&id=" + this.type_id,
  221. });
  222. },
  223. top() {
  224. uni.pageScrollTo({
  225. scrollTop: 0,
  226. duration: 500,
  227. });
  228. },
  229. historys(item) {
  230. console.log("item", item);
  231. switch (this.type_id) {
  232. // 水肥新设备
  233. case 22:
  234. var obj = {};
  235. obj.d_id = item.d_id;
  236. obj.device_id = item.imei;
  237. obj.is_online = item.is_online;
  238. obj.lat = item.lat;
  239. obj.lng = item.lng;
  240. obj.equip_name = item.device_name;
  241. obj.uptime = item.addtime;
  242. uni.navigateTo({
  243. url: "../waterandfernew/details?shebei=" + JSON.stringify(obj),
  244. });
  245. break
  246. // 病虫害可视监测
  247. case 14:
  248. uni.navigateTo({
  249. url: "../cb/sy/detail?detail=" + JSON.stringify(item),
  250. });
  251. break
  252. case 2:
  253. uni.navigateTo({
  254. url:
  255. "../prevention/equipmentdetails?shebei=" + JSON.stringify(item),
  256. });
  257. break;
  258. case 5:
  259. console.log(item);
  260. var obj = {};
  261. obj.d_id = item.d_id;
  262. obj.equip_id = item.imei;
  263. obj.is_online = item.is_online;
  264. obj.lat = item.lat;
  265. obj.lng = item.lng;
  266. obj.equip_name = item.device_name;
  267. obj.uptime = item.addtime;
  268. uni.navigateTo({
  269. url: "../environment/equipment?shebei=" + JSON.stringify(obj),
  270. });
  271. break;
  272. case 6:
  273. uni.navigateTo({
  274. url:
  275. "/pages/webview?device_id=" +
  276. item.imei +
  277. "&accessToken=" +
  278. this.accessToken,
  279. });
  280. break;
  281. case 3:
  282. item.type = this.type_id;
  283. uni.navigateTo({
  284. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  285. });
  286. break;
  287. case 4:
  288. item.type = this.type_id;
  289. uni.navigateTo({
  290. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  291. });
  292. break;
  293. case 7:
  294. item.type = this.type_id;
  295. uni.navigateTo({
  296. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item),
  297. });
  298. break;
  299. case 8:
  300. // item.type = this.type_id;
  301. uni.navigateTo({
  302. url: "../cb/thxydetail/thxydetail?imei=" + item.imei
  303. });
  304. break;
  305. case 24:
  306. // item.type = this.type_id;
  307. uni.navigateTo({
  308. url: "../cb/zjxydetail/thxydetail?imei=" + item.imei
  309. });
  310. break;
  311. case 12:
  312. console.log(item);
  313. uni.navigateTo({
  314. url: "../cb/xctdetail/xctdetail?info=" + JSON.stringify(item),
  315. });
  316. break;
  317. case 13:
  318. console.log(item);
  319. var obj = {};
  320. obj.d_id = item.d_id;
  321. obj.device_id = item.imei;
  322. obj.is_online = item.is_online;
  323. obj.lat = item.lat;
  324. obj.lng = item.lng;
  325. obj.equip_name = item.device_name;
  326. obj.uptime = item.addtime;
  327. uni.navigateTo({
  328. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj),
  329. });
  330. break;
  331. case 15:
  332. console.log(item);
  333. var obj = {};
  334. obj.d_id = item.d_id;
  335. obj.device_id = item.imei;
  336. obj.is_online = item.is_online;
  337. obj.lat = item.lat;
  338. obj.lng = item.lng;
  339. obj.equip_name = item.device_name;
  340. obj.uptime = item.addtime;
  341. uni.navigateTo({
  342. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj),
  343. });
  344. break;
  345. case 17:
  346. break;
  347. case 18:
  348. var obj = {};
  349. obj.device_id = item.imei;
  350. obj.is_online = item.is_online;
  351. uni.navigateTo({
  352. url: "../cb/shuifeiL/shuifeiL?detail=" + JSON.stringify(obj),
  353. });
  354. break;
  355. case 11:
  356. var obj = {};
  357. obj.d_id = item.d_id;
  358. obj.device_id = item.imei;
  359. obj.is_online = item.is_online;
  360. obj.lat = item.lat;
  361. obj.lng = item.lng;
  362. obj.equip_name = item.device_name;
  363. obj.uptime = item.addtime;
  364. obj.location = item.address;
  365. obj.type = 11;
  366. uni.navigateTo({
  367. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  368. });
  369. break;
  370. case 19:
  371. var obj = {};
  372. obj.d_id = item.d_id;
  373. obj.device_id = item.imei;
  374. obj.is_online = item.is_online;
  375. obj.lat = item.lat;
  376. obj.lng = item.lng;
  377. obj.equip_name = item.device_name;
  378. obj.uptime = item.addtime;
  379. obj.location = item.address;
  380. obj.type = 19;
  381. uni.navigateTo({
  382. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  383. });
  384. break;
  385. case 20:
  386. var obj = {};
  387. obj.d_id = item.d_id;
  388. obj.device_id = item.imei;
  389. obj.is_online = item.is_online;
  390. obj.lat = item.lat;
  391. obj.lng = item.lng;
  392. obj.equip_name = item.device_name;
  393. obj.uptime = item.addtime;
  394. obj.location = item.address;
  395. obj.type = 20;
  396. uni.navigateTo({
  397. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  398. });
  399. break;
  400. case 21:
  401. var obj = {};
  402. obj.d_id = item.d_id;
  403. obj.device_id = item.imei;
  404. obj.is_online = item.is_online;
  405. obj.lat = item.lat;
  406. obj.lng = item.lng;
  407. obj.equip_name = item.device_name;
  408. obj.uptime = item.addtime;
  409. obj.location = item.address;
  410. obj.type = 20;
  411. uni.navigateTo({
  412. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  413. });
  414. break;
  415. default:
  416. item.type = this.type_id;
  417. uni.navigateTo({
  418. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item),
  419. });
  420. break;
  421. }
  422. },
  423. search() {
  424. //搜索
  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. },
  433. searchinput() {
  434. Debounce(() => {
  435. this.eqlistdata = [];
  436. this.page = 1;
  437. if (this.list[this.currents].id == 10) {
  438. this.xyeqlist();
  439. } else {
  440. this.eqlist();
  441. }
  442. }, 1000)();
  443. },
  444. scrollTop(e) {
  445. console.log(e);
  446. },
  447. upper() { },
  448. lower() {
  449. console.log(11);
  450. this.page++;
  451. if (this.type_id == 10) {
  452. this.xyeqlist(true);
  453. } else {
  454. this.eqlist(true);
  455. }
  456. },
  457. scroll() { },
  458. },
  459. onLoad() {
  460. // this.list = [];
  461. // this.camera();
  462. // this.current = 0;
  463. // this.currents = 0;
  464. // this.page = 1;
  465. // this.usertype();
  466. // this.width = 0;
  467. },
  468. onTabItemTap (e) {
  469. // console.log(e);
  470. this.eqlistdata = [];
  471. this.list = [];
  472. this.camera();
  473. this.current = 0;
  474. this.currents = 0;
  475. this.page = 1;
  476. this.usertype();
  477. this.width = 0;
  478. },
  479. onReachBottom() {
  480. this.page++;
  481. if (this.type_id == 10) {
  482. this.xyeqlist(true);
  483. } else {
  484. this.eqlist(true);
  485. }
  486. },
  487. onPageScroll(e) {
  488. //nvue暂不支持滚动监听,可用bindingx代替
  489. if (e.scrollTop > 200) {
  490. //距离大于200时显示
  491. this.isTop = true;
  492. } else {
  493. //距离小于200时隐藏
  494. this.isTop = false;
  495. }
  496. },
  497. };
  498. </script>
  499. <style lang="scss">
  500. page {
  501. background-color: #00b075;
  502. }
  503. /deep/.uni-icons {
  504. font-size: 40rpx !important;
  505. }
  506. .textbox {
  507. width: 100%;
  508. height: 100vh;
  509. padding: 20rpx 30rpx;
  510. box-sizing: border-box;
  511. border-top-left-radius: 80rpx;
  512. border-top-right-radius: 80rpx;
  513. margin-top: 30rpx;
  514. background-color: #f9f9f9;
  515. }
  516. .inputs {
  517. /deep/.u-content {
  518. background-color: #fff !important;
  519. }
  520. /deep/.uni-input-wrapper {
  521. background-color: #fff !important;
  522. }
  523. }
  524. .utabs_box {
  525. width: 100%;
  526. position: fixed;
  527. top: 88px;
  528. background-color: #ffffff;
  529. z-index: 100;
  530. .utabs {
  531. width: 95%;
  532. margin: 0 auto;
  533. }
  534. }
  535. .loading {
  536. position: fixed;
  537. top: 440px;
  538. width: 95%;
  539. left: 2.5%;
  540. text-align: center;
  541. .img {
  542. width: 300rpx;
  543. height: 40rpx;
  544. }
  545. }
  546. .listbox {
  547. display: flex;
  548. justify-content: space-around;
  549. height: calc(100vh - 84px);
  550. margin-top: 20rpx;
  551. .listbox_left {
  552. background-color: #fff;
  553. padding: 20rpx;
  554. width: 140rpx;
  555. overflow: auto;
  556. .listbox_left_item {
  557. height: 50rpx;
  558. width: 100%;
  559. margin-bottom: 20rpx;
  560. text-align: center;
  561. border-radius: 10rpx;
  562. line-height: 50rpx;
  563. overflow: hidden; //溢出隐藏
  564. white-space: nowrap; //禁止换行
  565. text-overflow: ellipsis; //...
  566. }
  567. .listbox_left_item_act {
  568. background-color: rgba(0, 176, 117, 0.2);
  569. color: #00b075;
  570. }
  571. }
  572. }
  573. .list {
  574. width: 70%;
  575. background-color: #fdfdfd;
  576. // margin-bottom: 100rpx;
  577. overflow-y: auto;
  578. .list_item {
  579. width: 100%;
  580. margin: 0 auto 20rpx;
  581. padding: 20rpx 20rpx;
  582. box-sizing: border-box;
  583. position: relative;
  584. background-color: #ffffff;
  585. box-shadow: 0 0 10rpx #bcb9ca;
  586. .list_item_top {
  587. display: flex;
  588. justify-content: space-between;
  589. .p1 {
  590. width: 87%;
  591. display: flex;
  592. justify-content: space-between;
  593. align-items: center;
  594. height: 60rpx;
  595. line-height: 60rpx;
  596. font-size: 28rpx;
  597. overflow: hidden;
  598. image {
  599. width: 40rpx;
  600. height: 40rpx;
  601. vertical-align: text-top;
  602. margin-right: 20rpx;
  603. }
  604. view {
  605. width: calc(100% - 40rpx);
  606. overflow: hidden;
  607. text-overflow: ellipsis;
  608. white-space: nowrap;
  609. }
  610. }
  611. .p2 {
  612. height: 60rpx;
  613. line-height: 60rpx;
  614. font-size: 28rpx;
  615. color: #42b983;
  616. }
  617. .p_out {
  618. height: 60rpx;
  619. line-height: 60rpx;
  620. font-size: 28rpx;
  621. color: red;
  622. }
  623. }
  624. .list_item_text {
  625. margin-top: 20rpx;
  626. p {
  627. font-size: 24rpx;
  628. color: #636363;
  629. margin-top: 10rpx;
  630. }
  631. p:first-child {
  632. font-size: 28rpx;
  633. font-weight: 700;
  634. }
  635. }
  636. .list_item_btn {
  637. width: 126rpx;
  638. color: #42b983;
  639. height: 40rpx;
  640. text-align: center;
  641. border: 1rpx solid #42b983;
  642. border-radius: 25rpx;
  643. font-size: 24rpx;
  644. line-height: 35rpx;
  645. position: absolute;
  646. bottom: 15rpx;
  647. right: 20rpx;
  648. }
  649. }
  650. }
  651. .top {
  652. position: fixed;
  653. right: 30px;
  654. bottom: 100px;
  655. z-index: 100;
  656. image {
  657. width: 100rpx;
  658. height: 100rpx;
  659. }
  660. }
  661. </style>