index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="pages-content">
  3. <view class="tabs">
  4. <u-tabs-swiper ref="uTabs" :list="tabsList" bar-width="100" :current="current" @change="tabsChange" :is-scroll="false"
  5. swiperWidth="750"></u-tabs-swiper>
  6. </view>
  7. <swiper style="height: calc(100% - 40px);" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
  8. <swiper-item class="swiper-item" v-for="(item, index) in tabsList" :key="index">
  9. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
  10. <couponTpl :list="couponList"></couponTpl>
  11. <u-empty :text="noDataText" img-width="120" v-if="couponList.length==0 && status!='loading'" mode="list"></u-empty>
  12. <view style="padding: 20upx;">
  13. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  14. </view>
  15. </scroll-view>
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. </template>
  20. <script>
  21. import couponTpl from '@/pages/coupon/couponTpl.vue'
  22. import {couponListFind} from '@/api/coupon.js'
  23. export default {
  24. components: {
  25. couponTpl
  26. },
  27. data() {
  28. return {
  29. noDataText: '暂无数据',
  30. status: 'loadmore',
  31. tabsList: [{
  32. name: '未使用'
  33. }, {
  34. name: '已使用'
  35. }, {
  36. name: '已过期'
  37. }],
  38. couponList: [{
  39. id: 23432445,
  40. couponTitle: "满100减50",
  41. couponAmount: 100,
  42. validEndTime: "2020-05-16",
  43. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  44. checked: false
  45. },
  46. {
  47. id: 3544355,
  48. couponTitle: "满100减50",
  49. couponAmount: 100,
  50. validEndTime: "2020-05-16",
  51. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  52. checked: false
  53. },
  54. {
  55. id: 234234234,
  56. couponTitle: "满100减50",
  57. couponAmount: 100,
  58. validEndTime: "2020-05-16",
  59. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  60. checked: false
  61. },
  62. {
  63. id: 66264646,
  64. couponTitle: "满100减50",
  65. couponAmount: 100,
  66. validEndTime: "2020-05-16",
  67. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  68. checked: false
  69. },
  70. {
  71. id: 9794694698,
  72. couponTitle: "满100减50",
  73. couponAmount: 100,
  74. validEndTime: "2020-05-16",
  75. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  76. checked: false
  77. }
  78. ], // 优惠卷列表
  79. // 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
  80. current: 0, // tabs组件的current值,表示当前活动的tab选项
  81. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  82. pageNo:1,
  83. pageSize:15,
  84. count:0
  85. };
  86. },
  87. methods: {
  88. // tabs通知swiper切换
  89. tabsChange(index) {
  90. this.swiperCurrent = index;
  91. },
  92. // swiper-item左右移动,通知tabs的滑块跟随移动
  93. transition(e) {
  94. let dx = e.detail.dx;
  95. this.$refs.uTabs.setDx(dx);
  96. },
  97. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  98. // swiper滑动结束,分别设置tabs和swiper的状态
  99. animationfinish(e) {
  100. let current = e.detail.current;
  101. this.$refs.uTabs.setFinishCurrent(current);
  102. this.swiperCurrent = current;
  103. this.current = current;
  104. },
  105. // scroll-view到底部加载更多
  106. onreachBottom() {
  107. },
  108. // 获取优惠卷列表
  109. getList(){
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss">
  115. page{
  116. height: 100%;
  117. }
  118. .pages-content{
  119. width: 100%;
  120. height: 100%;
  121. display: flex;
  122. flex-direction: column;
  123. uni-swiper{
  124. flex-grow: 1;
  125. }
  126. }
  127. </style>