index.vue 19 KB

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