index.vue 16 KB

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