tradeIncome.vue
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<LayoutApp :show-back="true" title="我的收入">
<div class="body" ref="body">
<LayoutScroll
ref="scroll"
:loading="loadingOptions"
@pulling-up="onPullingUp">
<incomeHeader :data="getAssetSummary"></incomeHeader>
<payAccount></payAccount>
<incomeDetail :data="incomeData">
<template v-for="(item,index) in incomeData.list">
<incomeItem :data="item" :key="index"></incomeItem>
</template>
</incomeDetail>
<!-- 自定义下拉刷新内容 -->
<!-- <template v-if="customPullDown" slot="pulldown" slot-scope="props">
<pullDown :propsData="props" :pullDownRefreshThreshold="pullDownRefreshThreshold"></pullDown>
</template> -->
</LayoutScroll>
</div>
</LayoutApp>
</template>
<script>
import incomeHeader from './components/incomeHeader';
import incomeDetail from './components/incomeDetail';
import incomeItem from './components/incomeItem';
import pullDown from './components/pullDown';
import payAccount from './components/payAccount';
import { createNamespacedHelpers } from 'vuex';
import {Style, Scroll} from 'cube-ui';
import scrollMixin from '../../../mixins/scroll';
const {mapState, mapGetters, mapActions} = createNamespacedHelpers('home/mine');
export default {
mixins: [scrollMixin],
data() {
return {
page: 0,
totalPage: 0
}
},
computed:{
...mapGetters(['getAssetSummary']),
...mapState({
incomeData: (state) => state.assetData
}),
loadingOptions() {
return {
hide: !this.totalPage,
noMore: this.page >= this.totalPage
};
}
},
created() {
},
activated() {
this.fetchAssetsAsync(true)
},
watch: {
"incomeData.list": function(val) {
if(val.length === 0) {
this.options.pullUpLoad.txt.noMore = ''
// this.$refs.scroll.disable()
} else {
this.options.pullUpLoad.txt.noMore = '到底啦~'
// this.$refs.scroll.enable()
}
}
},
methods: {
...mapActions(['fetchAssets']),
onPullingUp() {
if(!this.incomeData.endReached) {
this.fetchAssetsAsync(false)
} else {
this.$refs.scroll.forceUpdate()
}
},
fetchAssetsAsync(reFetch) {
return this.fetchAssets(reFetch).then(res => {
if (res.code === 200) {
let { page, pagetotal } = res.data || {};
this.page = page || 0;
this.totalPage = pagetotal || 0;
}
});
}
},
components: {
incomeHeader,
incomeDetail,
incomeItem,
pullDown,
payAccount,
Style
}
};
</script>
<style lang="scss" scoped>
.body {
height: 100%;
overflow-y: auto;
background-color: white;
padding: 0 40px;
color: #999;
}
</style>