list.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="app-container">
  3. <view class="list-container">
  4. <block v-for="(item, index) in dataList" :key='index'>
  5. <view class="item" @tap="toDetail(item.code)">
  6. <view class="num">{{item.code}}</view>
  7. <view class="date">兑换时间:{{item.userExchangeTime}}</view>
  8. </view>
  9. </block>
  10. </view>
  11. <no-data v-if="!dataList.length" :showText="'暂无数据'"></no-data>
  12. <loading-text v-if="dataList.length" :loading="loading" :noMore="noMore" ></loading-text>
  13. </view>
  14. </template>
  15. <script>
  16. import {mapState} from 'vuex';
  17. import EventBus from '@/utils/eventbus.js';
  18. export default {
  19. data() {
  20. return {
  21. pageNum: 1,
  22. pageSize: 8,
  23. dataList: [],
  24. noMore: false,
  25. loading: false,
  26. }
  27. },
  28. computed:{
  29. ...mapState(['userInfo', 'isLogin', 'userId'])
  30. },
  31. onLoad() {
  32. this.getList();
  33. },
  34. // 下拉刷新
  35. onPullDownRefresh() {
  36. this.pageNum = 1;
  37. this.getList();
  38. },
  39. // 上拉加载
  40. onReachBottom() {
  41. this.getList(1);
  42. },
  43. methods: {
  44. // 获取列表
  45. getList(loadMore) {
  46. if(this.noMore && loadMore)return;
  47. this.noMore = false
  48. if(!loadMore){
  49. this.pageNum = 1;
  50. }else{
  51. this.loading = true;
  52. }
  53. this.$axios({
  54. url: '/promotion/luck/draw/list',
  55. method: 'post',
  56. params: {
  57. pageNum: this.pageNum,
  58. pageSize: this.pageSize
  59. },
  60. isLoading: !loadMore
  61. }).then(res => {
  62. let _list = res.data.records;
  63. let pageTotal = res.data.pages;
  64. if(this.pageNum >= pageTotal){
  65. this.noMore = true;
  66. }
  67. if (_list.length) {
  68. this.pageNum += 1
  69. }
  70. if (loadMore) {
  71. this.dataList = this.dataList.concat(_list);
  72. this.loading = false;
  73. } else {
  74. this.dataList = _list;
  75. }
  76. uni.stopPullDownRefresh();
  77. })
  78. },
  79. toDetail(code) {
  80. uni.navigateTo({
  81. url: '/pages/mine/exchange/detail?code=' + code
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. .app-container {
  89. background: #F4F2F2;
  90. padding: 20rpx;
  91. padding-bottom: 250rpx;
  92. box-sizing: border-box;
  93. }
  94. .list-container {
  95. .item {
  96. border-radius: 20rpx;
  97. background: #ffffff;
  98. margin-bottom: 20rpx;
  99. padding: 20rpx 30rpx;
  100. .num {
  101. font-size: 32rpx;
  102. color: #333333;
  103. font-weight: 500;
  104. }
  105. .date {
  106. font-size: 24rpx;
  107. color: #999999;
  108. margin-top: 10rpx;
  109. }
  110. }
  111. }
  112. </style>