tradingRecord.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <!-- 使用z-paging-swiper为根节点可以免计算高度 -->
  3. <z-paging-swiper>
  4. <!-- 需要固定在顶部不滚动的view放在slot="top"的view中 -->
  5. <!-- 注意!此处的z-tabs为独立的组件,可替换为第三方的tabs,若需要使用z-tabs,请在插件市场搜索z-tabs并引入,否则会报插件找不到的错误 -->
  6. <template #top>
  7. <z-tabs ref="tabs" :list="tab_list" :current="current" @change="tabsChange"
  8. inactiveColor='#000' activeColor="#FD4A76"
  9. :active-style="{'font-size': '18px', 'font-weight': '400'}"
  10. :inactive-style="{'font-size': '18px', 'font-weight': '400'}"
  11. barWidth="90"
  12. />
  13. </template>
  14. <!-- swiper必须设置height:100%,因为swiper有默认的高度,只有设置高度100%才可以铺满页面 -->
  15. <swiper class="swiper" duration="100" :current="current" @transition="swiperTransition" @animationfinish="swiperAnimationfinish">
  16. <swiper-item class="swiper-item" v-for="(item, index) in tab_list" :key="index">
  17. <recharge v-if="index==0" :tab_index="index" :current_index="current"></recharge>
  18. <consume v-if="index==1" :tab_index="index" :current_index="current"></consume>
  19. <rewards v-if="index==2" :tab_index="index" :current_index="current"></rewards>
  20. </swiper-item>
  21. </swiper>
  22. </z-paging-swiper>
  23. </template>
  24. <script setup lang="ts">
  25. import { ref } from 'vue';
  26. import recharge from '../tradingRecord/tr-recharge.vue'
  27. import consume from '../tradingRecord/tr-consume.vue'
  28. import rewards from '../tradingRecord/tr-rewards.vue'
  29. let tab_list = ref(['充值记录','消费记录']) //ref(['充值记录','消费记录','奖励记录'])
  30. let current = ref(0) // tabs组件的current值,表示当前活动的tab选项
  31. const tabs = ref(null)
  32. // tabs通知swiper切换
  33. function tabsChange(index:number) {
  34. current.value = index
  35. }
  36. // swiper滑动中
  37. function swiperTransition(e) {
  38. tabs.value.setDx(e.detail.dx)
  39. }
  40. // swiper滑动结束
  41. function swiperAnimationfinish(e) {
  42. current.value = e.detail.current
  43. tabs.value.unlockDx()
  44. }
  45. </script>
  46. <style lang="scss">
  47. .swiper {
  48. height: 100%;
  49. }
  50. </style>