index.vue 3.7 KB

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