Showing
4 changed files
with
124 additions
and
53 deletions
@@ -5,11 +5,11 @@ | @@ -5,11 +5,11 @@ | ||
5 | <span class="total-wait-apply">收款清单</span> | 5 | <span class="total-wait-apply">收款清单</span> |
6 | <span><span class="wait-label">待收金额:</span><span class="wait-price-num">¥{{props.data.waitApplyCashAmount}}</span></span> | 6 | <span><span class="wait-label">待收金额:</span><span class="wait-price-num">¥{{props.data.waitApplyCashAmount}}</span></span> |
7 | </p> | 7 | </p> |
8 | - <slot><div class="no-data">暂无收款清单</div></slot> | 8 | + <slot name="waitApply"><div class="no-data">暂无收款清单</div></slot> |
9 | </div> | 9 | </div> |
10 | <div class="income-detail-header"> | 10 | <div class="income-detail-header"> |
11 | <p class="total-income">收入明细</p> | 11 | <p class="total-income">收入明细</p> |
12 | - <slot><div class="no-data">暂无收入明细</div></slot> | 12 | + <slot name="income"><div class="no-data">暂无收入明细</div></slot> |
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | </template> | 15 | </template> |
@@ -8,9 +8,16 @@ | @@ -8,9 +8,16 @@ | ||
8 | 8 | ||
9 | <incomeHeader :data="getAssetSummary" class="header-inner-padding"></incomeHeader> | 9 | <incomeHeader :data="getAssetSummary" class="header-inner-padding"></incomeHeader> |
10 | <payAccount class="inner-padding"></payAccount> | 10 | <payAccount class="inner-padding"></payAccount> |
11 | - <incomeDetail :data="incomeData"> | ||
12 | - <template v-for="(item,index) in incomeData.list"> | 11 | + <incomeDetail :data="assetData"> |
12 | + <template #waitApply> | ||
13 | + <div v-for="(item,index) in assetData.waitApplyInfo.list" :key="index"> | ||
13 | <incomeItem :item="item" :key="index"></incomeItem> | 14 | <incomeItem :item="item" :key="index"></incomeItem> |
15 | + </div> | ||
16 | + </template> | ||
17 | + <template #income> | ||
18 | + <div v-for="(item,index) in assetData.incomeInfo.list" :key="index"> | ||
19 | + <incomeItem :item="item" :key="index"></incomeItem> | ||
20 | + </div> | ||
14 | </template> | 21 | </template> |
15 | </incomeDetail> | 22 | </incomeDetail> |
16 | <!-- 自定义下拉刷新内容 --> | 23 | <!-- 自定义下拉刷新内容 --> |
@@ -29,21 +36,27 @@ import incomeItem from './components/incomeItem'; | @@ -29,21 +36,27 @@ import incomeItem from './components/incomeItem'; | ||
29 | import pullDown from './components/pullDown'; | 36 | import pullDown from './components/pullDown'; |
30 | import payAccount from './components/payAccount'; | 37 | import payAccount from './components/payAccount'; |
31 | import { createNamespacedHelpers } from 'vuex'; | 38 | import { createNamespacedHelpers } from 'vuex'; |
32 | -import {Style, Scroll} from 'cube-ui'; | 39 | +import {Style} from 'cube-ui'; |
33 | import scrollMixin from '../../../mixins/scroll'; | 40 | import scrollMixin from '../../../mixins/scroll'; |
34 | const {mapState, mapGetters, mapActions} = createNamespacedHelpers('home/mine'); | 41 | const {mapState, mapGetters, mapActions} = createNamespacedHelpers('home/mine'); |
42 | + | ||
35 | export default { | 43 | export default { |
36 | mixins: [scrollMixin], | 44 | mixins: [scrollMixin], |
37 | data() { | 45 | data() { |
38 | return { | 46 | return { |
39 | page: 0, | 47 | page: 0, |
40 | totalPage: 0 | 48 | totalPage: 0 |
41 | - } | 49 | + }; |
42 | }, | 50 | }, |
43 | - computed:{ | 51 | + computed: { |
44 | ...mapGetters(['getAssetSummary']), | 52 | ...mapGetters(['getAssetSummary']), |
45 | ...mapState({ | 53 | ...mapState({ |
46 | - incomeData: (state) => state.assetData | 54 | + assetData: (state) => state.assetData, |
55 | + isEnd: state => { | ||
56 | + const {incomeInfo} = state.assetData; | ||
57 | + | ||
58 | + return incomeInfo.isEnd; | ||
59 | + } | ||
47 | }), | 60 | }), |
48 | loadingOptions() { | 61 | loadingOptions() { |
49 | return { | 62 | return { |
@@ -55,35 +68,33 @@ export default { | @@ -55,35 +68,33 @@ export default { | ||
55 | created() { | 68 | created() { |
56 | }, | 69 | }, |
57 | activated() { | 70 | activated() { |
58 | - this.fetchAssetsAsync(true) | 71 | + this.fetchAssetsAsync(true); |
59 | }, | 72 | }, |
60 | watch: { | 73 | watch: { |
61 | - "incomeData.list": function(val) { | ||
62 | - if(val.length === 0) { | ||
63 | - this.options.pullUpLoad.txt.noMore = '' | ||
64 | - // this.$refs.scroll.disable() | 74 | + 'assetData.incomeInfo.list': function(val) { |
75 | + if (val.length === 0) { | ||
76 | + this.options.pullUpLoad.txt.noMore = ''; | ||
65 | } else { | 77 | } else { |
66 | - this.options.pullUpLoad.txt.noMore = '到底啦~' | ||
67 | - // this.$refs.scroll.enable() | 78 | + this.options.pullUpLoad.txt.noMore = '到底啦~'; |
68 | } | 79 | } |
69 | } | 80 | } |
70 | }, | 81 | }, |
71 | methods: { | 82 | methods: { |
72 | ...mapActions(['fetchAssets']), | 83 | ...mapActions(['fetchAssets']), |
73 | onPullingUp() { | 84 | onPullingUp() { |
74 | - if(!this.incomeData.endReached) { | ||
75 | - this.fetchAssetsAsync(false) | 85 | + if (!this.isEnd) { |
86 | + this.fetchAssetsAsync(false); | ||
76 | } else { | 87 | } else { |
77 | - this.$refs.scroll.forceUpdate() | 88 | + this.$refs.scroll.forceUpdate(); |
78 | } | 89 | } |
79 | }, | 90 | }, |
80 | fetchAssetsAsync(reFetch) { | 91 | fetchAssetsAsync(reFetch) { |
81 | return this.fetchAssets(reFetch).then(res => { | 92 | return this.fetchAssets(reFetch).then(res => { |
82 | - if (res.code === 200) { | ||
83 | - let { page, pagetotal } = res.data || {}; | 93 | + if (res) { |
94 | + let { currentPage, totalPage } = res || {}; | ||
84 | 95 | ||
85 | - this.page = page || 0; | ||
86 | - this.totalPage = pagetotal || 0; | 96 | + this.page = currentPage || 0; |
97 | + this.totalPage = totalPage || 0; | ||
87 | } | 98 | } |
88 | }); | 99 | }); |
89 | } | 100 | } |
@@ -24,14 +24,24 @@ export default function() { | @@ -24,14 +24,24 @@ export default function() { | ||
24 | askBuyNum: 0, | 24 | askBuyNum: 0, |
25 | couponNum: 0, | 25 | couponNum: 0, |
26 | assetData: { | 26 | assetData: { |
27 | - isFetching: false, | ||
28 | - list: [], | ||
29 | - currentPage: 1, | ||
30 | - pageSize: 20, | ||
31 | - endReached: false, | ||
32 | compensateIncome: '¥0.00', | 27 | compensateIncome: '¥0.00', |
33 | goodsIncome: '¥0.00', | 28 | goodsIncome: '¥0.00', |
34 | totalIncome: '¥0.00', | 29 | totalIncome: '¥0.00', |
30 | + waitApplyCashAmount: '0.00', | ||
31 | + waitApplyInfo: { | ||
32 | + isEnd: false, | ||
33 | + currentPage: 1, | ||
34 | + pageSize: 20, | ||
35 | + totalPage: 0, | ||
36 | + list: [] | ||
37 | + }, | ||
38 | + incomeInfo: { | ||
39 | + isEnd: false, | ||
40 | + currentPage: 1, | ||
41 | + pageSize: 20, | ||
42 | + totalPage: 0, | ||
43 | + list: [] | ||
44 | + } | ||
35 | }, | 45 | }, |
36 | walletData: { | 46 | walletData: { |
37 | isFetching: false, | 47 | isFetching: false, |
@@ -293,6 +303,18 @@ export default function() { | @@ -293,6 +303,18 @@ export default function() { | ||
293 | state.resource1 = Object.assign({}, state.resource1, resource1); | 303 | state.resource1 = Object.assign({}, state.resource1, resource1); |
294 | state.resource2 = Object.assign({}, state.resource1, resource2); | 304 | state.resource2 = Object.assign({}, state.resource1, resource2); |
295 | }, | 305 | }, |
306 | + | ||
307 | + setAssetStatisticalInfo(state, summary = {}) { | ||
308 | + const {compensateIncome, goodsIncome, totalIncome, waitApplyCashAmount} = summary; | ||
309 | + | ||
310 | + state.assetData.compensateIncome = formatNumber(compensateIncome || 0); | ||
311 | + state.assetData.goodsIncome = formatNumber(goodsIncome || 0); | ||
312 | + state.assetData.totalIncome = formatNumber(totalIncome || 0); | ||
313 | + state.assetData.waitApplyCashAmount = waitApplyCashAmount; | ||
314 | + }, | ||
315 | + setAssets(state, assetsInfo = {}) { | ||
316 | + state.assetData = {...state.assetData, ...assetsInfo}; | ||
317 | + } | ||
296 | }, | 318 | }, |
297 | actions: { | 319 | actions: { |
298 | async fetchRollBoardList({ commit }) { | 320 | async fetchRollBoardList({ commit }) { |
@@ -379,38 +401,82 @@ export default function() { | @@ -379,38 +401,82 @@ export default function() { | ||
379 | commit('addCouponSummary', { count: result.data }); | 401 | commit('addCouponSummary', { count: result.data }); |
380 | } | 402 | } |
381 | }, | 403 | }, |
382 | - async fetchAssets({ commit, state }, isRefresh) { | ||
383 | - let { | ||
384 | - isFetching, | ||
385 | - endReached, | ||
386 | - currentPage, | ||
387 | - list, | ||
388 | - pageSize, | ||
389 | - } = state.assetData; | 404 | + async fetchAssets({state, dispatch}, isRefresh) { |
405 | + const {incomeInfo, waitApplyInfo} = state.assetData; | ||
390 | 406 | ||
391 | - if (isFetching || (!isRefresh && endReached)) { | 407 | + if (!isRefresh && waitApplyInfo.isEnd && incomeInfo.isEnd) { |
392 | return; | 408 | return; |
393 | } | 409 | } |
394 | - let oldList = isRefresh ? [] : list; | ||
395 | 410 | ||
396 | - // commit('assetFetching', {isFetching: true}); | ||
397 | - let page = isRefresh ? 1 : currentPage + 1; | 411 | + if (waitApplyInfo.isEnd) { |
412 | + const res = await dispatch('fetchInComeAssets'); | ||
413 | + | ||
414 | + return res; | ||
415 | + } else { | ||
416 | + const res = await dispatch('fetchWaitApplyAssets', isRefresh); | ||
417 | + | ||
418 | + return res; | ||
419 | + } | ||
420 | + }, | ||
421 | + | ||
422 | + async fetchInComeAssets({commit, state}, isRefresh) { | ||
423 | + let {currentPage, list, pageSize} = state.assetData.incomeInfo; | ||
424 | + | ||
425 | + const page = isRefresh ? 1 : currentPage + 1; | ||
426 | + | ||
427 | + if (isRefresh) { | ||
428 | + list = []; | ||
429 | + } | ||
430 | + | ||
431 | + const result = await this.$api.get('/api/ufo/mine/assets', { | ||
432 | + type: 2, | ||
433 | + page, | ||
434 | + limit: pageSize, | ||
435 | + }); | ||
436 | + | ||
437 | + if (result.code === 200) { | ||
438 | + let assetData = parseAssetList(result.data); | ||
439 | + | ||
440 | + assetData.list = [...list, ...assetData.list]; | ||
441 | + | ||
442 | + commit('setAssetStatisticalInfo', result.data.summary); | ||
443 | + commit('setAssets', {incomeInfo: assetData}); | ||
444 | + | ||
445 | + return assetData; | ||
446 | + } | ||
447 | + }, | ||
448 | + | ||
449 | + async fetchWaitApplyAssets({commit, state, dispatch}, isRefresh) { | ||
450 | + let {currentPage, list, pageSize} = state.assetData.waitApplyInfo; | ||
451 | + | ||
452 | + const page = isRefresh ? 1 : currentPage + 1; | ||
453 | + | ||
454 | + if (isRefresh) { | ||
455 | + list = []; | ||
456 | + } | ||
457 | + | ||
398 | const result = await this.$api.get('/api/ufo/mine/assets', { | 458 | const result = await this.$api.get('/api/ufo/mine/assets', { |
399 | type: 1, | 459 | type: 1, |
400 | page, | 460 | page, |
401 | limit: pageSize, | 461 | limit: pageSize, |
402 | }); | 462 | }); |
403 | 463 | ||
404 | - // commit('assetFetching', {isFetching: false}); | ||
405 | if (result.code === 200) { | 464 | if (result.code === 200) { |
406 | let assetData = parseAssetList(result.data); | 465 | let assetData = parseAssetList(result.data); |
407 | - let newList = [...oldList, ...assetData.list]; | ||
408 | 466 | ||
409 | - assetData.list = newList; | ||
410 | - commit('addAssets', assetData); | 467 | + assetData.list = [...list, ...assetData.list]; |
468 | + | ||
469 | + commit('setAssetStatisticalInfo', result.data.summary); | ||
470 | + commit('setAssets', {waitApplyInfo: assetData}); | ||
471 | + | ||
472 | + if (assetData.isEnd) { | ||
473 | + const res = await dispatch('fetchInComeAssets', isRefresh); | ||
474 | + | ||
475 | + return res; | ||
411 | } | 476 | } |
412 | 477 | ||
413 | - return result; | 478 | + return assetData; |
479 | + } | ||
414 | }, | 480 | }, |
415 | 481 | ||
416 | async applyCash(_, id) { | 482 | async applyCash(_, id) { |
@@ -5,7 +5,6 @@ export function parseAssetList(json) { | @@ -5,7 +5,6 @@ export function parseAssetList(json) { | ||
5 | data, | 5 | data, |
6 | page, | 6 | page, |
7 | pagetotal, | 7 | pagetotal, |
8 | - summary | ||
9 | } = json; | 8 | } = json; |
10 | let parsedList = data ? data.map((item) => { | 9 | let parsedList = data ? data.map((item) => { |
11 | let price = ''; | 10 | let price = ''; |
@@ -40,19 +39,14 @@ export function parseAssetList(json) { | @@ -40,19 +39,14 @@ export function parseAssetList(json) { | ||
40 | isWaitApply: item.links.includes('applyCash') | 39 | isWaitApply: item.links.includes('applyCash') |
41 | }; | 40 | }; |
42 | }) : []; | 41 | }) : []; |
43 | - let endReached = parsedList.length === 0 || page === pagetotal; | 42 | + let isEnd = parsedList.length === 0 || page === pagetotal; |
44 | let dealedList = { | 43 | let dealedList = { |
45 | currentPage: page, | 44 | currentPage: page, |
45 | + totalPage: pagetotal, | ||
46 | list: parsedList, | 46 | list: parsedList, |
47 | - endReached, | 47 | + isEnd, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | - if (summary) { | ||
51 | - dealedList.compensateIncome = summary.compensateIncome; | ||
52 | - dealedList.goodsIncome = summary.goodsIncome; | ||
53 | - dealedList.totalIncome = summary.totalIncome; | ||
54 | - dealedList.waitApplyCashAmount = summary.waitApplyCashAmount; | ||
55 | - } | ||
56 | return dealedList; | 50 | return dealedList; |
57 | } | 51 | } |
58 | export function formatNumber(number) { | 52 | export function formatNumber(number) { |
-
Please register or login to post a comment