index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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. uni.navigateTo({
  371. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  372. });
  373. break;
  374. case 19:
  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. uni.navigateTo({
  385. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  386. });
  387. break;
  388. case 20:
  389. var obj = {};
  390. obj.d_id = item.d_id;
  391. obj.device_id = item.imei;
  392. obj.is_online = item.is_online;
  393. obj.lat = item.lat;
  394. obj.lng = item.lng;
  395. obj.equip_name = item.device_name;
  396. obj.uptime = item.addtime;
  397. obj.location = item.address;
  398. uni.navigateTo({
  399. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  400. });
  401. break;
  402. default:
  403. item.type = this.type_id;
  404. uni.navigateTo({
  405. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item),
  406. });
  407. break;
  408. }
  409. },
  410. search() {
  411. //搜索
  412. this.eqlistdata = [];
  413. this.page = 1;
  414. if (this.list[this.currents].id == 10) {
  415. this.xyeqlist();
  416. } else {
  417. this.eqlist();
  418. }
  419. },
  420. searchinput() {
  421. Debounce(() => {
  422. this.eqlistdata = [];
  423. this.page = 1;
  424. if (this.list[this.currents].id == 10) {
  425. this.xyeqlist();
  426. } else {
  427. this.eqlist();
  428. }
  429. }, 1000)();
  430. },
  431. scrollTop(e) {
  432. console.log(e);
  433. },
  434. upper() {},
  435. lower() {
  436. console.log(11);
  437. this.page++;
  438. if (this.type_id == 10) {
  439. this.xyeqlist(true);
  440. } else {
  441. this.eqlist(true);
  442. }
  443. },
  444. scroll() {},
  445. },
  446. onLoad() {
  447. console.log('onload equiplist --------------------------1')
  448. this.list = [];
  449. this.camera();
  450. this.current = 0;
  451. this.currents = 0;
  452. this.page = 1;
  453. this.usertype();
  454. this.width = 0;
  455. },
  456. onReachBottom() {
  457. this.page++;
  458. if (this.type_id == 10) {
  459. this.xyeqlist(true);
  460. } else {
  461. this.eqlist(true);
  462. }
  463. },
  464. onPageScroll(e) {
  465. //nvue暂不支持滚动监听,可用bindingx代替
  466. if (e.scrollTop > 200) {
  467. //距离大于200时显示
  468. this.isTop = true;
  469. } else {
  470. //距离小于200时隐藏
  471. this.isTop = false;
  472. }
  473. },
  474. };
  475. </script>
  476. <style lang="scss">
  477. page {
  478. background-color: #00b075;
  479. }
  480. /deep/.uni-icons {
  481. font-size: 40rpx !important;
  482. }
  483. .textbox {
  484. width: 100%;
  485. height: 100vh;
  486. padding: 20rpx 30rpx;
  487. box-sizing: border-box;
  488. border-top-left-radius: 80rpx;
  489. border-top-right-radius: 80rpx;
  490. margin-top: 30rpx;
  491. background-color: #f9f9f9;
  492. }
  493. .inputs {
  494. /deep/.u-content {
  495. background-color: #fff !important;
  496. }
  497. /deep/.uni-input-wrapper {
  498. background-color: #fff !important;
  499. }
  500. }
  501. .utabs_box {
  502. width: 100%;
  503. position: fixed;
  504. top: 88px;
  505. background-color: #ffffff;
  506. z-index: 100;
  507. .utabs {
  508. width: 95%;
  509. margin: 0 auto;
  510. }
  511. }
  512. .loading {
  513. position: fixed;
  514. top: 440px;
  515. width: 95%;
  516. left: 2.5%;
  517. text-align: center;
  518. .img {
  519. width: 300rpx;
  520. height: 40rpx;
  521. }
  522. }
  523. .listbox {
  524. display: flex;
  525. justify-content: space-around;
  526. height: calc(100vh - 84px);
  527. margin-top: 20rpx;
  528. .listbox_left {
  529. background-color: #fff;
  530. padding: 20rpx;
  531. width: 140rpx;
  532. .listbox_left_item {
  533. height: 50rpx;
  534. width: 100%;
  535. margin-bottom: 20rpx;
  536. text-align: center;
  537. border-radius: 10rpx;
  538. line-height: 50rpx;
  539. overflow: hidden; //溢出隐藏
  540. white-space: nowrap; //禁止换行
  541. text-overflow: ellipsis; //...
  542. }
  543. .listbox_left_item_act {
  544. background-color: rgba(0, 176, 117, 0.2);
  545. color: #00b075;
  546. }
  547. }
  548. }
  549. .list {
  550. width: 70%;
  551. background-color: #fdfdfd;
  552. // margin-bottom: 100rpx;
  553. overflow-y: auto;
  554. .list_item {
  555. width: 100%;
  556. margin: 0 auto 20rpx;
  557. padding: 20rpx 20rpx;
  558. box-sizing: border-box;
  559. position: relative;
  560. background-color: #ffffff;
  561. box-shadow: 0 0 10rpx #bcb9ca;
  562. .list_item_top {
  563. display: flex;
  564. justify-content: space-between;
  565. .p1 {
  566. height: 60rpx;
  567. line-height: 60rpx;
  568. font-size: 28rpx;
  569. image {
  570. width: 40rpx;
  571. height: 40rpx;
  572. vertical-align: text-top;
  573. margin-right: 20rpx;
  574. }
  575. }
  576. .p2 {
  577. height: 60rpx;
  578. line-height: 60rpx;
  579. font-size: 28rpx;
  580. color: #42b983;
  581. }
  582. .p_out {
  583. height: 60rpx;
  584. line-height: 60rpx;
  585. font-size: 28rpx;
  586. color: red;
  587. }
  588. }
  589. .list_item_text {
  590. margin-top: 20rpx;
  591. p {
  592. font-size: 24rpx;
  593. color: #636363;
  594. margin-top: 10rpx;
  595. }
  596. p:first-child {
  597. font-size: 28rpx;
  598. font-weight: 700;
  599. }
  600. }
  601. .list_item_btn {
  602. width: 126rpx;
  603. color: #42b983;
  604. height: 40rpx;
  605. text-align: center;
  606. border: 1rpx solid #42b983;
  607. border-radius: 25rpx;
  608. font-size: 24rpx;
  609. line-height: 35rpx;
  610. position: absolute;
  611. bottom: 15rpx;
  612. right: 20rpx;
  613. }
  614. }
  615. }
  616. .top {
  617. position: fixed;
  618. right: 30px;
  619. bottom: 100px;
  620. z-index: 100;
  621. image {
  622. width: 100rpx;
  623. height: 100rpx;
  624. }
  625. }
  626. </style>