index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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 12:
  280. console.log(item);
  281. uni.navigateTo({
  282. url: "../cb/xctdetail/xctdetail?info=" + JSON.stringify(item),
  283. });
  284. break;
  285. case 13:
  286. console.log(item)
  287. var obj = {}
  288. obj.d_id = item.d_id
  289. obj.device_id = item.imei
  290. obj.is_online = item.is_online
  291. obj.lat = item.lat
  292. obj.lng = item.lng
  293. obj.equip_name = item.device_name
  294. obj.uptime = item.addtime
  295. uni.navigateTo({
  296. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj)
  297. })
  298. break;
  299. case 15:
  300. console.log(item)
  301. var obj = {}
  302. obj.d_id = item.d_id
  303. obj.device_id = item.imei
  304. obj.is_online = item.is_online
  305. obj.lat = item.lat
  306. obj.lng = item.lng
  307. obj.equip_name = item.device_name
  308. obj.uptime = item.addtime
  309. uni.navigateTo({
  310. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj)
  311. })
  312. break;
  313. case 11:
  314. var obj = {};
  315. obj.d_id = item.d_id;
  316. obj.device_id = item.imei;
  317. obj.is_online = item.is_online;
  318. obj.lat = item.lat;
  319. obj.lng = item.lng;
  320. obj.equip_name = item.device_name;
  321. obj.uptime = item.addtime;
  322. obj.location = item.address;
  323. obj.type = 11;
  324. uni.navigateTo({
  325. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  326. });
  327. break;
  328. case 19:
  329. var obj = {};
  330. obj.d_id = item.d_id;
  331. obj.device_id = item.imei;
  332. obj.is_online = item.is_online;
  333. obj.lat = item.lat;
  334. obj.lng = item.lng;
  335. obj.equip_name = item.device_name;
  336. obj.uptime = item.addtime;
  337. obj.location = item.address;
  338. obj.type = 19;
  339. uni.navigateTo({
  340. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  341. });
  342. break;
  343. case 20:
  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. obj.location = item.address;
  353. obj.type = 20;
  354. uni.navigateTo({
  355. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  356. });
  357. break;
  358. case 21:
  359. var obj = {};
  360. obj.d_id = item.d_id;
  361. obj.device_id = item.imei;
  362. obj.is_online = item.is_online;
  363. obj.lat = item.lat;
  364. obj.lng = item.lng;
  365. obj.equip_name = item.device_name;
  366. obj.uptime = item.addtime;
  367. obj.location = item.address;
  368. obj.type = 20;
  369. uni.navigateTo({
  370. url: "../disease/cmb?shebei=" + JSON.stringify(obj),
  371. });
  372. break;
  373. case 17:
  374. break;
  375. case 18:
  376. var obj = {};
  377. obj.device_id = item.imei;
  378. obj.is_online = item.is_online;
  379. uni.navigateTo({
  380. url: "../cb/shuifeiL/shuifeiL?detail=" + JSON.stringify(obj),
  381. });
  382. break;
  383. default:
  384. item.type = this.type_id
  385. uni.navigateTo({
  386. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  387. })
  388. break;
  389. }
  390. },
  391. search() { //搜索
  392. this.eqlistdata = []
  393. this.page = 1
  394. if (this.list[this.currents].id == 10) {
  395. this.xyeqlist()
  396. } else {
  397. this.eqlist()
  398. }
  399. },
  400. searchinput() {
  401. Debounce(() => {
  402. this.eqlistdata = []
  403. this.page = 1
  404. if (this.list[this.currents].id == 10) {
  405. this.xyeqlist()
  406. } else {
  407. this.eqlist()
  408. }
  409. }, 1000)()
  410. },
  411. scrollTop(e) {
  412. console.log(e)
  413. },
  414. upper() {
  415. },
  416. lower() {
  417. console.log(11)
  418. this.page++
  419. if (this.type_id == 10) {
  420. this.xyeqlist(true)
  421. } else {
  422. this.eqlist(true)
  423. }
  424. },
  425. scroll() {
  426. },
  427. },
  428. onLoad() {
  429. this.list = []
  430. this.camera()
  431. this.current = 0
  432. this.currents = 0
  433. this.page = 1
  434. this.usertype()
  435. this.width = 0
  436. uni.getStorage({
  437. key: "jurisdiction",
  438. success: (res) => {
  439. console.log(JSON.parse(res.data));
  440. let items = JSON.parse(res.data).filter((item) => {
  441. return item.pur_id == 22 //"设备管理";
  442. });
  443. let items2 = items[0].children.filter((item) => {
  444. return item.pur_id == 23 //"设备列表";
  445. });
  446. console.log(items2[0].children);
  447. this.infoalter = items2[0].children.some((item) => {
  448. return (
  449. item.pur_id == 108 || item.pur_id == 109
  450. );
  451. });
  452. console.log(this.infoalter);
  453. },
  454. });
  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) { //nvue暂不支持滚动监听,可用bindingx代替
  465. if (e.scrollTop > 200) { //距离大于200时显示
  466. this.isTop = true
  467. } else { //距离小于200时隐藏
  468. this.isTop = false
  469. }
  470. }
  471. }
  472. </script>
  473. <style lang="scss">
  474. page {
  475. background-color: #00B075;
  476. }
  477. /deep/.uni-icons {
  478. font-size: 40rpx !important;
  479. }
  480. .textbox {
  481. width: 100%;
  482. padding: 20rpx 30rpx;
  483. box-sizing: border-box;
  484. border-top-left-radius: 80rpx;
  485. border-top-right-radius: 80rpx;
  486. margin-top: 30rpx;
  487. background-color: #F9F9F9;
  488. }
  489. .inputs {
  490. /deep/.u-content {
  491. background-color: #fff !important;
  492. }
  493. /deep/.uni-input-wrapper {
  494. background-color: #fff !important;
  495. }
  496. /deep/.u-input {
  497. background-color: #fff !important;
  498. }
  499. }
  500. .utabs_box {
  501. width: 100%;
  502. position: fixed;
  503. top: 88px;
  504. background-color: #FFFFFF;
  505. z-index: 100;
  506. .utabs {
  507. width: 95%;
  508. margin: 0 auto;
  509. }
  510. }
  511. .loading {
  512. position: fixed;
  513. top: 440px;
  514. width: 95%;
  515. left: 2.5%;
  516. text-align: center;
  517. .img {
  518. width: 300rpx;
  519. height: 40rpx;
  520. }
  521. }
  522. .listbox {
  523. display: flex;
  524. justify-content: space-around;
  525. height: calc(100vh - 77px);
  526. margin-top: 20rpx;
  527. .listbox_left {
  528. background-color: #fff;
  529. padding: 20rpx;
  530. width: 140rpx;
  531. overflow: auto;
  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. width: 87%;
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. height: 60rpx;
  571. line-height: 60rpx;
  572. font-size: 28rpx;
  573. overflow: hidden;
  574. image {
  575. width: 40rpx;
  576. height: 40rpx;
  577. vertical-align: text-top;
  578. margin-right: 20rpx;
  579. }
  580. view {
  581. width: calc(100% - 40rpx);
  582. overflow: hidden;
  583. text-overflow: ellipsis;
  584. white-space: nowrap;
  585. }
  586. }
  587. .p2 {
  588. height: 60rpx;
  589. line-height: 60rpx;
  590. font-size: 28rpx;
  591. color: #42b983;
  592. }
  593. .p_out {
  594. height: 60rpx;
  595. line-height: 60rpx;
  596. font-size: 28rpx;
  597. color: red;
  598. }
  599. }
  600. .list_item_text {
  601. margin-top: 20rpx;
  602. p {
  603. font-size: 24rpx;
  604. color: #636363;
  605. margin-top: 10rpx;
  606. }
  607. p:first-child {
  608. font-size: 28rpx;
  609. font-weight: 700;
  610. }
  611. }
  612. .list_item_btn {
  613. width: 126rpx;
  614. color: #42b983;
  615. height: 40rpx;
  616. text-align: center;
  617. border: 1rpx solid #42b983;
  618. border-radius: 25rpx;
  619. font-size: 24rpx;
  620. line-height: 35rpx;
  621. position: absolute;
  622. bottom: 15rpx;
  623. right: 20rpx;
  624. }
  625. }
  626. }
  627. .top {
  628. position: fixed;
  629. right: 30px;
  630. bottom: 100px;
  631. z-index: 100;
  632. image {
  633. width: 100rpx;
  634. height: 100rpx;
  635. }
  636. }
  637. </style>