index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="">
  3. <uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft" 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. device_id:'',//筛选的设备id
  48. }
  49. },
  50. onLoad(){
  51. this.getEquipList(0)
  52. this.getEquipList(1)
  53. this.getEquipList(2)
  54. },
  55. onShow(){
  56. },
  57. onHide(){
  58. },
  59. onUnload(){
  60. },
  61. onPullDownRefresh(){
  62. this.equipArr[this.active].pageIndex=1
  63. this.equipArr[this.active].list=[]
  64. this.getEquipList(this.active)
  65. setTimeout(()=>{
  66. uni.stopPullDownRefresh()
  67. },1000)
  68. },
  69. onReachBottom(){
  70. let act=this.active
  71. if(this.equipArr[act].list.length<this.equipArr[act].pageIndex*10){ //判断是否数据请求完
  72. return false
  73. }
  74. this.equipArr[act].pageIndex++;
  75. this.getEquipList(act)
  76. },
  77. methods: {
  78. async getEquipList(act){
  79. const res=await this.$myRequest({
  80. url:'/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  81. data:{
  82. device_type_id:this.equipArr[act].type,
  83. page:this.equipArr[act].pageIndex,
  84. page_size:10,
  85. }
  86. })
  87. console.log(res)
  88. this.equipArr[act].list=[...this.equipArr[act].list,...res.data]
  89. console.log(this.equipArr[act].list)
  90. },
  91. async searchEquip(){
  92. const res=await this.$myRequest({
  93. url:'/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  94. data:{
  95. device_type_id:this.equipArr[this.active].type,
  96. device_id:this.device_id,
  97. }
  98. })
  99. this.equipArr[this.active].list=res.data
  100. },
  101. tabClick(index){
  102. this.active=index;
  103. },
  104. clickRight(){
  105. uni.navigateTo({
  106. url: '/pages/search/search?device_type_id='+this.equipArr[this.active].type
  107. })
  108. },
  109. itemClick(item){
  110. item.type=this.equipArr[this.active].type
  111. let data=JSON.stringify(item)
  112. uni.navigateTo({
  113. url: '/pages/cb/equip-detail/equip-detail?info='+data
  114. });
  115. },
  116. clickLeft(){
  117. uni.switchTab({
  118. url:"../../index/index"
  119. })
  120. }
  121. },
  122. components:{
  123. equipItem,
  124. uniNavBar
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. page {
  130. background:$uni-bg-color-grey;
  131. .content{padding:0 20rpx 20rpx 20rpx;}
  132. }
  133. image{
  134. width:100%;
  135. }
  136. .tab-box{
  137. display:flex;
  138. justify-content: space-around;
  139. font-size:30rpx;
  140. line-height:80rpx;
  141. .tab-item{
  142. cursor:pointer;
  143. position:relative;
  144. };
  145. .tab-item.active{
  146. .bottom-line{
  147. bottom:0;
  148. position:absolute;
  149. display: inline-block;
  150. width:90rpx;
  151. height:6rpx;
  152. left:0;
  153. right:0;
  154. margin:auto;
  155. background:$uni-color-success;
  156. }
  157. }
  158. }
  159. </style>