list.vue
4.15 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<template>
<div class="list-wrapper">
<div class="header-wrapper header-padding" v-if="fixed">
<div class="header">
<div style="width: 25%; text-align: left;">我邀请的好友</div>
<div class="register-time">注册时间</div>
<div style="width: 20%; text-align: right;">我的佣金</div>
</div>
</div>
<Scroll ref="scroll" class="list" :options="scrollOptions" :scrollEvents="['scroll']" :data="list"
@scroll="scroll"
@pulling-up="onPullingUp">
<Banner ref="banner"></Banner>
<div class="list-comp" ref="header">
<div class="title">邀请记录</div>
<div class="header-wrapper">
<div class="header">
<div style="width: 25%; text-align: left;">我邀请的好友</div>
<div class="register-time">注册时间</div>
<div style="width: 20%; text-align: right;">我的佣金</div>
</div>
</div>
</div>
<template v-if="list.length">
<div class="item" v-for="item in list">
<div class="name"
style="width: 25%; text-align: center; text-overflow:ellipsis; overflow: hidden; white-space: nowrap;">
{{item.nickname}}
</div>
<div class="register-time">{{item.dateStr}}</div>
<div class="amount" style="width: 20%; text-align: center;">{{item.amountStr}}</div>
</div>
</template>
<div class="empty" v-else>
快去邀请好友吧!
</div>
<div class="footer">
</div>
</Scroll>
</div>
</template>
<script>
import { Scroll } from 'cube-ui';
import Banner from './banner';
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapActions } = createNamespacedHelpers('order');
export default {
data() {
return {
scrollOptions: {
bounce: {
top: false
},
pullUpLoad: true
},
fixed: false
};
},
mounted() {
this.fetchList();
this.fetchResource().then(() => {
this.$nextTick(() => {
this.$refs.scroll.$forceUpdate();
});
});
},
methods: {
...mapActions(['fetchList', 'fetchResource']),
async onPullingUp() {
const result = await this.fetchList();
if (!result) {
this.$refs.scroll.$forceUpdate();
}
},
scroll({ y }) {
const height = this.$refs.banner.$el.offsetHeight + this.$refs.header.offsetHeight;
if (-y >= height) {
this.fixed = true;
} else {
this.fixed = false;
}
}
},
computed: {
...mapState(['list']),
},
components: {
Scroll,
Banner
}
};
</script>
<style lang="scss" scoped>
.list-comp {
padding: 40px 30px 0 30px;
}
.header-padding {
margin: 0 30px 0 30px;
z-index: 100;
background-color: white;
width: calc(100% - 60px);
}
.list-wrapper {
height: 100%;
}
.list-comp {
height: 100%;
}
.title {
font-size: 34px;
color: #222;
text-align: center;
font-weight: bold;
margin-bottom: 20px;
}
.header-wrapper {
position: relative;
height: 100px;
}
.header {
display: flex;
font-size: 28px;
color: #b0b0b0;
justify-content: space-between;
height: 100px;
line-height: 100px;
.fixed {
position: absolute;
}
}
.header:before {
content: " ";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1px;
border-top: 1px solid #b0b0b0;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.register-time {
position: absolute;
width: 100%;
text-align: center;
}
.list {
height: 100%;
}
.item {
height: 100px;
font-size: 28px;
color: #444;
display: flex;
border-bottom: 0.5PX solid #e0e0e0;
line-height: 100px;
position: relative;
justify-content: space-between;
margin: 0 30px 0 30px;
}
.empty {
width: 100%;
height: 150px;
font-size: 28px;
color: #b0b0b0;
line-height: 150px;
text-align: center;
}
.footer {
height: 98px;
width: 100%;
}
</style>