my-coupons.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <mescroll-uni ref="mescrollRef" top="80rpx" @init="mescrollInit" @down="downCallback" @up="upCallback"
  3. :down="downOption" :up="upOption">
  4. <view class="my-coupons">
  5. <coupon-list :list="couponList" :btnType="btnType"></coupon-list>
  6. </view>
  7. </mescroll-uni>
  8. </template>
  9. <script>
  10. import {
  11. getMyCoupon
  12. } from '@/api/activity';
  13. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  14. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  15. export default {
  16. mixins: [MescrollMixin, MescrollMoreItemMixin],
  17. data() {
  18. return {
  19. couponList: [],
  20. downOption: {
  21. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  22. },
  23. upOption: {
  24. auto: false, // 不自动加载
  25. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  26. empty: {
  27. icon: '/static/images/coupon_null.png',
  28. tip: '暂无优惠券', // 提示
  29. fixed: true
  30. }
  31. },
  32. };
  33. },
  34. props: {
  35. type: {
  36. type: String
  37. },
  38. btnType: {
  39. type: Number
  40. }
  41. },
  42. methods: {
  43. upCallback(page) {
  44. const {
  45. type
  46. } = this;
  47. const pageNum = page.num; // 页码, 默认从1开始
  48. const pageSize = page.size; // 页长, 默认每页10条
  49. getMyCoupon({
  50. page_size: pageSize,
  51. page_no: pageNum,
  52. type
  53. }).then(({
  54. data
  55. }) => {
  56. let curPageData = data.lists;
  57. let curPageLen = curPageData.length;
  58. let hasNext = !!data.more;
  59. if (page.num == 1) this.couponList = [];
  60. this.couponList = this.couponList.concat(curPageData);
  61. this.mescroll.endSuccess(curPageLen, hasNext);
  62. })
  63. },
  64. }
  65. };
  66. </script>
  67. <style>
  68. </style>