record-record.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="income-running">
  3. <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
  4. <view class="content">
  5. <view class="data-card">
  6. <image src="../../static/icon/data-card.png" class="position-center"></image>
  7. <view class="data-card-text position-center">
  8. <text class="text">累计业绩(元)</text>
  9. <text class="num">{{ all_income | numDot }}元</text>
  10. </view>
  11. </view>
  12. <view class="title">收入明细</view>
  13. <view class="scroll">
  14. <pulldown-refresher ref="pulldownRefresher" @pulldownRefresh="pulldownrefresh">
  15. <scroll-view scroll-y :style="{ height: scrollViewHeight + 'px' }" @scrolltolower="scrolltolower">
  16. <view class="item" v-for="(item, index) in list" :key="index">
  17. <view class="left">
  18. <text class="name">{{ item.type | getType }}</text>
  19. <text class="time">{{ item.created_at }}</text>
  20. </view>
  21. <view class="right">+{{ item.money | numDot }}</view>
  22. </view>
  23. <custom-reach-bottom v-if="list.length" :nomore="page === 0" />
  24. <swiper-status v-else :page="page" />
  25. </scroll-view>
  26. </pulldown-refresher>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { _API_FortuneRecordRecord } from '@/apis/fortune.js'
  33. import swiperStatus from '@/components/public/swiper-status.vue'
  34. import pulldownRefresher from '@/components/public/pulldown-refresher.vue'
  35. import customReachBottom from '@/components/public/custom-reach-bottom.vue'
  36. export default {
  37. components: { swiperStatus, pulldownRefresher, customReachBottom },
  38. data() {
  39. return {
  40. title: '历史记录',
  41. all_income: 0,
  42. list: [],
  43. page: 1,
  44. scrollViewHeight: 0,
  45. requesting: false
  46. }
  47. },
  48. filters: {
  49. getType(val) {
  50. switch (+val) {
  51. case 0 : {
  52. return '下级代理下单收入'
  53. }
  54. case 1 : {
  55. return '零售收入'
  56. }
  57. case 2 : {
  58. return '邀请奖励收入'
  59. }
  60. case 3 : {
  61. return '店铺奖励收入'
  62. }
  63. case 4 : {
  64. return '业绩奖励收入'
  65. }
  66. }
  67. }
  68. },
  69. mounted() {
  70. this.request()
  71. this.$offset('.scroll').then(res => {
  72. this.scrollViewHeight = res.height
  73. })
  74. },
  75. methods: {
  76. request(action) {
  77. return new Promise(resolve => { // 只有在 首次加载列表或者下拉刷新时才显示 liaoding
  78. if (this.page) { // 当上一批数量不小于 size 时执行
  79. !action && uni.showLoading({ mask: true }) // 开始 loading, 只有在 首次加载列表或者下拉刷新时才显示 liaoding
  80. this.requesting = true // 请求加锁防抖
  81. _API_FortuneRecordRecord({ page: this.page }).then(res => {
  82. !action ? this.list = [] : '' // 如果是下拉刷新,清空列表
  83. this.list = [...this.list, ...res.data.list]
  84. this.all_income = res.data.all_money // 获取总收入
  85. res.data.list.length < +res.data.size ? this.page = 0 : this.page ++ // 如果返回列表数量小于 10 表示没有更多了
  86. }).catch(() => { // 网络请求失败 进入失败状态
  87. this.page = -1
  88. this.list = []
  89. }).finally(() => { // promise 结束
  90. resolve() // 通知下拉刷新收起
  91. this.requesting = false // 取消请求加锁防抖
  92. })
  93. }
  94. })
  95. },
  96. pulldownrefresh() { // 下拉刷新
  97. this.page = 1
  98. this.request().then(() => { this.$refs.pulldownRefresher.pullup() })
  99. },
  100. scrolltolower() { // 上拉加载
  101. this.requesting ? '' : this.request('loadmore')
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .income-running {
  108. @include page();
  109. .content {
  110. @include flex(column);
  111. .type {
  112. @include flex();
  113. width: 100%;
  114. height: 120rpx;
  115. font-size: 32rpx;
  116. background: #FFFFFF;
  117. padding: 20rpx 30rpx;
  118. box-sizing: border-box;
  119. text {
  120. @include flex();
  121. flex: 1;
  122. height: 100%;
  123. }
  124. }
  125. .title {
  126. @include flex();
  127. width: 100%;
  128. height: 60rpx;
  129. font-size: 32rpx;
  130. padding: 0 30rpx;
  131. background: #FFFFFF;
  132. margin: 10rpx 0 1rpx;
  133. box-sizing: border-box;
  134. justify-content: flex-start;
  135. }
  136. .scroll {
  137. flex: 1;
  138. width: 100%;
  139. background: #FFFFFF;
  140. scroll-view {
  141. .item {
  142. @include flex();
  143. height: 90rpx;
  144. background: #FFFFFF;
  145. padding: 10rpx 30rpx;
  146. box-sizing: border-box;
  147. justify-content: space-between;
  148. border-bottom: 1rpx solid $app-base-bg;
  149. .left {
  150. @include flex(column);
  151. flex: 1;
  152. height: 100%;
  153. align-items: flex-start;
  154. .name {
  155. font-size: 26rpx;
  156. }
  157. .time {
  158. font-size: 24rpx;
  159. color: $app-sec-text-color;
  160. }
  161. }
  162. .right {
  163. font-size: 30rpx;
  164. color: $app-base-color;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>