coupon-list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <!-- TODO -->
  3. <view class="coupon-find-list">
  4. <!-- tabs -->
  5. <tui-tabs
  6. :tabs="tabs"
  7. :currentTab="currentTab"
  8. @change="tabChange"
  9. :sliderWidth="118"
  10. color="#333333"
  11. selectedColor="#FF457B"
  12. sliderBgColor="#FF457B"
  13. ></tui-tabs>
  14. <!-- 优惠券列表 -->
  15. <swiper
  16. :indicator-dots="false"
  17. :autoplay="false"
  18. class="swiper"
  19. :style="{ height: swiperHeight + 'px' }"
  20. :current="currentTab"
  21. @change="swiperChange"
  22. >
  23. <swiper-item class="coupon-list"> <cm-coupon :key="i" v-for="i in 15"></cm-coupon> </swiper-item>
  24. <swiper-item class="coupon-list"> <cm-coupon :key="i" v-for="i in 3"></cm-coupon> </swiper-item>
  25. <swiper-item class="coupon-list">
  26. <cm-empty message="暂无任何优惠券~" :image="baseUrl + 'icon-coupon-empty.png'" :offset="-12"></cm-empty>
  27. </swiper-item>
  28. </swiper>
  29. <!-- 跳转领券中心 -->
  30. <view class="footer"> <view class="btn">领券中心</view> </view>
  31. </view>
  32. </template>
  33. <script>
  34. import CmCoupon from '@/components/cm-module/cm-coupon/cm-coupon.vue'
  35. import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
  36. import { mapGetters } from 'vuex'
  37. export default {
  38. components: {
  39. CmCoupon,
  40. CmEmpty
  41. },
  42. data() {
  43. return {
  44. windowHeight: 0,
  45. baseUrl: this.$Static,
  46. tabs: [
  47. {
  48. name: '未使用10'
  49. },
  50. {
  51. name: '已使用10'
  52. },
  53. {
  54. name: '已失效10'
  55. }
  56. ],
  57. currentTab: 0
  58. }
  59. },
  60. computed: {
  61. ...mapGetters(['isIphoneX']),
  62. swiperHeight() {
  63. if (this.isIphoneX) {
  64. return this.windowHeight - 120
  65. }
  66. return this.windowHeight - 80
  67. // return this.swiperHeight
  68. }
  69. },
  70. onLoad() {
  71. this.getWindowHeight()
  72. },
  73. methods: {
  74. tabChange(e) {
  75. this.currentTab = e.index
  76. },
  77. swiperChange(e){
  78. this.currentTab = e.detail.current
  79. },
  80. // 获取可用屏幕高度
  81. getWindowHeight(){
  82. this.windowHeight = uni.getSystemInfoSync().windowHeight
  83. console.log(this.windowHeight)
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. page{
  90. width: 100%;
  91. height: 100%;
  92. background: #f7f7f7;
  93. }
  94. .swiper {
  95. height: 800rpx;
  96. background: #f7f7f7;
  97. .coupon-list{
  98. height: 100%;
  99. overflow-y: scroll;
  100. }
  101. }
  102. .footer {
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. background: #f7f7f7;
  107. padding-top: 20rpx;
  108. .btn {
  109. display: flex;
  110. justify-content: center;
  111. align-items: center;
  112. width: 600rpx;
  113. height: 90rpx;
  114. background: linear-gradient(90deg, #fc32b4 0%, #f83c6c 100%);
  115. border-radius: 45rpx;
  116. font-size: 30rpx;
  117. color: #ffffff;
  118. }
  119. }
  120. </style>