record.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. }
  112. </script>
  113. <style lang="less">
  114. .record_box{
  115. display: block;
  116. overflow: hidden;
  117. margin: 10rpx auto;
  118. .record_list{
  119. display: block;
  120. overflow: hidden;
  121. .record_item{
  122. display: block;
  123. height: 100rpx;
  124. margin: 10rpx auto;
  125. background: #FFFFFF;
  126. padding: 0rpx 35rpx;
  127. .item_info{
  128. float: left;
  129. height: 100rpx;
  130. .pay_desc{
  131. height: 60rpx;
  132. color: #666666;
  133. font-size: 28rpx;
  134. line-height: 60rpx;
  135. }
  136. .pay_time{
  137. color: #999999;
  138. height: 40rpx;
  139. font-size: 24rpx;
  140. line-height: 40rpx;
  141. }
  142. }
  143. .score{
  144. float: right;
  145. height: 100rpx;
  146. color: forestgreen;
  147. line-height: 100rpx;
  148. .text_red{
  149. color: #E03519;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. </style>