list.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="container">
  3. <view class="tabs" style="width: 420rpx;margin: 0rpx auto;padding-top: 20rpx;">
  4. <scroll-view scroll-x class="nav" >
  5. <view class="flex text-center">
  6. <view style="border: 1rpx solid #5064eb;padding:15rpx 20rpx;" class="flex-sub"
  7. :class="index==current?'nav-checked':'nav-unchecked'"
  8. v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)" >
  9. {{item.name}}
  10. </view>
  11. </view>
  12. </scroll-view>
  13. </view>
  14. <view style="height: 100%;margin-top: 20rpx;">
  15. <swiper style="height: 100%;" :current="current" @change="swiperChange"
  16. @animationfinish="animationfinish">
  17. <swiper-item v-for="(item,index) in tabs" :key="index">
  18. <scroll-view scroll-y style="height: 100%;">
  19. <item :params="params" :i="index" :item="item" :type="current"></item>
  20. </scroll-view>
  21. </swiper-item>
  22. </swiper>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import item from "./comps/item.vue"
  28. export default {
  29. components: {
  30. item
  31. },
  32. data() {
  33. return {
  34. params:{
  35. carNo:''
  36. },
  37. scrollLeft:0,
  38. current: 0,
  39. swiperCurrent:0,
  40. tabs: [
  41. {
  42. name: '入场记录',
  43. value:1
  44. },
  45. {
  46. name: '出场记录',
  47. value:2
  48. }
  49. ],
  50. }
  51. },
  52. onLoad(options) {
  53. this.params.carNo=options.carNo || ''
  54. },
  55. methods:{
  56. tabChange(index) {
  57. this.current = index
  58. },
  59. swiperChange(e) {
  60. uni.pageScrollTo({
  61. scrollTop: 0,
  62. duration: 0
  63. });
  64. this.current = e.detail.current
  65. },
  66. animationfinish({detail: { current }}) {
  67. this.swiperCurrent = current;
  68. this.current = current;
  69. },
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .container {
  75. height: calc(100vh);
  76. background-color: #F6F6F6;
  77. padding: 100rpx 0rpx 0rpx;
  78. .tabs {
  79. height: 100rpx;
  80. position: fixed;
  81. top: 0rpx;
  82. left: 0;
  83. right: 0;
  84. width: 100%;
  85. z-index: 3;
  86. }
  87. }
  88. .nav-checked{
  89. background-color: $base-color;
  90. color: #FFFFFF;
  91. font-weight: 800;
  92. }
  93. .nav-unchecked{
  94. background-color: #FFFFFF;
  95. color: $base-color;
  96. }
  97. </style>