list.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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%;">
  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 @showDetail="showDetail" :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. scrollLeft:0,
  35. current: 0,
  36. swiperCurrent:0,
  37. tabs: [
  38. {
  39. name: '全部记录',
  40. value:''
  41. },
  42. {
  43. name: '异常记录',
  44. value:1
  45. }
  46. ],
  47. }
  48. },
  49. methods:{
  50. tabChange(index) {
  51. this.current = index
  52. },
  53. swiperChange(e) {
  54. uni.pageScrollTo({
  55. scrollTop: 0,
  56. duration: 0
  57. });
  58. this.current = e.detail.current
  59. },
  60. animationfinish({detail: { current }}) {
  61. this.swiperCurrent = current;
  62. this.current = current;
  63. },
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .container {
  69. height: calc(100vh);
  70. background-color: #F6F6F6;
  71. padding: 100rpx 0rpx 0rpx;
  72. .tabs {
  73. height: 100rpx;
  74. position: fixed;
  75. top: 0rpx;
  76. left: 0;
  77. right: 0;
  78. width: 100%;
  79. z-index: 3;
  80. }
  81. }
  82. .nav-checked{
  83. background-color: $base-color;
  84. color: #FFFFFF;
  85. font-weight: 800;
  86. }
  87. .nav-unchecked{
  88. background-color: #FFFFFF;
  89. color: $base-color;
  90. }
  91. </style>