index.vue 18 KB

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