index.vue 3.9 KB

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