index.vue 17 KB

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