PromoterList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="promoter-list" ref="container">
  3. <NavBar title="推广人数"></NavBar>
  4. <div class="header">
  5. <div class="promoterHeader bg-color-red">
  6. <div class="headerCon acea-row row-between-wrapper">
  7. <div>
  8. <div class="name">推广人数</div>
  9. <div>
  10. <span class="num">{{ first + second }}</span
  11. >人
  12. </div>
  13. </div>
  14. <div class="iconfont icon-tuandui"></div>
  15. </div>
  16. </div>
  17. <div class="nav acea-row row-around">
  18. <div
  19. class="item"
  20. :class="screen.grade == 0 ? 'on' : ''"
  21. @click="checkGrade(0)"
  22. >
  23. 一级({{ first }})
  24. </div>
  25. <div
  26. class="item"
  27. :class="screen.grade == 1 ? 'on' : ''"
  28. @click="checkGrade(1)"
  29. >
  30. 二级({{ second }})
  31. </div>
  32. </div>
  33. <div class="search acea-row row-between-wrapper">
  34. <form @submit.prevent="submitForm">
  35. <div class="input">
  36. <input placeholder="点击搜索会员名称" v-model="screen.keyword" />
  37. <span class="iconfont icon-guanbi"></span>
  38. </div>
  39. </form>
  40. <div class="iconfont icon-sousuo2"></div>
  41. </div>
  42. </div>
  43. <div class="list">
  44. <div
  45. class="sortNav acea-row row-middle"
  46. :class="fixedState === true ? 'on' : ''"
  47. >
  48. <div class="sortItem" @click="sort('childCount')">
  49. 团队排序
  50. <img src="@assets/images/sort1.png" v-if="childCount == 1" />
  51. <img src="@assets/images/sort2.png" v-if="childCount == 2" />
  52. <img src="@assets/images/sort3.png" v-if="childCount == 3" />
  53. </div>
  54. <div class="sortItem" @click="sort('numberCount')">
  55. 金额排序
  56. <img src="@assets/images/sort1.png" v-if="numberCount == 1" />
  57. <img src="@assets/images/sort2.png" v-if="numberCount == 2" />
  58. <img src="@assets/images/sort3.png" v-if="numberCount == 3" />
  59. </div>
  60. <div class="sortItem" @click="sort('orderCount')">
  61. 订单排序
  62. <img src="@assets/images/sort1.png" v-if="orderCount == 1" />
  63. <img src="@assets/images/sort2.png" v-if="orderCount == 2" />
  64. <img src="@assets/images/sort3.png" v-if="orderCount == 3" />
  65. </div>
  66. </div>
  67. <div :class="fixedState === true ? 'sortList' : ''">
  68. <div
  69. class="item acea-row row-between-wrapper"
  70. v-for="(val, index) in spreadList"
  71. :key="index"
  72. >
  73. <div class="picTxt acea-row row-between-wrapper">
  74. <div class="pictrue"><img :src="val.avatar" /></div>
  75. <div class="text">
  76. <div class="name line1">{{ val.nickname }}</div>
  77. <div>加入时间: {{ val.time }}</div>
  78. </div>
  79. </div>
  80. <div class="right">
  81. <div>
  82. <span class="font-color-red">{{ val.childCount }}</span> 人
  83. </div>
  84. <div>{{ val.orderCount }} 单</div>
  85. <div>{{ val.numberCount ? val.numberCount : 0 }} 元</div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <Loading :loaded="loaded" :loading="loading"></Loading>
  91. </div>
  92. </template>
  93. <script>
  94. import { getSpreadUser } from "../../../api/user";
  95. import Loading from "@components/Loading";
  96. import NavBar from "@components/NavBar";
  97. export default {
  98. name: "PromoterList",
  99. components: {
  100. Loading,
  101. NavBar
  102. },
  103. props: {},
  104. data: function() {
  105. return {
  106. fixedState: false,
  107. screen: {
  108. page: 1,
  109. limit: 15,
  110. grade: 0,
  111. keyword: "",
  112. sort: ""
  113. },
  114. childCount: 2,
  115. numberCount: 2,
  116. orderCount: 2,
  117. loaded: false,
  118. loading: false,
  119. spreadList: [],
  120. loadTitle: "",
  121. first: "",
  122. second: ""
  123. };
  124. },
  125. mounted: function() {
  126. this.getSpreadUsers();
  127. this.$scroll(this.$refs.container, () => {
  128. !this.loading && this.getSpreadUsers();
  129. });
  130. },
  131. watch: {
  132. "screen.sort": function() {
  133. this.screen.page = 0;
  134. this.loaded = false;
  135. this.loading = false;
  136. this.spreadList = [];
  137. this.getSpreadUsers();
  138. }
  139. },
  140. methods: {
  141. handleScroll: function() {
  142. var scrollTop =
  143. document.documentElement.scrollTop || document.body.scrollTop;
  144. var offsetTop = document.querySelector(".header").clientHeight;
  145. if (scrollTop >= offsetTop) {
  146. this.fixedState = true;
  147. } else {
  148. this.fixedState = false;
  149. }
  150. },
  151. submitForm: function() {
  152. this.screen.page = 0;
  153. this.loaded = false;
  154. this.loading = false;
  155. this.spreadList = [];
  156. this.getSpreadUsers();
  157. },
  158. getSpreadUsers: function() {
  159. let that = this,
  160. screen = that.screen;
  161. if (that.loaded || that.loading) return;
  162. that.loading = true;
  163. getSpreadUser(screen).then(
  164. res => {
  165. that.loading = false;
  166. that.spreadList.push.apply(that.spreadList, res.data.list);
  167. that.loaded = res.data.list.length < that.screen.limit; //判断所有数据是否加载完成;
  168. that.loadTitle = that.loaded ? "人家是有底线的" : "上拉加载更多";
  169. that.screen.page = that.screen.page + 1;
  170. that.first = res.data.total;
  171. that.second = res.data.totalLevel;
  172. },
  173. error => {
  174. that.$dialog.message(error.msg);
  175. },
  176. 300
  177. );
  178. },
  179. checkGrade: function(val) {
  180. if (val == this.screen.grade) return;
  181. else {
  182. this.screen.page = 1;
  183. this.screen.grade = val;
  184. this.loading = false;
  185. this.loaded = false;
  186. this.spreadList = [];
  187. this.getSpreadUsers();
  188. }
  189. },
  190. sort: function(types) {
  191. let that = this;
  192. switch (types) {
  193. case "childCount":
  194. if (that.childCount == 2) {
  195. that.childCount = 1;
  196. that.orderCount = 2;
  197. that.numberCount = 2;
  198. that.screen.sort = "childCount DESC";
  199. } else if (that.childCount == 1) {
  200. that.childCount = 3;
  201. that.orderCount = 2;
  202. that.numberCount = 2;
  203. that.screen.sort = "childCount ASC";
  204. } else if (that.childCount == 3) {
  205. that.childCount = 2;
  206. that.orderCount = 2;
  207. that.numberCount = 2;
  208. that.screen.sort = "";
  209. }
  210. break;
  211. case "numberCount":
  212. if (that.numberCount == 2) {
  213. that.numberCount = 1;
  214. that.orderCount = 2;
  215. that.childCount = 2;
  216. that.screen.sort = "numberCount DESC";
  217. } else if (that.numberCount == 1) {
  218. that.numberCount = 3;
  219. that.orderCount = 2;
  220. that.childCount = 2;
  221. that.screen.sort = "numberCount ASC";
  222. } else if (that.numberCount == 3) {
  223. that.numberCount = 2;
  224. that.orderCount = 2;
  225. that.childCount = 2;
  226. that.screen.sort = "";
  227. }
  228. break;
  229. case "orderCount":
  230. if (that.orderCount == 2) {
  231. that.orderCount = 1;
  232. that.numberCount = 2;
  233. that.childCount = 2;
  234. that.screen.sort = "orderCount DESC";
  235. } else if (that.orderCount == 1) {
  236. that.orderCount = 3;
  237. that.numberCount = 2;
  238. that.childCount = 2;
  239. that.screen.sort = "orderCount ASC";
  240. } else if (that.orderCount == 3) {
  241. that.orderCount = 2;
  242. that.numberCount = 2;
  243. that.childCount = 2;
  244. that.screen.sort = "";
  245. }
  246. break;
  247. default:
  248. that.screen.sort = "";
  249. }
  250. }
  251. }
  252. };
  253. </script>