index.vue 4.1 KB

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