index.vue 13 KB

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