list.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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?'base-color 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 "./comps/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. },
  67. onLoad(options) {
  68. this.fireType=options.fireType || 0
  69. getApp().globalData.fireType=this.fireType
  70. if (this.fireType==1) {
  71. uni.setNavigationBarTitle({
  72. title: '气感'
  73. });
  74. }else if (this.fireType==2) {
  75. uni.setNavigationBarTitle({
  76. title: '消防栓'
  77. });
  78. }else if (this.fireType==3) {
  79. uni.setNavigationBarTitle({
  80. title: '电表'
  81. });
  82. }
  83. },
  84. methods:{
  85. tabChange(index) {
  86. this.current = index
  87. // this.scrollLeft = (index - 1) * 60
  88. },
  89. swiperChange(e) {
  90. uni.pageScrollTo({
  91. scrollTop: 0,
  92. duration: 0
  93. });
  94. this.current = e.detail.current
  95. // this.scrollLeft = (this.current - 1) * 60
  96. },
  97. animationfinish({detail: { current }}) {
  98. this.swiperCurrent = current;
  99. this.current = current;
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .text-blue{
  106. color: #59a5f0;
  107. }
  108. .text-xl{
  109. font-size: 34rpx;
  110. }
  111. .container {
  112. height: calc(100vh);
  113. background-color: #F6F6F6;
  114. padding: 78rpx 0rpx 0rpx;
  115. .tabs {
  116. position: fixed;
  117. top: -10rpx;
  118. left: 0;
  119. display: flex;
  120. align-items: center;
  121. width: 100%;
  122. background-color: #FFFFFF;
  123. box-sizing: border-box;
  124. z-index: 3;
  125. }
  126. }
  127. </style>