myfans.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="content">
  3. <view class="content-money flex">
  4. <view class="money-box">
  5. <view class="money">{{ userInfo.spread_count|| '0' }}</view>
  6. <view>我的推广人数</view>
  7. </view>
  8. <view class="money-box">
  9. <view class="money">{{ userInfo.achievement|| '0' }}</view>
  10. <view>总业绩</view>
  11. </view>
  12. </view>
  13. <!-- <view class="time-in">
  14. <picker mode="date" @change="bindStartDateChange">
  15. <input type="text" v-model="start_time" class="showtime" placeholder="请输入开始时间" disabled>
  16. </picker>
  17. <picker mode="date" @change="bindEndDateChange">
  18. <input type="text" v-model="end_time" class="showtime" placeholder="请输入结束时间" disabled>
  19. </picker>
  20. <view class="search" @click="loadData('reload')">
  21. 搜索
  22. </view>
  23. </view> -->
  24. <!-- <view class="flex buttom-box">
  25. <view class="buttom" @click="tabClick(0)">
  26. <view class="money">{{all || 0}}</view>
  27. <text class="text" :class="{ current: tabCurrentIndex === 0 }">一级推广</text>
  28. </view>
  29. <view class="buttom" @click="tabClick(1)">
  30. <view class="money">{{totalLevel || 0}}</view>
  31. <text class="text" :class="{ current: tabCurrentIndex === 1 }">二级推广</text>
  32. </view>
  33. </view> -->
  34. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300"
  35. @change="changeTab" disable-touch>
  36. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  37. <scroll-view class="list-scroll-content" :style="{ height: maxheight }" scroll-y>
  38. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  39. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  40. <view class="title-box flex_item">
  41. <view class="title-avatar">
  42. <image :src="item.avatar"></image>
  43. </view>
  44. <view class="list_tpl">
  45. <view class="title">
  46. <view class="title-name clamp">{{ item.nickname }}</view>
  47. </view>
  48. <view class="time">
  49. <text>{{item.phone}}</text>
  50. </view>
  51. <view class="time">
  52. <text>订单数:{{item.orderCount || '0'}} 消费金额:{{item.numberCount || '0'}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  58. </scroll-view>
  59. </swiper-item>
  60. </swiper>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. getMyfans,
  66. } from '@/api/user.js';
  67. import empty from '@/components/empty';
  68. import {
  69. mapState,
  70. mapMutations
  71. } from 'vuex';
  72. export default {
  73. components: {
  74. empty
  75. },
  76. onReady(res) {
  77. var _this = this;
  78. uni.getSystemInfo({
  79. success: resu => {
  80. const query = uni.createSelectorQuery();
  81. query.select('.swiper-box').boundingClientRect();
  82. query.exec(function(res) {
  83. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  84. console.log('打印页面的剩余高度', _this.height);
  85. });
  86. },
  87. fail: res => {}
  88. });
  89. },
  90. data() {
  91. return {
  92. // 头部图高度
  93. maxheight: '',
  94. tabCurrentIndex: 0,
  95. navList: [{
  96. state: 0,
  97. text: '直接推荐',
  98. loadingType: 'more',
  99. orderList: [],
  100. page: 1, //当前页数
  101. limit: 10 ,//每次信息条数
  102. loaded: false
  103. },
  104. {
  105. state: 1,
  106. text: '间接推荐',
  107. loadingType: 'more',
  108. orderList: [],
  109. page: 1, //当前页数
  110. limit: 10 ,//每次信息条数
  111. loaded: false
  112. }
  113. ],
  114. all: '',
  115. list: '',
  116. totalLevel: '',
  117. order: '',
  118. zt_order: '',
  119. jt_order: '',
  120. teamcount: '',
  121. ztcount: '',
  122. start_time: '',
  123. end_time: ''
  124. };
  125. },
  126. computed: {
  127. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  128. ...mapState(['baseURL'])
  129. },
  130. onLoad(options) {},
  131. onShow() {
  132. this.loadData();
  133. },
  134. methods: {
  135. bindStartDateChange(e) {
  136. console.log(e)
  137. this.start_time = e.detail.value
  138. },
  139. bindEndDateChange(e) {
  140. console.log(e)
  141. this.end_time = e.detail.value
  142. },
  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 = this.tabCurrentIndex;
  154. let navItem = this.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. if(source == 'reload') {
  165. navItem.orderList = []
  166. }
  167. // if (navItem.loadingType === 'noMore') {
  168. // //防止重复加载
  169. // return;
  170. // }
  171. // 修改当前对象状态为加载中
  172. navItem.loadingType = 'loading';
  173. getMyfans({
  174. page: navItem.page,
  175. limit: navItem.limit,
  176. grade: navItem.state
  177. })
  178. .then(({
  179. data
  180. }) => {
  181. navItem.orderList = navItem.orderList.concat(data.list)
  182. if(data.list.lenght == navItem.limit) {
  183. navItem.loadingType = 'more'
  184. }else {
  185. navItem.loadingType = 'noMore'
  186. }
  187. navItem.loaded = true
  188. // console.log(data);
  189. // this.teamcount = data.team_count
  190. // this.ztcount = data.zt_count
  191. // this.order = data.order
  192. // this.zt_order = data.zt_order
  193. // this.jt_order = data.jt_order
  194. // this.totalLevel = data.totalLevel
  195. // navItem.orderList = data.list;
  196. // navItem.loadingType = 'noMore'
  197. })
  198. .catch(e => {
  199. console.log(e);
  200. });
  201. },
  202. //swiper 切换
  203. changeTab(e) {
  204. this.tabCurrentIndex = e.target.current;
  205. this.loadData('tabChange');
  206. },
  207. //顶部tab点击
  208. tabClick(index) {
  209. this.tabCurrentIndex = index;
  210. },
  211. // 点击返回 我的页面
  212. toBack() {
  213. uni.switchTab({
  214. url: '/pages/user/user'
  215. });
  216. }
  217. }
  218. };
  219. </script>
  220. <style lang="scss">
  221. page {
  222. background: #f8f8f8;
  223. height: 100%;
  224. }
  225. .status_bar {
  226. height: var(--status-bar-height);
  227. width: 100%;
  228. background: #5dbc7c;
  229. }
  230. .content-money {
  231. position: relative;
  232. justify-content: space-around;
  233. padding-bottom: 40rpx;
  234. .body-title {
  235. height: 80rpx;
  236. text-align: center;
  237. font-size: 35rpx;
  238. position: relative;
  239. .header {
  240. position: absolute;
  241. left: 0;
  242. top: 0;
  243. width: 100%;
  244. font-size: 36rpx;
  245. font-family: PingFang SC;
  246. font-weight: bold;
  247. color: #6B4216;
  248. height: 80rpx;
  249. font-size: 36rpx;
  250. font-weight: 700;
  251. z-index: 9;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. }
  256. .goback-box {
  257. position: absolute;
  258. left: 18rpx;
  259. top: 0;
  260. height: 80rpx;
  261. display: flex;
  262. align-items: center;
  263. }
  264. .goback {
  265. z-index: 100;
  266. width: 34rpx;
  267. height: 34rpx;
  268. }
  269. }
  270. }
  271. .money-box {
  272. position: relative;
  273. z-index: 2;
  274. padding-top: 90rpx;
  275. color: #6B4216;
  276. text-align: center;
  277. .money {
  278. font-size: 72rpx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #6B4216;
  282. }
  283. .text {
  284. font-size: 30rpx;
  285. }
  286. }
  287. .order-item {
  288. padding: 20rpx 30rpx;
  289. line-height: 1.5;
  290. background-color: #fff;
  291. margin: 0rpx 30rpx 30rpx 30rpx;
  292. border-radius: 10rpx;
  293. .title-box {
  294. width: 100%;
  295. .title-avatar {
  296. flex-shrink: 0;
  297. width: 100rpx;
  298. height: 100rpx;
  299. margin-right: 25rpx;
  300. border-radius: 100%;
  301. image {
  302. width: 100%;
  303. height: 100%;
  304. border-radius: 100%;
  305. }
  306. }
  307. .list_tpl {
  308. width: 85%;
  309. .title {
  310. display: flex;
  311. justify-content: flex-start;
  312. font-size: $font-lg;
  313. color: $font-color-base;
  314. overflow: hidden; //超出的文本隐藏
  315. text-overflow: ellipsis; //溢出用省略号显示
  316. white-space: nowrap;
  317. line-height: 1;
  318. text-align: center;
  319. .title-name {
  320. max-width: 40%;
  321. }
  322. .dl {
  323. margin-left: 10rpx;
  324. width: 93rpx;
  325. height: 32rpx;
  326. border-radius: 16rpx;
  327. image {
  328. width: 93rpx;
  329. height: 32rpx;
  330. border-radius: 16rpx;
  331. }
  332. }
  333. .class {
  334. display: inline-block;
  335. margin-left: 10rpx;
  336. padding: 6rpx;
  337. text-align: center;
  338. border: 1px solid #2e58ff;
  339. border-radius: 16rpx;
  340. font-size: 20rpx;
  341. font-family: PingFang SC;
  342. font-weight: 500;
  343. color: #2e58ff;
  344. }
  345. }
  346. .time {
  347. font-size: $font-lg;
  348. color: $font-color-light;
  349. }
  350. }
  351. }
  352. .money {
  353. width: 50%;
  354. text-align: right;
  355. color: #db1935;
  356. font-size: $font-lg;
  357. }
  358. }
  359. .yeji {
  360. position: relative;
  361. margin: -72rpx auto 0;
  362. width: 690rpx;
  363. height: 143rpx;
  364. background: #ffffff;
  365. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  366. border-radius: 10rpx;
  367. display: flex;
  368. align-items: center;
  369. .yeji-a {
  370. width: 50%;
  371. display: flex;
  372. flex-direction: column;
  373. justify-content: center;
  374. align-items: center;
  375. .yeji-top {
  376. font-size: 28rpx;
  377. font-family: PingFang SC;
  378. font-weight: bold;
  379. color: #333333;
  380. }
  381. .yeji-buttom {
  382. font-size: 42rpx;
  383. font-family: PingFang SC;
  384. font-weight: bold;
  385. color: #333333;
  386. }
  387. }
  388. .border {
  389. width: 1rpx;
  390. height: 51rpx;
  391. background: #dddddd;
  392. }
  393. }
  394. .navbar {
  395. margin-top: 20rpx;
  396. display: flex;
  397. height: 88rpx;
  398. padding: 0 5px;
  399. background: #fff;
  400. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  401. position: relative;
  402. z-index: 10;
  403. .nav-item {
  404. flex: 1;
  405. display: flex;
  406. justify-content: center;
  407. align-items: center;
  408. height: 100%;
  409. font-size: 15px;
  410. color: #999999;
  411. position: relative;
  412. &.current {
  413. color: #000;
  414. &:after {
  415. content: '';
  416. position: absolute;
  417. left: 50%;
  418. bottom: 0;
  419. transform: translateX(-50%);
  420. width: 44px;
  421. height: 0;
  422. border-bottom: 2px solid #fe5b38;
  423. }
  424. }
  425. }
  426. }
  427. .buttom-box {
  428. position: relative;
  429. background-color: #ffffff;
  430. text-align: center;
  431. padding: 30rpx 0;
  432. .buttom {
  433. flex-grow: 1;
  434. }
  435. .money {
  436. font-size: 32rpx;
  437. font-weight: bold;
  438. color: #ff4173;
  439. }
  440. .text {
  441. padding-bottom: 26rpx;
  442. font-size: 28rpx;
  443. font-weight: 500;
  444. color: #666666;
  445. &.current {
  446. border-bottom: 2px solid #ff4173;
  447. }
  448. }
  449. .icon {
  450. height: 50rpx;
  451. width: 48rpx;
  452. margin: 0 auto;
  453. .icon-img {
  454. width: 100%;
  455. height: 100%;
  456. }
  457. }
  458. }
  459. .time-in {
  460. display: flex;
  461. margin-top: 20rpx;
  462. height: 100rpx;
  463. justify-content: space-around;
  464. align-items: center;
  465. background-color: #fff;
  466. .showtime {
  467. display: inline-block;
  468. width: 300rpx;
  469. height: 85rpx;
  470. background-color: #eee;
  471. border: 1px solid #999;
  472. border-radius: 20rpx;
  473. color: #000;
  474. font-size: 32rpx;
  475. padding-left: 20rpx;
  476. }
  477. .search {
  478. width: 100rpx;
  479. height: 50rpx;
  480. border-radius: 50rpx;
  481. background-color: #ff4575;
  482. font-size: 32rpx;
  483. text-align: center;
  484. line-height: 50rpx;
  485. color: #fff;
  486. }
  487. }
  488. </style>