get_coupon.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  3. :up="upOption">
  4. <view class="get-coupon">
  5. <view>
  6. <image class="banner" src="/static/images/banner_coupon.jpg"></image>
  7. </view>
  8. <view class="bg-body main">
  9. <coupon-list :list="couponList" :btn-type="3" @refresh="refresh"></coupon-list>
  10. </view>
  11. </view>
  12. </mescroll-body>
  13. </template>
  14. <script>
  15. import {
  16. getCouponList,
  17. getCoupon
  18. } from '@/api/activity';
  19. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
  20. export default {
  21. mixins: [MescrollMixin],
  22. data() {
  23. return {
  24. active: 0,
  25. upOption: {
  26. empty: {
  27. icon: '/static/images/coupon_null.png',
  28. tip: "暂无优惠券",
  29. }
  30. },
  31. tabList: [{
  32. name: '全部',
  33. type: 'all'
  34. },{
  35. name: '店铺券',
  36. type: 'shop'
  37. },{
  38. name: '通用券',
  39. type: 'platform'
  40. }],
  41. couponList: []
  42. };
  43. },
  44. onLoad(options) {
  45. },
  46. methods: {
  47. upCallback(page) {
  48. const {tabList, active} = this
  49. getCouponList({
  50. page_size:page.size,
  51. page_no:page.num,
  52. type: tabList[active].type
  53. }).then(({
  54. data
  55. }) => {
  56. if (page.num == 1) this.couponList = [];
  57. const curPageData = data.lists;
  58. const curPageLen = curPageData.length;
  59. const hasNext = !!data.more;
  60. this.couponList = this.couponList.concat(curPageData);
  61. this.mescroll.endSuccess(curPageLen, hasNext);
  62. }).catch(() => {
  63. this.mescroll.endErr()
  64. })
  65. },
  66. changeActive(index) {
  67. this.active = index
  68. this.refresh()
  69. },
  70. refresh() {
  71. this.couponList = [] // 先置空列表,显示加载进度
  72. this.mescroll.resetUpScroll() // 再刷新列表数据
  73. }
  74. }
  75. };
  76. </script>
  77. <style>
  78. .banner {
  79. width: 100%;
  80. height: 340rpx;
  81. }
  82. .main {
  83. border-radius: 20rpx 20rpx 0 0;
  84. margin-top: -20rpx;
  85. overflow: hidden;
  86. position: relative;
  87. }
  88. </style>