myteam.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
  6. <text>{{ item.text }}</text>
  7. <text v-if="item.num>0">({{ item.num || '' }})</text>
  8. </view>
  9. </view>
  10. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  11. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  12. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  13. <view class="searchInput flex">
  14. <view class="searchBox flex">
  15. <image class="search" src="../../static/icon/search.png" mode="widthFix"></image>
  16. <input class="input" type="text" @confirm="changeSearchList('')" v-model='search'
  17. confirm-type='搜索' />
  18. <image @click="search=''" class="exit" src="../../static/icon/goodsExit.png"
  19. mode="widthFix"></image>
  20. </view>
  21. <view class="searchImg flex">
  22. <picker mode="selector" range-key="text" :range="searchList" @change="changeSearchList">
  23. <image class="searchList" src="../../static/icon/searchList.png" mode="widthFix">
  24. </image>
  25. </picker>
  26. </view>
  27. </view>
  28. <!-- 空白页 -->
  29. <!-- #ifdef H5 -->
  30. <empty src="../../static/error/emptyItem.png"
  31. v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  32. <!-- #endif -->
  33. <!-- #ifndef H5 -->
  34. <empty src="../static/error/emptyItem.png"
  35. v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  36. <!-- #endif -->
  37. <!-- 订单列表 -->
  38. <view v-for="(item, index) in tabItem.orderList" :key="item.uid" class="andr-mt-lBox flex">
  39. <!-- 订单列表 -->
  40. <image :src="item.avatar" class="andr-mt-avatar andr-mt-marR20 flex-shrink-false" mode="scaleToFill"></image>
  41. <view class="andr-mt-fdC">
  42. <view class="andr-mt-lname flex-start">
  43. <text class="clamp padding-r-20">
  44. {{ item.nickname }}
  45. </text>
  46. <image v-if="item.level>0" class="tipLevel flex-shrink-false" :src="`../../static/image/level${item.level-1}.png`" mode="heightFix"></image>
  47. </view>
  48. <view class="andr-mt-ltime margin-t-10">{{ item.time }}</view>
  49. <view class="andr-mt-ltime margin-t-20">推广数:{{ item.childCount }}</view>
  50. </view>
  51. <view class="rightText">
  52. <view class="money">
  53. {{item.numberCount}}
  54. </view>
  55. <view class="allOrder margin-t-20">
  56. 消费{{item.orderCount}}单
  57. </view>
  58. </view>
  59. </view>
  60. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  61. </scroll-view>
  62. </swiper-item>
  63. </swiper>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. spreadPeople
  69. } from '@/api/user.js';
  70. import {
  71. userinfo
  72. } from '@/api/user.js';
  73. import {
  74. mapState,
  75. mapMutations
  76. } from 'vuex';
  77. import {
  78. getMoneyStyle
  79. } from '@/utils/rocessor.js';
  80. export default {
  81. filters: {
  82. getMoneyStyle
  83. },
  84. data() {
  85. return {
  86. // 查询key
  87. search: '',
  88. searchIndex: 0, //当前选中对象
  89. searchList: [{
  90. text: '团队排序',
  91. key: 'childCount DESC'
  92. },
  93. {
  94. text: '金额排序 ',
  95. key: 'numberCount DESC'
  96. },
  97. {
  98. text: '订单排序',
  99. key: 'orderCount DESC'
  100. }
  101. ],
  102. userInfo: {},
  103. // 头部图高度
  104. maxheight: '',
  105. tabCurrentIndex: 0,
  106. navList: [{
  107. state: 0,
  108. text: '一级团队',
  109. loadingType: 'more',
  110. num: 0, //人数
  111. orderList: [],
  112. page: 1, //当前页数
  113. limit: 10 //每次信息条数
  114. },
  115. {
  116. state: 1,
  117. text: '二级团队',
  118. num: 0, //团队人数
  119. loadingType: 'more',
  120. orderList: [],
  121. page: 1, //当前页数
  122. limit: 10 //每次信息条数
  123. }
  124. ],
  125. money: ''
  126. };
  127. },
  128. onLoad(options) {},
  129. onShow() {
  130. this.loadData();
  131. // 获取用户积分
  132. let obj = this;
  133. userinfo({})
  134. .then(({
  135. data
  136. }) => {
  137. console.log(data);
  138. obj.userInfo = data;
  139. })
  140. .catch(e => {});
  141. },
  142. methods: {
  143. // 页面跳转
  144. navto(e) {
  145. uni.navigateTo({
  146. url: e
  147. });
  148. },
  149. //获取收入支出信息
  150. async loadData(source) {
  151. let obj = this;
  152. //这里是将订单挂载到tab列表下
  153. let index = obj.tabCurrentIndex;
  154. let navItem = obj.navList[index];
  155. let state = navItem.state;
  156. if (source === 'tabChange' && navItem.loaded === true) {
  157. //tab切换只有第一次需要加载数据
  158. return;
  159. }
  160. if (navItem.loadingType === 'loading') {
  161. //防止重复加载
  162. return;
  163. }
  164. // 修改当前对象状态为加载中
  165. navItem.loadingType = 'loading';
  166. spreadPeople({
  167. page: navItem.page,
  168. limit: navItem.limit,
  169. grade: state,
  170. keyword: this.search,
  171. sort: this.searchList[this.tabCurrentIndex].key
  172. })
  173. .then(({
  174. data
  175. }) => {
  176. obj.navList[0].num = data.total;
  177. obj.navList[1].num = data.totalLevel;
  178. if (data.list.length > 0) {
  179. navItem.orderList = navItem.orderList.concat(data.list);
  180. console.log(navItem.orderList);
  181. navItem.page++;
  182. }
  183. if (navItem.limit == data.list.length) {
  184. //判断是否还有数据, 有改为 more, 没有改为noMore
  185. navItem.loadingType = 'more';
  186. return;
  187. } else {
  188. //判断是否还有数据, 有改为 more, 没有改为noMore
  189. navItem.loadingType = 'noMore';
  190. }
  191. uni.hideLoading();
  192. obj.$set(navItem, 'loaded', true);
  193. })
  194. .catch(e => {
  195. console.log(e);
  196. });
  197. },
  198. //swiper 切换
  199. changeTab(e) {
  200. this.tabCurrentIndex = e.target.current;
  201. this.loadData('tabChange');
  202. },
  203. //顶部tab点击
  204. tabClick(index) {
  205. this.tabCurrentIndex = index;
  206. },
  207. // 查询对象数据
  208. changeSearchList(e) {
  209. if (e) {
  210. this.searchIndex = e.detail.value;
  211. }
  212. // 重新初始化
  213. this.navList[tabCurrentIndex].page = 1;
  214. this.navList[tabCurrentIndex].limit = 10;
  215. this.navList[tabCurrentIndex].loadingType = 'more';
  216. this.navList[tabCurrentIndex].orderList = [];
  217. this.loadData()
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss">
  223. page {
  224. height: 100%;
  225. }
  226. .searchInput {
  227. padding: 0 30rpx;
  228. .searchBox {
  229. background-color: #FFFFFF;
  230. border-radius: 100rpx;
  231. padding: 0 30rpx;
  232. height: 70rpx;
  233. flex-grow: 1;
  234. .input {
  235. flex-grow: 1;
  236. padding: 0 20rpx;
  237. }
  238. .search {
  239. width: 36rpx;
  240. }
  241. .exit {
  242. width: 36rpx;
  243. }
  244. }
  245. .searchImg {
  246. height: 70rpx;
  247. width: 70rpx;
  248. justify-content: center;
  249. margin-left: 30rpx;
  250. border-radius: 20rpx;
  251. background-color: #FFFFFF;
  252. .searchList {
  253. width: 36rpx;
  254. }
  255. }
  256. }
  257. .money-box {
  258. background-color: $base-color;
  259. padding-top: var(--status-bar-height);
  260. // height: 368rpx;
  261. height: 180rpx;
  262. display: flex;
  263. flex-direction: column;
  264. align-items: center;
  265. justify-content: center;
  266. color: #ffffff;
  267. // text-align: center;
  268. .text {
  269. // padding-top: 147rpx;
  270. font-size: $font-sm;
  271. }
  272. .money {
  273. font-size: 56rpx;
  274. }
  275. }
  276. .navbar {
  277. display: flex;
  278. height: 40px;
  279. padding: 0 5px;
  280. background: #fff;
  281. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  282. position: relative;
  283. z-index: 10;
  284. .nav-item {
  285. flex: 1;
  286. display: flex;
  287. justify-content: center;
  288. align-items: center;
  289. height: 100%;
  290. font-size: 15px;
  291. color: $font-color-dark;
  292. position: relative;
  293. &.current {
  294. color: $base-color;
  295. &:after {
  296. content: '';
  297. position: absolute;
  298. left: 50%;
  299. bottom: 0;
  300. transform: translateX(-50%);
  301. width: 44px;
  302. height: 0;
  303. border-bottom: 2px solid $base-color;
  304. }
  305. }
  306. }
  307. }
  308. // 列表
  309. .swiper-box {
  310. padding-top: 10rpx;
  311. height: calc(100% - 40px);
  312. .order-item {
  313. padding: 20rpx 30rpx;
  314. line-height: 1.5;
  315. .title-box {
  316. .title {
  317. font-size: $font-lg;
  318. color: $font-color-base;
  319. }
  320. .time {
  321. font-size: $font-base;
  322. color: $font-color-light;
  323. }
  324. }
  325. .money {
  326. color: #fd5b23;
  327. font-size: $font-lg;
  328. }
  329. }
  330. }
  331. .list-scroll-content {
  332. height: 100%;
  333. padding-top: 30rpx;
  334. }
  335. .content {
  336. height: 100%;
  337. .empty-content {
  338. background-color: #ffffff;
  339. }
  340. }
  341. .andr-mt-avatar {
  342. width: 120rpx;
  343. height: 120rpx;
  344. border-radius: 10rpx;
  345. background-color: $font-color-light;
  346. }
  347. .andr-mt-avatarBd {
  348. border: 2px solid #ffffff;
  349. }
  350. .andr-mt-cname {
  351. font-size: 28rpx;
  352. color: #ffffff;
  353. }
  354. .andr-mt-flex {
  355. display: flex;
  356. }
  357. .andr-mt-lBox {
  358. background-color: #ffffff;
  359. padding: 30rpx;
  360. border-bottom: 1px solid #f0f0f0;
  361. margin: 30rpx;
  362. border-radius: 20rpx;
  363. }
  364. .andr-mt-marR20 {
  365. margin-right: 20rpx;
  366. }
  367. .andr-mt-fdC {
  368. flex-grow: 1;
  369. overflow: hidden;
  370. }
  371. .rightText {
  372. line-height: 1;
  373. .money {
  374. font-size: 36rpx;
  375. font-weight: bold;
  376. }
  377. .allOrder {
  378. font-size: 22rpx;
  379. color: $font-color-disabled;
  380. }
  381. }
  382. .andr-mt-lname {
  383. font-size: 32rpx;
  384. color: #3f454b;
  385. overflow: hidden;
  386. .tipLevel{
  387. height: 36rpx;
  388. margin-right: 20rpx;
  389. }
  390. }
  391. .andr-mt-ltime {
  392. line-height: 1;
  393. font-size: 22rpx;
  394. color: $font-color-disabled;
  395. }
  396. </style>