user_fans.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" :down="downOption"
  3. @down="downCallback">
  4. <view class="user-fans">
  5. <view class="header">
  6. <u-search v-model="keyword" shape="round" background="white" placeholder="请输入搜索关键词" @search="changeTab"
  7. @custom="changeTab" />
  8. <view class="top-bar flex bg-white md">
  9. <view class="bar-item flex" :class="{'item-active': active == 'all'}" @tap="changeTab('all')">全部粉丝
  10. </view>
  11. <view class="bar-item flex" :class="{'item-active': active == 'first'}" @tap="changeTab('first')">
  12. 一级粉丝</view>
  13. <view class="bar-item flex" :class="{'item-active': active == 'second'}" @tap="changeTab('second')">
  14. 二级粉丝</view>
  15. </view>
  16. <view class="sort-bar flex bg-white">
  17. <view class="sort-bar-item flex row-center" @tap="sortChange(0)">
  18. <view :class="sortType == 0 ? 'item-active' : ''">团队排序</view>
  19. <view class="arrow-icon flex-col col-center row-center">
  20. <u-icon name="arrow-up-fill"
  21. :color="fansSort == 'asc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  22. <u-icon name="arrow-down-fill"
  23. :color="fansSort == 'desc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  24. </view>
  25. </view>
  26. <view class="sort-bar-item flex row-center" @tap="sortChange(1)">
  27. <view :class="sortType == 1 ? 'item-active' : ''">金额排序</view>
  28. <view class="arrow-icon flex-col col-center row-center">
  29. <u-icon name="arrow-up-fill"
  30. :color="moneySort == 'asc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  31. <u-icon name="arrow-down-fill"
  32. :color="moneySort == 'desc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  33. </view>
  34. </view>
  35. <view class="sort-bar-item flex row-center" @tap="sortChange(2)">
  36. <view :class="sortType == 2 ? 'item-active' : ''">订单排序</view>
  37. <view class="arrow-icon flex-col col-center row-center">
  38. <u-icon name="arrow-up-fill"
  39. :color="orderSort == 'asc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  40. <u-icon name="arrow-down-fill"
  41. :color="orderSort == 'desc' ? colorConfig.primary : colorConfig.normal"></u-icon>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="content">
  47. <view class="card-box p-t-20">
  48. <view v-for="(item, index) in fansList" :key="index" class="card-item flex row-between bg-white p-20">
  49. <view class="flex">
  50. <u-image :src="item.avatar" border-radius="50%" width="100rpx" height="100rpx" />
  51. <view class="fans-info m-l-20">
  52. <view class="fans-name bold line-1">{{item.nickname}}</view>
  53. <view class="flex lighter m-t-20">
  54. <view v-if="item.mobile" class="m-r-20">{{item.mobile}}</view>
  55. <view>{{item.create_time}}</view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="flex-col xs flex-none m-l-20">
  60. <view class="msg"><span class="primary">{{item.fans_team}} </span>人</view>
  61. <view class="m-t-5 msg"><span>{{item.fans_order}} </span>单</view>
  62. <view class="m-t-5 msg"><span>{{item.fans_money}} </span>元</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </mescroll-body>
  69. </template>
  70. <script>
  71. import {
  72. sortType,
  73. } from '@/utils/type';
  74. import {
  75. getUserFans
  76. } from '@/api/user';
  77. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  78. export default {
  79. mixins: [MescrollMixin], // 使用mixin
  80. data() {
  81. return {
  82. upOption: {
  83. empty: {
  84. icon: '/static/images/order_null.png',
  85. tip: '暂无相关数据', // 提示
  86. }
  87. },
  88. active: 'all',
  89. sortType: -1,
  90. keyword: "",
  91. fansSort: sortType.NONE,
  92. moneySort: sortType.NONE,
  93. orderSort: sortType.NONE,
  94. fansList: []
  95. };
  96. },
  97. methods: {
  98. onRefresh() {
  99. this.fansList = []
  100. this.mescroll.resetUpScroll();
  101. },
  102. // 上拉加载
  103. upCallback(page) {
  104. const {
  105. fansSort,
  106. moneySort,
  107. orderSort,
  108. active,
  109. keyword,
  110. } = this;
  111. const params = {
  112. type: active,
  113. keyword,
  114. fans: fansSort,
  115. money: moneySort,
  116. order: orderSort,
  117. page_size: page.size,
  118. page_no: page.num,
  119. };
  120. getUserFans(params).then(({
  121. data
  122. }) => {
  123. if (page.num == 1) this.fansList = [];
  124. const curPageData = data.list;
  125. const curPageLen = curPageData.length;
  126. const hasNext = !!data.more;
  127. this.fansList = this.fansList.concat(curPageData);
  128. this.mescroll.endSuccess(curPageLen, hasNext);
  129. }).catch(() => {
  130. this.mescroll.endErr()
  131. })
  132. },
  133. changeTab(val) {
  134. this.active = val
  135. this.onRefresh()
  136. },
  137. // 排序状态变化
  138. sortChange(type) {
  139. let {
  140. fansSort,
  141. moneySort,
  142. orderSort
  143. } = this;
  144. this.sortType = parseInt(type)
  145. switch (this.sortType) {
  146. case 0:
  147. // 团队排序
  148. if (fansSort == sortType.DESC || fansSort == sortType.NONE) {
  149. this.fansSort = sortType.ASC;
  150. this.moneySort = sortType.NONE
  151. this.orderSort = sortType.NONE
  152. } else if (fansSort == sortType.ASC) {
  153. this.fansSort = sortType.DESC;
  154. this.moneySort = sortType.NONE;
  155. this.orderSort = sortType.NONE;
  156. }
  157. break;
  158. case 1:
  159. // 金额排序
  160. if (moneySort == sortType.DESC || moneySort == sortType.NONE) {
  161. this.moneySort = sortType.ASC;
  162. this.fansSort = sortType.NONE;
  163. this.orderSort = sortType.NONE
  164. } else if (moneySort == sortType.ASC) {
  165. this.moneySort = sortType.DESC;
  166. this.fansSort = sortType.NONE;
  167. this.orderSort = sortType.NONE;
  168. }
  169. break;
  170. case 2:
  171. // 订单排序
  172. if (orderSort == sortType.DESC || orderSort == sortType.NONE) {
  173. this.orderSort = sortType.ASC;
  174. this.moneySort = sortType.NONE;
  175. this.fansSort = sortType.NONE;
  176. } else if (orderSort == sortType.ASC) {
  177. this.orderSort = sortType.DESC;
  178. this.moneySort = sortType.NONE;
  179. this.fansSort = sortType.NONE;
  180. }
  181. break;
  182. }
  183. this.onRefresh()
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss">
  189. .user-fans {
  190. .header {
  191. .top-bar {
  192. padding: 18rpx 50rpx;
  193. height: 100rpx;
  194. .bar-item {
  195. flex: 1;
  196. padding: 0 30rpx;
  197. height: 58rpx;
  198. &:not(:last-of-type) {
  199. margin-right: 54rpx;
  200. }
  201. }
  202. .item-active {
  203. color: white;
  204. background-color: $-color-primary;
  205. border-radius: 100rpx;
  206. }
  207. }
  208. .sort-bar {
  209. height: 80rpx;
  210. .sort-bar-item {
  211. flex: 1;
  212. .arrow-icon {
  213. transform: scale(0.36);
  214. }
  215. .item-active {
  216. color: $-color-primary;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. .content {
  223. .card-box {
  224. .card-item {
  225. .fans-name {
  226. width: 500rpx;
  227. }
  228. &:not(:last-of-type) {
  229. border-bottom: $-solid-border;
  230. }
  231. }
  232. }
  233. }
  234. </style>