index.vue 13 KB

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