You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.0 KiB

8 months ago
  1. <template>
  2. <view>
  3. <mNavbar title="我的优惠劵"
  4. :leftClick="toLeft"
  5. style="background: linear-gradient(#4899a6, rgb(78 160 167));"
  6. />
  7. <view style="position: sticky;top: 45px;z-index: 99;">
  8. <van-tabs v-model:active="active"
  9. title-active-color="var(--van-primary-color)"
  10. @change="clickTabs"
  11. >
  12. <van-tab :title="item.name"
  13. v-for="(item, index) in tabs"
  14. :key="index"></van-tab>
  15. </van-tabs>
  16. </view>
  17. <van-list
  18. v-model:loading="loading"
  19. :finished="finished"
  20. @load="onLoad"
  21. >
  22. <couponList :list="couponList" @select="toHome"/>
  23. </van-list>
  24. </view>
  25. </template>
  26. <script>
  27. import couponList from '/components/couponList.vue'
  28. import mNavbar from '@/components/base/m-navbar.vue'
  29. export default {
  30. components : {
  31. couponList,
  32. mNavbar
  33. },
  34. data() {
  35. return {
  36. value : '',
  37. tabs : [
  38. {
  39. name: '待使用优惠劵',
  40. }, {
  41. name: '已使用优惠劵',
  42. }, {
  43. name: '已过期优惠劵'
  44. }
  45. ],
  46. active : 0,
  47. queryParams : {
  48. pageNo : 1,
  49. pageSize : 10,
  50. },
  51. couponList : [],
  52. loading : false,
  53. finished : false,
  54. }
  55. },
  56. onShow(){
  57. this.getCouponList()
  58. },
  59. methods: {
  60. onLoad(){
  61. this.queryParams.pageSize += 10
  62. this.getCouponList()
  63. },
  64. //获取优惠券列表
  65. getCouponList(){
  66. this.$api('getCouponList' , {
  67. ...this.queryParams,
  68. state : this.active
  69. } , res => {
  70. if(res.code == 200){
  71. this.couponList = res.result.records;
  72. if(this.queryParams.pageSize > res.result.total){
  73. this.finished = true
  74. }
  75. }
  76. this.loading = false
  77. })
  78. },
  79. toLeft(){
  80. uni.switchTab({
  81. url: '/pages/index/center'
  82. })
  83. },
  84. clickTabs(e){
  85. this.getCouponList()
  86. },
  87. onClickButton(){
  88. },
  89. toHome(){ //跳转首页
  90. uni.switchTab({
  91. url: '/pages/index/index'
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. .btn{
  99. padding: 0px 30rpx;
  100. background-color: #4FD3BC;
  101. color: #fff;
  102. font-size: 22rpx;
  103. margin-left: 20rpx;
  104. font-size: 20rpx;
  105. border-radius: 30rpx;
  106. }
  107. </style>