list.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="container">
  3. <view class="tabs">
  4. <scroll-view scroll-x class="bg-white nav">
  5. <view class="flex text-center">
  6. <view class="cu-item flex-sub" :class="index==current?'text-blue text-xl text-bold ':'text-lg'" v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)" >
  7. {{item.name}}
  8. </view>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. <view style="height: 100%;">
  13. <swiper style="height: 100%;" :current="current" @change="swiperChange"
  14. @animationfinish="animationfinish">
  15. <swiper-item v-for="(item, index) in tabs" :key="index">
  16. <scroll-view scroll-y style="height: 100%;">
  17. <item :fireType="fireType" :refresh="refresh" :i="index" :item="item" :type="current"></item>
  18. </scroll-view>
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import item from "./item.vue"
  26. export default {
  27. components: {
  28. item
  29. },
  30. data() {
  31. return {
  32. //0 烟感报警 1 燃气告警 2 消防水压
  33. fireType:0,
  34. //是否第一次进入页面
  35. isfirst:false,
  36. //动态让item主动刷新
  37. refresh:false,
  38. scrollLeft:0,
  39. current: 0,
  40. swiperCurrent:0,
  41. tabs: [
  42. {
  43. name: '全部',
  44. value:''
  45. },
  46. {
  47. name: '正常',
  48. value:1
  49. },
  50. {
  51. name: '告警',
  52. value:2
  53. },
  54. {
  55. name:'失联',
  56. value:3
  57. },
  58. {
  59. name:'停用',
  60. value:4
  61. },
  62. ],
  63. }
  64. },
  65. onShow(){
  66. if (this.isfirst) {
  67. this.isfirst=false
  68. }else{
  69. //刷新列表
  70. this.refresh=!this.refresh
  71. }
  72. },
  73. onLoad(options) {
  74. this.fireType=options.fireType || 0
  75. getApp().globalData.fireType=this.fireType
  76. if (this.fireType==1) {
  77. uni.setNavigationBarTitle({
  78. title: '气感'
  79. });
  80. }else if (this.fireType==2) {
  81. uni.setNavigationBarTitle({
  82. title: '消防栓'
  83. });
  84. }
  85. this.isfirst=true
  86. },
  87. methods:{
  88. tabChange(index) {
  89. this.current = index
  90. // this.scrollLeft = (index - 1) * 60
  91. },
  92. swiperChange(e) {
  93. uni.pageScrollTo({
  94. scrollTop: 0,
  95. duration: 0
  96. });
  97. this.current = e.detail.current
  98. // this.scrollLeft = (this.current - 1) * 60
  99. },
  100. animationfinish({detail: { current }}) {
  101. this.swiperCurrent = current;
  102. this.current = current;
  103. },
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .text-blue{
  109. color: #59a5f0;
  110. }
  111. .text-xl{
  112. font-size: 34rpx;
  113. }
  114. .container {
  115. height: calc(100vh);
  116. background-color: #F6F6F6;
  117. padding: 78rpx 0rpx 0rpx;
  118. .tabs {
  119. position: fixed;
  120. top: -10rpx;
  121. left: 0;
  122. display: flex;
  123. align-items: center;
  124. width: 100%;
  125. background-color: #FFFFFF;
  126. box-sizing: border-box;
  127. z-index: 3;
  128. }
  129. }
  130. </style>