team-achievement.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="team-achievement">
  3. <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
  4. <w-picker ref="Selector1" mode="selector" defaultVal="全部代理" themeColor="#F76454" :selectList="typeList" @confirm="onConfirm1" />
  5. <w-picker ref="Selector2" mode="selector" defaultVal="本日业绩" themeColor="#F76454" :selectList="timeList" @confirm="onConfirm2" />
  6. <view class="content">
  7. <view class="chooser">
  8. <view class="picker" @tap="choosePicker1">
  9. <text class="icon-right">{{ typeList[choosed.type].label }}</text>
  10. <text class="cuIcon-unfold"></text>
  11. </view>
  12. <view class="picker" @tap="choosePicker2">
  13. <text class="icon-right">{{ timeList[choosed.time].label }}</text>
  14. <text class="cuIcon-unfold"></text>
  15. </view>
  16. </view>
  17. <view class="total">
  18. <text class="text">业绩合计</text>
  19. <text class="num">¥{{ total | numDot }}</text>
  20. </view>
  21. <view class="scroll">
  22. <pulldown-refresher ref="pulldownRefresher" @pulldownRefresh="pulldownrefresh">
  23. <scroll-view scroll-y :style="{ height: scrollViewHeight + 'px' }" @scrolltolower="scrolltolower">
  24. <view class="item" v-for="(item, index) in list" :key="index">
  25. <image class="avatar" :src="item.avatar"></image>
  26. <view class="nickname ellipsis">{{ item.nickname }}</view>
  27. <view class="level-name"><text class="cuIcon-crownfill"></text>{{ item.level }}</view>
  28. <view class="money">¥{{ item.money | numDot }}</view>
  29. </view>
  30. <custom-reach-bottom v-if="list.length" :nomore="page === 0" />
  31. <swiper-status v-else :page="page" unit="团队成员" />
  32. </scroll-view>
  33. </pulldown-refresher>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { _API_TeamAchievement } from '@/apis/team.js'
  40. import WPicker from '@/components/w-picker/w-picker.vue'
  41. import swiperStatus from '@/components/public/swiper-status.vue'
  42. import pulldownRefresher from '@/components/public/pulldown-refresher.vue'
  43. import customReachBottom from '@/components/public/custom-reach-bottom.vue'
  44. export default {
  45. components: { WPicker, swiperStatus, customReachBottom, pulldownRefresher },
  46. data() {
  47. return {
  48. title: '团队业绩',
  49. typeList: [
  50. { label: '全部代理', value: '全部代理' },
  51. { label: '销售经理', value: '销售经理' },
  52. { label: '销售主管', value: '销售主管' },
  53. ],
  54. timeList: [
  55. { label: '本日业绩', value: '本日业绩' },
  56. { label: '本周业绩', value: '本周业绩' },
  57. { label: '本月业绩', value: '本月业绩' },
  58. ],
  59. choosed: { type: 0, time: 0 },
  60. total: 0,
  61. list: [],
  62. page: 1,
  63. scrollViewHeight: 0,
  64. requesting: false
  65. }
  66. },
  67. watch: {
  68. choosed: {
  69. deep: true,
  70. handler() {
  71. this.list = []
  72. this.pulldownrefresh()
  73. }
  74. }
  75. },
  76. mounted() {
  77. this.request()
  78. this.$offset('.scroll').then(res => {
  79. this.scrollViewHeight = res.height
  80. })
  81. },
  82. methods: {
  83. request(action) {
  84. return new Promise(resolve => { // 只有在 首次加载列表或者下拉刷新时才显示 liaoding
  85. if (this.page) { // 当上一批数量不小于 size 时执行
  86. !action && uni.showLoading({ mask: true }) // 开始 loading, 只有在 首次加载列表或者下拉刷新时才显示 liaoding
  87. this.requesting = true // 请求加锁防抖
  88. _API_TeamAchievement({ type: this.choosed.type, time: this.choosed.time, page: this.page }).then(res => {
  89. this.total = res.data.money // 设置业绩业绩数量
  90. !action ? this.list = [] : '' // 如果是下拉刷新,清空列表
  91. this.list = [...this.list, ...res.data.list]
  92. res.data.list.length < +res.data.size ? this.page = 0 : this.page ++ // 如果返回列表数量小于 10 表示没有更多了
  93. }).catch(() => { // 网络请求失败 进入失败状态
  94. this.page = -1
  95. this.list = []
  96. }).finally(() => { // promise 结束
  97. resolve() // 通知下拉刷新收起
  98. this.requesting = false // 取消请求加锁防抖
  99. })
  100. }
  101. })
  102. },
  103. pulldownrefresh() { // 下拉刷新
  104. this.page = 1
  105. this.request().then(() => { this.$refs.pulldownRefresher.pullup() })
  106. },
  107. scrolltolower() { // 上拉加载
  108. this.requesting ? '' : this.request('loadmore')
  109. },
  110. choosePicker1() { // 点击选择级别
  111. this.$refs.Selector1.show()
  112. },
  113. choosePicker2() { // 点击选择时长
  114. this.$refs.Selector2.show()
  115. },
  116. onConfirm1(e) { // 确定级别选择
  117. this.choosed.type = e.defaultVal[0]
  118. },
  119. onConfirm2(e) { // 确定时长选择
  120. this.choosed.time = e.defaultVal[0]
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .team-achievement {
  127. @include page();
  128. .content {
  129. @include flex(column);
  130. .chooser {
  131. @include flex();
  132. width: 100%;
  133. background: #FFFFFF;
  134. .picker {
  135. @include flex();
  136. flex: 1;
  137. height: 84rpx;
  138. }
  139. }
  140. .total {
  141. @include flex();
  142. width: 100%;
  143. height: 90rpx;
  144. padding: 30rpx;
  145. font-size: 32rpx;
  146. margin-top: 10rpx;
  147. background: #FFFFFF;
  148. box-sizing: border-box;
  149. justify-content: space-between;
  150. .num {
  151. color: $app-base-color;
  152. }
  153. }
  154. .scroll {
  155. flex: 1;
  156. width: 100%;
  157. margin-top: 10rpx;
  158. scroll-view {
  159. .item {
  160. @include flex();
  161. height: 120rpx;
  162. background: #FFFFFF;
  163. padding: 10rpx 30rpx;
  164. box-sizing: border-box;
  165. justify-content: space-between;
  166. border-bottom: 1rpx solid $app-base-bg;
  167. .avatar {
  168. width: 100rpx;
  169. height: 100rpx;
  170. border-radius: 50%;
  171. }
  172. .nickname {
  173. max-width: 300rpx;
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. </style>