index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="">
  3. <uni-nav-bar @clickRight="clickRight" left-icon="back" left-text="返回" right-icon="search" title="测报灯系统"></uni-nav-bar>
  4. <view>
  5. <image src="../../../static/image/cb/banner.jpg" mode="widthFix"></image>
  6. </view>
  7. <view class="tab-box">
  8. <view
  9. v-for="(item,index) in equipArr"
  10. :key="item.type"
  11. @click="tabClick(index)"
  12. :class="['tab-item',active==index?'active':'']">
  13. <text>{{item.name}}</text>
  14. <text class="bottom-line"></text>
  15. </view>
  16. </view>
  17. <view class="content">
  18. <template v-for="(item,index) in equipArr[active].list" >
  19. <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index"></equipItem>
  20. </template>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import equipItem from "../../../components/equip-item/equip-item"
  26. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  27. export default {
  28. data() {
  29. return {
  30. active:0,//默认选中虫情测报
  31. equipArr:[{
  32. name:'虫情测报',
  33. type:3, //3虫情测报灯 7孢子仪 4智能性诱
  34. list:[],
  35. pageIndex:1,
  36. },{
  37. name:'孢子仪',
  38. type:7, //3虫情测报灯 7孢子仪 4智能性诱
  39. list:[],
  40. pageIndex:1,
  41. },{
  42. name:'性诱测报',
  43. type:4, //3虫情测报灯 7孢子仪 4智能性诱
  44. list:[],
  45. pageIndex:1,
  46. }],
  47. }
  48. },
  49. onLoad(){
  50. this.getEquipList(0)
  51. this.getEquipList(1)
  52. this.getEquipList(2)
  53. },
  54. onShow(){
  55. },
  56. onHide(){
  57. },
  58. onUnload(){
  59. },
  60. onPullDownRefresh(){
  61. this.equipArr[this.active].pageIndex=1
  62. this.equipArr[this.active].list=[]
  63. this.getEquipList(this.active)
  64. setTimeout(()=>{
  65. uni.stopPullDownRefresh()
  66. },1000)
  67. },
  68. onReachBottom(){
  69. let act=this.active
  70. if(this.equipArr[act].list.length<this.equipArr[act].pageIndex*10){ //判断是否数据请求完
  71. return false
  72. }
  73. this.equipArr[act].pageIndex++;
  74. this.getEquipList(act)
  75. },
  76. methods: {
  77. async getEquipList(act){
  78. const res=await this.$myRequest({
  79. url:'/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  80. data:{
  81. device_type_id:this.equipArr[act].type,
  82. page:this.equipArr[act].pageIndex,
  83. page_size:10
  84. }
  85. })
  86. this.equipArr[act].list=[...this.equipArr[act].list,...res.data]
  87. console.log(this.equipArr[act].list)
  88. },
  89. tabClick(index){
  90. this.active=index;
  91. },
  92. clickRight(){
  93. uni.navigateTo({
  94. url: '/pages/search/search'
  95. });
  96. },
  97. itemClick(item){
  98. item.type=this.equipArr[this.active].type
  99. let data=JSON.stringify(item)
  100. uni.navigateTo({
  101. url: '/pages/cb/equip-detail/equip-detail?info='+data
  102. });
  103. }
  104. },
  105. components:{
  106. equipItem,
  107. uniNavBar
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. page {
  113. background:$uni-bg-color-grey;
  114. .content{padding:0 20rpx 20rpx 20rpx;}
  115. }
  116. image{
  117. width:100%;
  118. }
  119. .tab-box{
  120. display:flex;
  121. justify-content: space-around;
  122. font-size:30rpx;
  123. line-height:80rpx;
  124. .tab-item{
  125. cursor:pointer;
  126. position:relative;
  127. };
  128. .tab-item.active{
  129. .bottom-line{
  130. bottom:0;
  131. position:absolute;
  132. display: inline-block;
  133. width:90rpx;
  134. height:6rpx;
  135. left:0;
  136. right:0;
  137. margin:auto;
  138. background:$uni-color-success;
  139. }
  140. }
  141. }
  142. </style>