list.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 :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. //是否第一次进入页面
  33. isfirst:false,
  34. //动态让item主动刷新
  35. refresh:false,
  36. scrollLeft:0,
  37. current: 0,
  38. swiperCurrent:0,
  39. tabs: [
  40. //数据库数据状态-
  41. //工单状态 -1 已取消 0:待处理 1:已处理
  42. //评价 estimateStatus 待评价0 已评价 1
  43. {
  44. name: '全部',
  45. value:''
  46. },
  47. {
  48. name: '待处理',
  49. value:0
  50. },
  51. {
  52. name: '已取消',
  53. value:-1
  54. },
  55. {
  56. name:'待评价',
  57. value:2
  58. },
  59. {
  60. name:'已完成',
  61. value:1
  62. }
  63. ],
  64. }
  65. },
  66. onShow(){
  67. if (this.isfirst) {
  68. this.isfirst=false
  69. }else{
  70. //刷新列表
  71. this.refresh=!this.refresh
  72. }
  73. },
  74. onLoad() {
  75. this.isfirst=true
  76. },
  77. methods:{
  78. tabChange(index) {
  79. this.current = index
  80. // this.scrollLeft = (index - 1) * 60
  81. },
  82. swiperChange(e) {
  83. uni.pageScrollTo({
  84. scrollTop: 0,
  85. duration: 0
  86. });
  87. this.current = e.detail.current
  88. // this.scrollLeft = (this.current - 1) * 60
  89. },
  90. animationfinish({detail: { current }}) {
  91. this.swiperCurrent = current;
  92. this.current = current;
  93. },
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .text-xl{
  99. font-size: 34rpx;
  100. }
  101. .container {
  102. height: calc(100vh - 78rpx);
  103. background-color: #F6F6F6;
  104. padding: 78rpx 0rpx 0rpx;
  105. .tabs {
  106. position: fixed;
  107. top: -10rpx;
  108. left: 0;
  109. display: flex;
  110. align-items: center;
  111. width: 100%;
  112. background-color: #FFFFFF;
  113. box-sizing: border-box;
  114. z-index: 3;
  115. }
  116. }
  117. </style>