index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: 180px;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 class="top" v-if="isTop" @click="top">
  34. <image src="../../../static/image/6209a98f0cb3b5086f2ca36152c9269.png" mode=""></image>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import equipItem from "../../../components/equip-item/equip-item"
  40. import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
  41. export default {
  42. data() {
  43. return {
  44. active:0,//默认选中虫情测报
  45. equipArr:[{
  46. name:'虫情测报',
  47. type:3, //3虫情测报灯 7孢子仪 4智能性诱
  48. list:[],
  49. pageIndex:1,
  50. },{
  51. name:'孢子仪',
  52. type:7, //3虫情测报灯 7孢子仪 4智能性诱
  53. list:[],
  54. pageIndex:1,
  55. },{
  56. name:'性诱测报',
  57. type:4, //3虫情测报灯 7孢子仪 4智能性诱
  58. list:[],
  59. pageIndex:1,
  60. }],
  61. device_id:'',//筛选的设备id
  62. isTop:false
  63. }
  64. },
  65. onLoad(){
  66. this.getEquipList(0)
  67. this.getEquipList(1)
  68. this.getEquipList(2)
  69. },
  70. onShow(){
  71. },
  72. onHide(){
  73. },
  74. onUnload(){
  75. },
  76. onPullDownRefresh(){
  77. this.equipArr[this.active].pageIndex=1
  78. this.equipArr[this.active].list=[]
  79. this.getEquipList(this.active)
  80. setTimeout(()=>{
  81. uni.stopPullDownRefresh()
  82. },1000)
  83. },
  84. onReachBottom(){
  85. let act=this.active
  86. if(this.equipArr[act].list.length<this.equipArr[act].pageIndex*10){ //判断是否数据请求完
  87. return false
  88. }
  89. this.equipArr[act].pageIndex++;
  90. this.getEquipList(act)
  91. },
  92. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  93. if (e.scrollTop > 200) { //距离大于200时显示
  94. this.isTop = true
  95. } else { //距离小于200时隐藏
  96. this.isTop = false
  97. }
  98. },
  99. methods: {
  100. async getEquipList(act){
  101. const res=await this.$myRequest({
  102. url:'/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  103. data:{
  104. device_type_id:this.equipArr[act].type,
  105. page:this.equipArr[act].pageIndex,
  106. page_size:10,
  107. }
  108. })
  109. console.log(res)
  110. this.equipArr[act].list=[...this.equipArr[act].list,...res.data]
  111. console.log(this.equipArr[act].list)
  112. },
  113. async searchEquip(){
  114. const res=await this.$myRequest({
  115. url:'/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  116. data:{
  117. device_type_id:this.equipArr[this.active].type,
  118. device_id:this.device_id,
  119. }
  120. })
  121. this.equipArr[this.active].list=res.data
  122. },
  123. tabClick(index){
  124. this.active=index;
  125. },
  126. clickRight(){
  127. uni.navigateTo({
  128. url: '/pages/search/search?device_type_id='+this.equipArr[this.active].type
  129. })
  130. },
  131. itemClick(item){
  132. item.type=this.equipArr[this.active].type
  133. let data=JSON.stringify(item)
  134. uni.navigateTo({
  135. url: '/pages/cb/equip-detail/equip-detail?info='+data
  136. });
  137. },
  138. clickLeft(){
  139. uni.switchTab({
  140. url:"../../index/index"
  141. })
  142. },
  143. top() {
  144. uni.pageScrollTo({
  145. scrollTop: 0,
  146. duration: 500
  147. })
  148. }
  149. },
  150. components:{
  151. equipItem,
  152. uniNavBar
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. page {
  158. background:$uni-bg-color-grey;
  159. .content{padding:0 20rpx 20rpx 20rpx;box-sizing: border-box;}
  160. }
  161. image{
  162. width:100%;
  163. }
  164. .tab-box{
  165. display:flex;
  166. justify-content: space-around;
  167. font-size:30rpx;
  168. line-height:80rpx;
  169. background-color: #FFFFFF;
  170. margin-top: -10rpx;
  171. .tab-item{
  172. cursor:pointer;
  173. position:relative;
  174. };
  175. .tab-item.active{
  176. .bottom-line{
  177. bottom:0;
  178. position:absolute;
  179. display: inline-block;
  180. width:90rpx;
  181. height:6rpx;
  182. left:0;
  183. right:0;
  184. margin:auto;
  185. background:$uni-color-success;
  186. }
  187. }
  188. }
  189. .top {
  190. position: fixed;
  191. right: 30px;
  192. bottom: 100px;
  193. z-index: 100;
  194. image{
  195. width: 100rpx;
  196. height: 100rpx;
  197. }
  198. }
  199. </style>