index.vue 9.2 KB

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