index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft" left-icon="back" left-text="返回" right-icon="search"
  7. title="测报系统"></uni-nav-bar>
  8. <view class="inputs" :style="{'width':width+'rpx'}">
  9. <input type="text" value="" placeholder="请输入设备ID或设备名称" v-model="imports" @input="searchinp"
  10. class="inputbox" :clearable="false" />
  11. <u-icon name="search" size="40" class="icon" @click="search"></u-icon>
  12. </view>
  13. <view>
  14. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/banner.jpg'" mode="widthFix"></image>
  15. </view>
  16. <view class="tab-box">
  17. <view v-for="(item,index) in equipArr" :key="item.type" v-if="item.tf" @click="tabClick(index)" :class="['tab-item',active==index?'active':'']">
  18. <text>{{item.name}}</text>
  19. <text class="bottom-line"></text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="loading" v-if="loadingtf">
  24. <image src="../../../static/images/ajax-loader.gif" mode="" class="img"></image>
  25. </view>
  26. <view class="" style="position: absolute;top: 180px;width: 100%;">
  27. <view class="content">
  28. <template v-for="(item,index) in equipArr[active].list">
  29. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
  30. <view class="date">
  31. <p>设备ID:{{item.imei || item.device_id}}</p>
  32. <p>最新上报时间:{{item.addtime|timeFormat}}</p>
  33. </view>
  34. </equipItem>
  35. </template>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="top">
  40. <view class="backtop" @click="top" v-if="isTop">
  41. <image src="../../../static/images/1.png" mode="" class="img0"></image>
  42. </view>
  43. <view class="more">
  44. <view class="box" @click="online" v-show="filtrateTF">
  45. <p>在线</p>
  46. </view>
  47. <view class="box" @click="offline" v-show="filtrateTF">
  48. <p>离线</p>
  49. </view>
  50. <view class="box" @click="complete" v-show="filtrateTF">
  51. <p>全部</p>
  52. </view>
  53. <view @click="filtrate">
  54. <image src="../../../static/images/b0bcdb0e3fe8690520f743aa8303bf2.png" mode="" class="img1"></image>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {Debounce} from "../../../util/anitthro.js"
  62. import equipItem from "../../../components/equip-item/equip-item"
  63. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  64. export default {
  65. data() {
  66. return {
  67. active: 0, //默认选中虫情测报
  68. equipArr: [{
  69. name: '虫情测报',
  70. type: 3, //3虫情测报灯 7孢子仪 4智能性诱
  71. list: [],
  72. pageIndex: 1,
  73. tf:false,
  74. }, {
  75. name: '孢子仪',
  76. type: 7, //3虫情测报灯 7孢子仪 4智能性诱
  77. list: [],
  78. pageIndex: 1,
  79. tf:false,
  80. }, {
  81. name: '性诱测报',
  82. type: 4, //3虫情测报灯 7孢子仪 4智能性诱
  83. list: [],
  84. pageIndex: 1,
  85. tf:false,
  86. },
  87. {
  88. name: '性诱2.0',
  89. type: 10, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
  90. list: [],
  91. pageIndex: 1,
  92. tf:false
  93. }
  94. ],
  95. device_id: '3', //筛选的设备id
  96. isTop: false,
  97. filtrateTF:false,
  98. device_status:"",
  99. width:0,//顶部搜索栏宽度
  100. imports:"",//搜索id
  101. loadingtf:false,//loading
  102. }
  103. },
  104. onLoad() {
  105. uni.getStorage({
  106. key:"jurisdiction",
  107. success:(res)=>{
  108. let items = JSON.parse(res.data).filter((item)=>{
  109. return item.purview_name == "测报系统"
  110. })
  111. var arr = items[0].children
  112. for(var i =0;i<arr.length;i++){
  113. switch (arr[i].purview_name){
  114. case "虫情测报灯":
  115. this.equipArr[0].tf = true
  116. this.getEquipList(0)
  117. break
  118. case "性诱测报":
  119. this.equipArr[2].tf = true
  120. this.getEquipList(2)
  121. break
  122. case "孢子仪":
  123. this.equipArr[1].tf = true
  124. this.getEquipList(1)
  125. break
  126. case "性诱2.0":
  127. this.equipArr[3].tf = true
  128. this.getxyEquipList(3)
  129. break
  130. }
  131. }
  132. }
  133. })
  134. },
  135. onShow() {
  136. },
  137. onHide() {
  138. },
  139. onUnload() {
  140. },
  141. onPullDownRefresh() {
  142. this.equipArr[this.active].pageIndex = 1
  143. this.equipArr[this.active].list = []
  144. if(this.active==3){
  145. this.getxyEquipList(3)
  146. }else{
  147. this.getEquipList(this.active)
  148. }
  149. setTimeout(() => {
  150. uni.stopPullDownRefresh()
  151. }, 1000)
  152. },
  153. onReachBottom() {
  154. let act = this.active
  155. if (this.equipArr[act].list.length < this.equipArr[act].pageIndex * 10) { //判断是否数据请求完
  156. return false
  157. }
  158. this.equipArr[act].pageIndex++;
  159. if(this.active==3){
  160. this.getxyEquipList(3)
  161. }else{
  162. this.getEquipList(act)
  163. }
  164. },
  165. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  166. if (e.scrollTop > 200) { //距离大于200时显示
  167. this.isTop = true
  168. } else { //距离小于200时隐藏
  169. this.isTop = false
  170. }
  171. },
  172. onBackPress(options) {
  173. if (options.from === 'navigateBack') {
  174. return false;
  175. }
  176. this.clickLeft();
  177. return true;
  178. },
  179. methods: {
  180. async getEquipList(act) {
  181. this.loadingtf =true
  182. const res = await this.$myRequest({
  183. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  184. data: {
  185. device_type_id: this.equipArr[act].type,
  186. page: this.equipArr[act].pageIndex,
  187. page_size: 10,
  188. device_status:this.device_status,
  189. device_id: this.imports,
  190. }
  191. })
  192. this.loadingtf =false
  193. console.log(res)
  194. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  195. console.log(this.equipArr[act].list)
  196. },
  197. async getxyEquipList(act) {
  198. this.loadingtf =true
  199. const res = await this.$myRequest({
  200. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  201. data: {
  202. device_type_id: this.equipArr[act].type,
  203. page: this.equipArr[act].pageIndex,
  204. page_size: 10,
  205. device_status:this.device_status,
  206. device_id: this.imports,
  207. }
  208. })
  209. this.loadingtf =false
  210. console.log(res)
  211. this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
  212. console.log(this.equipArr[act].list)
  213. },
  214. tabClick(index) {
  215. this.width = 0
  216. this.imports = ""
  217. this.active = index;
  218. this.device_id = this.equipArr[index].type
  219. },
  220. clickRight() {
  221. this.width=600
  222. },
  223. itemClick(item) {
  224. item.type = this.equipArr[this.active].type
  225. let data = JSON.stringify(item)
  226. if (item.type == 10) {
  227. uni.navigateTo({
  228. url: '/pages/cb/xy2.0/particulars?info=' + data
  229. });
  230. } else {
  231. uni.navigateTo({
  232. url: '/pages/cb/equip-detail/equip-detail?info=' + data
  233. });
  234. }
  235. },
  236. clickLeft() {
  237. uni.switchTab({
  238. url: "../../index/index"
  239. })
  240. },
  241. filtrate(){
  242. this.filtrateTF = !this.filtrateTF
  243. },
  244. top() {
  245. uni.pageScrollTo({
  246. scrollTop: 0,
  247. duration: 500
  248. })
  249. },
  250. online(){
  251. this.equipArr[this.active].pageIndex=1
  252. this.equipArr[this.active].list =[]
  253. this.device_status = 1
  254. if(this.active==3){
  255. this.getxyEquipList(3)
  256. }else{
  257. this.getEquipList(this.active)
  258. }
  259. this.filtrateTF = !this.filtrateTF
  260. },
  261. offline(){
  262. this.equipArr[this.active].pageIndex=1
  263. this.equipArr[this.active].list =[]
  264. this.device_status = 0
  265. if(this.active==3){
  266. this.getxyEquipList(3)
  267. }else{
  268. this.getEquipList(this.active)
  269. }
  270. this.filtrateTF = !this.filtrateTF
  271. },
  272. complete(){
  273. this.equipArr[this.active].pageIndex=1
  274. this.equipArr[this.active].list =[]
  275. this.device_status = ""
  276. if(this.active==3){
  277. this.getxyEquipList(3)
  278. }else{
  279. this.getEquipList(this.active)
  280. }
  281. this.filtrateTF = !this.filtrateTF
  282. },
  283. search() {//搜索按钮搜索
  284. if(this.active==3){
  285. this.equipArr[this.active].list =[]
  286. this.getxyEquipList(3)
  287. }else{
  288. this.equipArr[this.active].list=[]
  289. this.getEquipList(this.active)
  290. }
  291. },
  292. searchinp() {//自动搜索
  293. Debounce(() => {
  294. if(this.active==3){
  295. this.equipArr[this.active].list=[]
  296. this.getxyEquipList(3)
  297. }else{
  298. this.equipArr[this.active].list=[]
  299. this.getEquipList(this.active)
  300. }
  301. }, 1000)()
  302. },
  303. },
  304. components: {
  305. equipItem,
  306. uniNavBar
  307. }
  308. }
  309. </script>
  310. <style lang="scss">
  311. page {
  312. background: $uni-bg-color-grey;
  313. .content {
  314. padding: 0 20rpx 20rpx 20rpx;
  315. box-sizing: border-box;
  316. }
  317. }
  318. image {
  319. width: 100%;
  320. }
  321. .inputs{
  322. height: 54rpx;
  323. background-color: #E4E4E4;
  324. border-radius: 27rpx;
  325. position: absolute;
  326. right: 20rpx;
  327. top: 20rpx;
  328. transition: width 0.5s;
  329. overflow: hidden;
  330. padding-top: 8rpx;
  331. box-sizing: border-box;
  332. .inputbox {
  333. width: 85%;
  334. text-indent: 1rem;
  335. font-size: 26rpx;
  336. }
  337. .icon {
  338. position: absolute;
  339. top: 8rpx;
  340. right: 26rpx;
  341. }
  342. }
  343. .loading{
  344. position: fixed;
  345. top: 440px;
  346. width: 95%;
  347. left: 2.5%;
  348. text-align: center;
  349. .img{
  350. width: 300rpx;
  351. height: 40rpx;
  352. }
  353. }
  354. .tab-box {
  355. display: flex;
  356. justify-content: space-around;
  357. font-size: 30rpx;
  358. line-height: 80rpx;
  359. background-color: #FFFFFF;
  360. margin-top: -10rpx;
  361. .tab-item {
  362. cursor: pointer;
  363. position: relative;
  364. }
  365. ;
  366. .tab-item.active {
  367. .bottom-line {
  368. bottom: 0;
  369. position: absolute;
  370. display: inline-block;
  371. width: 90rpx;
  372. height: 6rpx;
  373. left: 0;
  374. right: 0;
  375. margin: auto;
  376. background: $uni-color-success;
  377. }
  378. }
  379. }
  380. .top {
  381. position: fixed;
  382. right: 10px;
  383. bottom: 40px;
  384. z-index: 100;
  385. image {
  386. width: 100rpx;
  387. height: 100rpx;
  388. }
  389. .backtop{
  390. display: flex;
  391. justify-content: flex-end;
  392. margin-bottom: 10rpx;
  393. }
  394. .more{
  395. display: flex;
  396. }
  397. .box{
  398. width: 80rpx;
  399. height: 80rpx;
  400. background-color: rgba(161,161,161,0.45);
  401. border-radius: 50%;
  402. text-align: center;
  403. line-height: 80rpx;
  404. box-sizing: border-box;
  405. margin: 14rpx 10rpx 0 0;
  406. color: #fff;
  407. }
  408. }
  409. </style>