小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
8.1 KiB

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