list.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. },
  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. }
  79. },
  80. methods:{
  81. tabChange(index) {
  82. this.current = index
  83. // this.scrollLeft = (index - 1) * 60
  84. },
  85. swiperChange(e) {
  86. uni.pageScrollTo({
  87. scrollTop: 0,
  88. duration: 0
  89. });
  90. this.current = e.detail.current
  91. // this.scrollLeft = (this.current - 1) * 60
  92. },
  93. animationfinish({detail: { current }}) {
  94. this.swiperCurrent = current;
  95. this.current = current;
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .text-blue{
  102. color: #59a5f0;
  103. }
  104. .text-xl{
  105. font-size: 34rpx;
  106. }
  107. .container {
  108. height: calc(100vh);
  109. background-color: #F6F6F6;
  110. padding: 78rpx 0rpx 0rpx;
  111. .tabs {
  112. position: fixed;
  113. top: -10rpx;
  114. left: 0;
  115. display: flex;
  116. align-items: center;
  117. width: 100%;
  118. background-color: #FFFFFF;
  119. box-sizing: border-box;
  120. z-index: 3;
  121. }
  122. }
  123. </style>