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.

102 lines
1.8 KiB

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