index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view>
  3. <view class="utabs_box" >
  4. <view class="search_bot_input" @click="clickRight">
  5. <input type="text" value="" placeholder="请输入设备ID" v-model="imports" @input="searchinput" disabled/>
  6. <u-icon name="search" size="36" class="icon" @click="search" color="#949494"></u-icon>
  7. </view>
  8. <view class="utabs">
  9. <u-tabs :list="list" :is-scroll="true" :current="current" @change="change" item-width="140" font-size="24" gutter="20"
  10. bar-width="60" active-color="#42b983"></u-tabs>
  11. </view>
  12. </view>
  13. <view class="list">
  14. <view class="list_item" v-for="(item,index) in eqlistdata" :key="index" @click="historys(item)">
  15. <view class="list_item_top">
  16. <p class="p1">
  17. <image :src="'http://static.yfpyx.com/bigdata_app'+imgpath[0].path" mode=""></image>
  18. {{item.device_name==''?"--":item.device_name}}
  19. </p>
  20. <p :class="[item.is_online?'p2':'p_out']">{{item.is_online?"在线":"离线"}}</p>
  21. </view>
  22. <view class="list_item_text">
  23. <p>设备ID:{{item.imei||item.device_id}}</p>
  24. <p>适配用户:{{item.real_name==''?"无":item.real_name}}</p>
  25. <p>添加设备时间:{{item.addtime|timeFormat()}}</p>
  26. <p>添加设备时间:{{item.uptime|timeFormat()}}</p>
  27. <p>设备已运行:{{item.days}}天</p>
  28. </view>
  29. <view class="list_item_btn" v-if="infoalter" @click.stop="modification(item)">
  30. 信息修改
  31. </view>
  32. </view>
  33. </view>
  34. <view class="top" v-if="isTop" @click="top">
  35. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. list: [],
  44. current: 0,
  45. currents:0,
  46. page: 1,
  47. size: 10,
  48. images: [{
  49. name: "杀虫灯",
  50. path: "/image/fourMoodBase/3.png", //
  51. id: 2
  52. },
  53. {
  54. name: "测报灯",
  55. path: "/image/fourMoodBase/1.png",
  56. id: 3
  57. }, {
  58. name: "性诱测报",
  59. path: "/image/fourMoodBase/6.png",
  60. id: 4
  61. }, {
  62. name: "环境监测",
  63. path: "/image/fourMoodBase/5.png",
  64. id: 5
  65. }, {
  66. name: "监控设备",
  67. path: "/image/fourMoodBase/2.png",
  68. id: 6
  69. }, {
  70. name: "孢子仪",
  71. path: "/image/fourMoodBase/4.png",
  72. id: 7
  73. },
  74. {
  75. name: "性诱2.0",
  76. path: "/image/fourMoodBase/10.png",
  77. id: 10
  78. }
  79. ],
  80. eqlistdata: [],
  81. isTop: false,
  82. infoalter: false, // 权限设置,
  83. type_id: 0, //设备类型,
  84. imgpath:[]
  85. }
  86. },
  87. methods: {
  88. async eqlist(tf) { //设备列表
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  91. data: {
  92. device_type_id: this.type_id,
  93. page: this.page,
  94. page_size: this.size,
  95. }
  96. })
  97. var newtime = +new Date() / 1000
  98. if(tf){
  99. this.eqlistdata = this.eqlistdata.concat(res.data)
  100. }else{
  101. this.eqlistdata = res.data
  102. }
  103. for (var i = 0; i < this.eqlistdata.length; i++) {
  104. var days = (newtime - this.eqlistdata[i].uptime) / 60 / 60 / 24
  105. this.eqlistdata[i].days = Math.round(days)
  106. }
  107. console.log(res)
  108. },
  109. async xyeqlist(tf) { //设备列表
  110. const res = await this.$myRequest({
  111. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  112. data: {
  113. device_type_id: this.type_id,
  114. page: this.page,
  115. page_size: this.size,
  116. }
  117. })
  118. var newtime = +new Date() / 1000
  119. if(tf){
  120. this.eqlistdata = this.eqlistdata.concat(res.data)
  121. }else{
  122. this.eqlistdata = res.data
  123. }
  124. for (var i = 0; i < this.eqlistdata.length; i++) {
  125. var days = (newtime - this.eqlistdata[i].uptime) / 60 / 60 / 24
  126. this.eqlistdata[i].days = Math.round(days)
  127. }
  128. console.log(res)
  129. },
  130. //camera.camera_manage.list_camera
  131. async camera() { //设备列表
  132. const res = await this.$myRequest({
  133. url: '/api/api_gateway?method=camera.camera_manage.list_camera',
  134. data: {
  135. page_size: 1,
  136. }
  137. })
  138. this.accessToken = res.accessToken
  139. },
  140. change(index) { //头部导航栏的点击
  141. this.current = index
  142. this.currents = index
  143. this.page = 1
  144. this.eqlistdata = []
  145. console.log(index)
  146. for (var i = 0; i < this.images.length; i++) {
  147. if (this.list[index].name == this.images[i].name) {
  148. this.type_id = this.images[i].id
  149. }
  150. }
  151. this.imgpath = this.images.filter((item)=>{
  152. return item.id == this.type_id
  153. })
  154. if (this.type_id == 10) {
  155. this.xyeqlist()
  156. } else {
  157. this.eqlist()
  158. }
  159. },
  160. clickRight() { //搜索
  161. uni.navigateTo({
  162. url: "./search?id=" + this.type_id
  163. })
  164. },
  165. modification(item) {
  166. uni.navigateTo({
  167. url: "./modification?data=" + JSON.stringify(item) + "&id=" + this.type_id,
  168. })
  169. },
  170. top() {
  171. uni.pageScrollTo({
  172. scrollTop: 0,
  173. duration: 500
  174. })
  175. },
  176. historys(item) {
  177. switch (this.type_id) {
  178. case 2:
  179. uni.navigateTo({
  180. url: "../prevention/equipmentdetails?shebei=" + JSON.stringify(item)
  181. })
  182. break;
  183. case 5:
  184. console.log(item)
  185. var obj = {}
  186. obj.d_id = item.d_id
  187. obj.equip_id = item.imei
  188. obj.is_online = item.is_online
  189. obj.lat = item.lat
  190. obj.lng = item.lng
  191. obj.equip_name = item.device_name
  192. obj.uptime = item.addtime
  193. uni.navigateTo({
  194. url: "../environment/equipment?shebei=" + JSON.stringify(obj)
  195. })
  196. break;
  197. case 6:
  198. uni.navigateTo({
  199. url: "/pages/webview?device_id=" + item.imei + "&accessToken=" + this.accessToken
  200. })
  201. break;
  202. case 3:
  203. item.type = this.type_id
  204. uni.navigateTo({
  205. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  206. })
  207. break;
  208. case 4:
  209. item.type = this.type_id
  210. uni.navigateTo({
  211. url: "../cb/equip-detail/equip-detail?info=" + JSON.stringify(item)
  212. })
  213. break;
  214. default:
  215. item.type = this.type_id
  216. uni.navigateTo({
  217. url: "../cb/xy2.0/particulars?info=" + JSON.stringify(item)
  218. })
  219. break;
  220. }
  221. }
  222. },
  223. onShow() {
  224. this.list=[]
  225. this.camera()
  226. this.current=0
  227. this.currents=0
  228. // console.log(this.current)
  229. uni.getStorage({
  230. key: "jurisdiction",
  231. success: (res) => {
  232. console.log(JSON.parse(res.data))
  233. let items = JSON.parse(res.data).filter((item) => {
  234. return item.purview_name == "设备管理"
  235. })
  236. let items2 = items[0].children.filter((item) => {
  237. return item.purview_name == "设备列表"
  238. })
  239. console.log(items2[0].children)
  240. this.infoalter = items2[0].children.some((item) => {
  241. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  242. })
  243. console.log(this.infoalter)
  244. var res = JSON.parse(res.data)
  245. for (var i = 0; i < res.length; i++) {
  246. switch (res[i].purview_name) {
  247. case "测报系统":
  248. for (var j = 0; j < res[i].children.length; j++) {
  249. var obj = {
  250. name: res[i].children[j].purview_name=="虫情测报灯"?"测报灯":res[i].children[j].purview_name
  251. }
  252. this.list.push(obj)
  253. }
  254. break;
  255. case "监控系统":
  256. for (var j = 0; j < res[i].children.length; j++) {
  257. var obj = {
  258. name: res[i].children[j].purview_name
  259. }
  260. this.list.push(obj)
  261. }
  262. break;
  263. case "环境监测系统":
  264. for (var j = 0; j < res[i].children.length; j++) {
  265. var obj = {
  266. name: res[i].children[j].purview_name
  267. }
  268. this.list.push(obj)
  269. }
  270. break;
  271. case "防治系统":
  272. for (var j = 0; j < res[i].children.length; j++) {
  273. var obj = {
  274. name: res[i].children[j].purview_name
  275. }
  276. this.list.push(obj)
  277. }
  278. break;
  279. }
  280. }
  281. for (var i = 0; i < this.images.length; i++) {
  282. if (this.list[this.current].name == this.images[i].name) {
  283. this.type_id = this.images[i].id
  284. }
  285. }
  286. this.imgpath = this.images.filter((item)=>{
  287. return item.id == this.type_id
  288. })
  289. if (this.type_id == 10) {
  290. this.xyeqlist(false)
  291. } else {
  292. this.eqlist(false)
  293. }
  294. },
  295. })
  296. },
  297. onReachBottom() {
  298. this.page++
  299. if (this.type_id == 10) {
  300. this.xyeqlist(true)
  301. } else {
  302. this.eqlist(true)
  303. }
  304. },
  305. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  306. if (e.scrollTop > 200) { //距离大于200时显示
  307. this.isTop = true
  308. } else { //距离小于200时隐藏
  309. this.isTop = false
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang="scss">
  315. /deep/.uni-icons {
  316. font-size: 40rpx !important;
  317. }
  318. .utabs_box {
  319. width: 100%;
  320. position: fixed;
  321. top: 0px;
  322. background-color: #FFFFFF;
  323. z-index: 100;
  324. .utabs {
  325. width: 95%;
  326. // margin: 64rpx auto;
  327. }
  328. .search_bot_input {
  329. width: 90%;
  330. height: 54rpx;
  331. background-color: #ebebeb;
  332. border-radius: 27rpx;
  333. box-sizing: border-box;
  334. padding-top: 8rpx;
  335. margin: 0 auto;
  336. position: relative;
  337. input {
  338. width: 100%;
  339. // text-indent: 1rem;
  340. font-size: 26rpx;
  341. padding-left: 40px;
  342. }
  343. .icon {
  344. position: absolute;
  345. top: 8rpx;
  346. left: 36rpx;
  347. }
  348. }
  349. }
  350. .list {
  351. width: 100%;
  352. background-color: #FDFDFD;
  353. margin-top: 160rpx;
  354. margin-bottom: 100rpx;
  355. .list_item {
  356. width: 90%;
  357. margin: 20rpx auto;
  358. padding: 20rpx 20rpx;
  359. box-sizing: border-box;
  360. position: relative;
  361. background-color: #FFFFFF;
  362. box-shadow: 0 0 10rpx #bcb9ca;
  363. .list_item_top {
  364. display: flex;
  365. justify-content: space-between;
  366. .p1 {
  367. height: 60rpx;
  368. line-height: 60rpx;
  369. font-size: 28rpx;
  370. image {
  371. width: 40rpx;
  372. height: 40rpx;
  373. vertical-align: text-top;
  374. margin-right: 20rpx;
  375. }
  376. }
  377. .p2 {
  378. height: 60rpx;
  379. line-height: 60rpx;
  380. font-size: 28rpx;
  381. color: #42b983;
  382. }
  383. .p_out {
  384. height: 60rpx;
  385. line-height: 60rpx;
  386. font-size: 28rpx;
  387. color: red;
  388. }
  389. }
  390. .list_item_text {
  391. margin-top: 20rpx;
  392. p {
  393. font-size: 24rpx;
  394. color: #636363;
  395. margin-top: 10rpx;
  396. }
  397. p:first-child {
  398. font-size: 28rpx;
  399. font-weight: 700;
  400. }
  401. }
  402. .list_item_btn {
  403. width: 126rpx;
  404. color: #42b983;
  405. height: 40rpx;
  406. text-align: center;
  407. border: 1rpx solid #42b983;
  408. border-radius: 25rpx;
  409. font-size: 24rpx;
  410. line-height: 35rpx;
  411. position: absolute;
  412. top: 136rpx;
  413. right: 20rpx;
  414. }
  415. }
  416. }
  417. .top {
  418. position: fixed;
  419. right: 30px;
  420. bottom: 100px;
  421. z-index: 100;
  422. image {
  423. width: 100rpx;
  424. height: 100rpx;
  425. }
  426. }
  427. </style>