record.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view>
  3. <view class="record_box">
  4. <view class="to_bottom" v-if="!recordList.length"> -----还没有拉新奖励啦-----</view>
  5. <view class="record_list">
  6. <!-- Vue3 项目部分小程序端事件延迟或调用失败 在执行事件的元素上添加 data-eventsync="true" 属性以解决此问题 -->
  7. <view class="record_item" v-for="(item, index) in recordList" :key="index">
  8. <view class="item_info">
  9. <view class="pay_desc">{{ item.username }}注册</view>
  10. <view class="pay_time">{{ item.insert_time }}</view>
  11. </view>
  12. <view class="score">
  13. <view class="text_red" v-if="item.prize_type == 1">+{{ item.prize }}</view>
  14. <view class="text_red" v-if="item.prize_type == 2">赠送优惠券</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. // 列表
  27. recordList: [],
  28. // 请求参数
  29. requestParam: {
  30. page: 1,
  31. },
  32. // 是否最后一页
  33. isLast: false,
  34. // 是否请求中
  35. isReqing: false,
  36. };
  37. },
  38. onShow() {
  39. // 登录提示
  40. if (!this.$checkAccess.alterLogin()) return;
  41. // 没有数据的话,或者请求中,不允许刷新
  42. if (this.isReqing) return;
  43. // 请求参数
  44. this.requestParam.page = 1;
  45. // 是否是最后一页
  46. this.isLast = false;
  47. // 设置请求中
  48. this.isReqing = true;
  49. // 请求
  50. this.$http.request('api/recruitment/get_record', this.requestParam).then((re) => {
  51. // 设置非请求中
  52. this.isReqing = false;
  53. // 成功结果
  54. if (re.code == 'success') {
  55. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  56. this.recordList = re.data.data;
  57. }
  58. });
  59. },
  60. onPullDownRefresh() {
  61. // 登录提示
  62. if (!this.$checkAccess.alterLogin()) return uni.stopPullDownRefresh();
  63. // 如果请求中,不允许请求,
  64. if (this.isReqing) return uni.stopPullDownRefresh();
  65. // 初始化页码为1
  66. this.requestParam.page = 1;
  67. // 是否是最后一页
  68. this.isLast = false;
  69. // 设置请求中
  70. this.isReqing = true;
  71. // 请求列表
  72. this.$http.request('api/recruitment/get_record', this.requestParam).then((re) => {
  73. // 设置非请求中
  74. this.isReqing = false;
  75. // 成功结果
  76. if (re.code == 'success') {
  77. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  78. this.recordList = re.data.data;
  79. }
  80. });
  81. uni.stopPullDownRefresh();
  82. },
  83. onReachBottom() {
  84. // 登录提示
  85. if (!this.$checkAccess.alterLogin()) return;
  86. // 如果页码是0,避免第一页重复
  87. if (this.requestParam.page < 1) return;
  88. // 最后一页不再请求
  89. if (this.isLast) return;
  90. // 请求中,不再请求
  91. if (this.isReqing) return;
  92. // 增加一页
  93. this.requestParam.page = this.requestParam.page + 1;
  94. // 设置请求中
  95. this.isReqing = true;
  96. // 请求列表
  97. this.$http.request('api/recruitment/get_record', this.requestParam).then((re) => {
  98. // 设置非请求中
  99. this.isReqing = false;
  100. // 成功结果
  101. if (re.code == 'success') {
  102. // 最后一页
  103. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  104. // 追加数据
  105. this.recordList.push(...re.data.data);
  106. }
  107. });
  108. },
  109. methods: {},
  110. };
  111. </script>
  112. <style lang="less">
  113. .record_box {
  114. display: block;
  115. overflow: hidden;
  116. margin: 10rpx auto;
  117. .record_list {
  118. display: block;
  119. overflow: hidden;
  120. .record_item {
  121. display: block;
  122. height: 100rpx;
  123. margin: 10rpx auto;
  124. background: #ffffff;
  125. padding: 0rpx 35rpx;
  126. .item_info {
  127. float: left;
  128. height: 100rpx;
  129. .pay_desc {
  130. height: 60rpx;
  131. color: #666666;
  132. font-size: 28rpx;
  133. line-height: 60rpx;
  134. }
  135. .pay_time {
  136. color: #999999;
  137. height: 40rpx;
  138. font-size: 24rpx;
  139. line-height: 40rpx;
  140. }
  141. }
  142. .score {
  143. float: right;
  144. height: 100rpx;
  145. color: forestgreen;
  146. line-height: 100rpx;
  147. .text_red {
  148. color: #f89c33;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. </style>