ordre.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-base cur text-xl text-bold ':'text-lg'"
  7. v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)">
  8. {{item.name}}
  9. </view>
  10. </view>
  11. </scroll-view>
  12. </view>
  13. <view style="height: 100%;">
  14. <swiper style="height: 100%;" :current="current" @change="swiperChange" @animationfinish="animationfinish">
  15. <swiper-item v-for="(item,index) in tabs" :key="index">
  16. <scroll-view scroll-y style="height: 100%;">
  17. <item ref="mescrollItem" :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. current: 0,
  33. swiperCurrent: 0,
  34. tabs: [{
  35. name: '今日订单',
  36. value: 0
  37. },
  38. {
  39. name: '全部订单',
  40. value: 1
  41. }
  42. ],
  43. }
  44. },
  45. onLoad() {
  46. },
  47. onShow() {
  48. if(this.canReset){
  49. let curMescroll = this.getMescroll(this.current)
  50. curMescroll && curMescroll.resetUpScroll()
  51. }
  52. this.canReset = true
  53. },
  54. methods: {
  55. getMescroll(i){
  56. let mescrollItems = this.$refs.mescrollItem;
  57. if(mescrollItems){
  58. let item = mescrollItems[i]
  59. if(item) return item.mescroll
  60. }
  61. return null
  62. },
  63. tabChange(index) {
  64. this.current = index
  65. },
  66. swiperChange(e) {
  67. uni.pageScrollTo({
  68. scrollTop: 0,
  69. duration: 0
  70. });
  71. this.current = e.detail.current
  72. },
  73. animationfinish({
  74. detail: {
  75. current
  76. }
  77. }) {
  78. this.swiperCurrent = current;
  79. this.current = current;
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .text-xl {
  86. font-size: 34rpx;
  87. }
  88. .container {
  89. height: calc(100vh);
  90. background-color: #F6F6F6;
  91. padding: 78rpx 0rpx 0rpx;
  92. .tabs {
  93. position: fixed;
  94. top: -10rpx;
  95. left: 0;
  96. width: 100%;
  97. background-color: #FFFFFF;
  98. box-sizing: border-box;
  99. z-index: 3;
  100. }
  101. }
  102. </style>