index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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">
  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="infoalter" @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(res[i].type_name == "性诱3.0" ||
  157. res[i].type_name == "吸虫塔" ||
  158. res[i].type_name == "病虫害可视监测" ||
  159. res[i].type_name == "小麦赤霉病" ||
  160. res[i].type_name == "温室大棚"
  161. ){
  162. continue;
  163. }
  164. var obj = {
  165. name: res[i].type_name,
  166. id: res[i].id
  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. if (this.list[index].id == 10) {
  188. this.xyeqlist()
  189. } else {
  190. this.eqlist()
  191. }
  192. },
  193. clickRight() { //搜索
  194. this.width = '90%'
  195. },
  196. modification(item) {
  197. uni.navigateTo({
  198. url: "./modification?data=" + JSON.stringify(item) + "&id=" + this.type_id,
  199. })
  200. },
  201. top() {
  202. uni.pageScrollTo({
  203. scrollTop: 0,
  204. duration: 500
  205. })
  206. },
  207. historys(item) {
  208. switch (this.type_id) {
  209. case 2:
  210. uni.navigateTo({
  211. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  212. })
  213. break;
  214. case 5:
  215. console.log(item)
  216. var obj = {}
  217. obj.d_id = item.d_id
  218. obj.equip_id = item.imei
  219. obj.is_online = item.is_online
  220. obj.lat = item.lat
  221. obj.lng = item.lng
  222. obj.equip_name = item.device_name
  223. obj.uptime = item.addtime
  224. uni.navigateTo({
  225. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  226. })
  227. break;
  228. case 6:
  229. uni.navigateTo({
  230. url: "/pages/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  231. })
  232. break;
  233. case 3:
  234. item.type = this.type_id
  235. uni.navigateTo({
  236. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  237. })
  238. break;
  239. case 4:
  240. item.type = this.type_id
  241. uni.navigateTo({
  242. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  243. })
  244. break;
  245. case 7:
  246. item.type = this.type_id
  247. uni.navigateTo({
  248. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  249. })
  250. break;
  251. case 13:
  252. console.log(item)
  253. var obj = {}
  254. obj.d_id = item.d_id
  255. obj.device_id = item.imei
  256. obj.is_online = item.is_online
  257. obj.lat = item.lat
  258. obj.lng = item.lng
  259. obj.equip_name = item.device_name
  260. obj.uptime = item.addtime
  261. uni.navigateTo({
  262. url: "../waterandfer/datails?shebei=" + JSON.stringify(obj)
  263. })
  264. break;
  265. case 15:
  266. console.log(item)
  267. var obj = {}
  268. obj.d_id = item.d_id
  269. obj.device_id = item.imei
  270. obj.is_online = item.is_online
  271. obj.lat = item.lat
  272. obj.lng = item.lng
  273. obj.equip_name = item.device_name
  274. obj.uptime = item.addtime
  275. uni.navigateTo({
  276. url: "../environment/gsequipment?shebei=" + JSON.stringify(obj)
  277. })
  278. break;
  279. case 17:
  280. break;
  281. case 18:
  282. break;
  283. default:
  284. item.type = this.type_id
  285. uni.navigateTo({
  286. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  287. })
  288. break;
  289. }
  290. },
  291. search() { //搜索
  292. this.eqlistdata = []
  293. this.page = 1
  294. if (this.list[this.currents].id == 10) {
  295. this.xyeqlist()
  296. } else {
  297. this.eqlist()
  298. }
  299. },
  300. searchinput() {
  301. Debounce(() => {
  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. }, 1000)()
  310. },
  311. scrollTop(e) {
  312. console.log(e)
  313. },
  314. upper(){
  315. },
  316. lower(){
  317. console.log(11)
  318. this.page++
  319. if (this.type_id == 10) {
  320. this.xyeqlist(true)
  321. } else {
  322. this.eqlist(true)
  323. }
  324. },
  325. scroll(){
  326. },
  327. },
  328. onShow() {
  329. this.list = []
  330. this.camera()
  331. this.current = 0
  332. this.currents = 0
  333. this.page = 1
  334. this.usertype()
  335. this.width = 0
  336. uni.getStorage({
  337. key: "jurisdiction",
  338. success: (res) => {
  339. console.log(JSON.parse(res.data))
  340. let items = JSON.parse(res.data).filter((item) => {
  341. return item.purview_name == "设备管理"
  342. })
  343. let items2 = items[0].children.filter((item) => {
  344. return item.purview_name == "设备列表"
  345. })
  346. console.log(items2[0].children)
  347. this.infoalter = items2[0].children.some((item) => {
  348. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  349. })
  350. console.log(this.infoalter)
  351. },
  352. })
  353. },
  354. onReachBottom() {
  355. this.page++
  356. if (this.type_id == 10) {
  357. this.xyeqlist(true)
  358. } else {
  359. this.eqlist(true)
  360. }
  361. },
  362. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  363. if (e.scrollTop > 200) { //距离大于200时显示
  364. this.isTop = true
  365. } else { //距离小于200时隐藏
  366. this.isTop = false
  367. }
  368. }
  369. }
  370. </script>
  371. <style lang="scss">
  372. page {
  373. background-color: #00B075;
  374. }
  375. /deep/.uni-icons {
  376. font-size: 40rpx !important;
  377. }
  378. .textbox {
  379. width: 100%;
  380. padding: 20rpx 30rpx;
  381. box-sizing: border-box;
  382. border-top-left-radius: 80rpx;
  383. border-top-right-radius: 80rpx;
  384. margin-top: 30rpx;
  385. background-color: #F9F9F9;
  386. }
  387. .inputs {
  388. /deep/.u-content {
  389. background-color: #fff !important;
  390. }
  391. /deep/.uni-input-wrapper {
  392. background-color: #fff !important;
  393. }
  394. /deep/.u-input{
  395. background-color: #fff !important;
  396. }
  397. }
  398. .utabs_box {
  399. width: 100%;
  400. position: fixed;
  401. top: 88px;
  402. background-color: #FFFFFF;
  403. z-index: 100;
  404. .utabs {
  405. width: 95%;
  406. margin: 0 auto;
  407. }
  408. }
  409. .loading {
  410. position: fixed;
  411. top: 440px;
  412. width: 95%;
  413. left: 2.5%;
  414. text-align: center;
  415. .img {
  416. width: 300rpx;
  417. height: 40rpx;
  418. }
  419. }
  420. .listbox {
  421. display: flex;
  422. justify-content: space-around;
  423. height: calc(100vh - 77px);
  424. margin-top: 20rpx;
  425. .listbox_left {
  426. background-color: #fff;
  427. padding: 20rpx;
  428. width: 140rpx;
  429. overflow-x: auto;
  430. .listbox_left_item {
  431. height: 50rpx;
  432. width: 100%;
  433. margin-bottom: 20rpx;
  434. text-align: center;
  435. border-radius: 10rpx;
  436. line-height: 50rpx;
  437. overflow: hidden;//溢出隐藏
  438. white-space: nowrap;//禁止换行
  439. text-overflow: ellipsis;//...
  440. }
  441. .listbox_left_item_act {
  442. background-color: rgba(0, 176, 117, 0.2);
  443. color: #00B075;
  444. }
  445. }
  446. }
  447. .list {
  448. width: 70%;
  449. background-color: #FDFDFD;
  450. // margin-bottom: 100rpx;
  451. overflow-y: auto;
  452. .list_item {
  453. width: 100%;
  454. margin: 0 auto 20rpx;
  455. padding: 20rpx 20rpx;
  456. box-sizing: border-box;
  457. position: relative;
  458. background-color: #FFFFFF;
  459. box-shadow: 0 0 10rpx #bcb9ca;
  460. .list_item_top {
  461. display: flex;
  462. justify-content: space-between;
  463. .p1 {
  464. height: 60rpx;
  465. line-height: 60rpx;
  466. font-size: 28rpx;
  467. image {
  468. width: 40rpx;
  469. height: 40rpx;
  470. vertical-align: text-top;
  471. margin-right: 20rpx;
  472. }
  473. }
  474. .p2 {
  475. height: 60rpx;
  476. line-height: 60rpx;
  477. font-size: 28rpx;
  478. color: #42b983;
  479. }
  480. .p_out {
  481. height: 60rpx;
  482. line-height: 60rpx;
  483. font-size: 28rpx;
  484. color: red;
  485. }
  486. }
  487. .list_item_text {
  488. margin-top: 20rpx;
  489. p {
  490. font-size: 24rpx;
  491. color: #636363;
  492. margin-top: 10rpx;
  493. }
  494. p:first-child {
  495. font-size: 28rpx;
  496. font-weight: 700;
  497. }
  498. }
  499. .list_item_btn {
  500. width: 126rpx;
  501. color: #42b983;
  502. height: 40rpx;
  503. text-align: center;
  504. border: 1rpx solid #42b983;
  505. border-radius: 25rpx;
  506. font-size: 24rpx;
  507. line-height: 35rpx;
  508. position: absolute;
  509. bottom: 15rpx;
  510. right: 20rpx;
  511. }
  512. }
  513. }
  514. .top {
  515. position: fixed;
  516. right: 30px;
  517. bottom: 100px;
  518. z-index: 100;
  519. image {
  520. width: 100rpx;
  521. height: 100rpx;
  522. }
  523. }
  524. </style>