donateList.vue
4.82 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
<!--
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-30 13:51:47
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-01 15:02:10
* @FilePath: /tswj/src/views/client/donateList.vue
* @Description: 幼儿园捐赠人捐赠金额排行榜
-->
<template>
<div class="wrapper">
<van-row>
<van-col span="18" style="padding: 1rem 0.5rem 1rem 0;">
<div :class="[kgInfo.multi_name ? 'heightHigh' : 'heightLow', 'kg-name']">
<van-row align="center" justify="center" style="position: relative; top: 50%; transform: translateY(-50%);">
<van-col span="4">
<van-image round width="4rem" height="4rem" :src="kgInfo.kg_logo ? kgInfo.kg_logo : icon_logo" style="vertical-align: text-bottom;" />
</van-col>
<van-col span="20">
<div v-if="kgInfo.multi_name" style="margin-left: 1.5rem;">
<p>{{ kgInfo.multi_name[0] }}</p>
<p>{{ kgInfo.multi_name[1] }}</p>
</div>
<p v-else style="margin-left: 1.5rem;">
{{ kgInfo.kg_name }}
</p>
</van-col>
</van-row>
</div>
</van-col>
<van-col span="6">
<div class="flower">
<van-icon :name="icon_flower" color="#c5c5c5" size="1.5rem" style="vertical-align: bottom;" /> {{ kgInfo.kg_total }}
</div>
</van-col>
</van-row>
</div>
<van-list v-model:loading="loading" :finished="finished" :finished-text="finishedTextStatus ? '没有更多了' : ''" :immediate-check="false" @load="onLoad">
<template v-for="(item, key) in donateList" :key="key">
<div class="van-hairline--bottom">
<van-row style="padding: 0.5rem 1rem;">
<van-col span="4">
<van-image round width="3rem" height="3rem" :src="item.avatar ? item.avatar : icon_avatar" />
</van-col>
<van-col span="14">
<div class="name-info glob-center">
<p>{{ item.name }}</p>
<p style="color: #C5C5C5;">{{ item.donate_time }}</p>
</div>
</van-col>
<van-col span="6" style="color: #222222; text-align: right; font-size: 1rem;">
<div class="glob-center">
<van-icon style="vertical-align: top;" size="1.25rem" :name="icon_flower" />
<span> 2</span>
</div>
</van-col>
</van-row>
</div>
</template>
</van-list>
<van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无明细" />
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
//import { } from '@/utils/generateModules.js'
import { icon_avatar, no_image, icon_flower, icon_logo } from '@/utils/generateIcons.js'
//import { } from '@/composables'
import { kgDonateListAPI } from '@/api/C/kg.js'
const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);
const kgInfo = ref({});
const kg_id = $route.query.kg_id;
const donateList = ref([])
const loading = ref(false)
const finished = ref(false)
const limit = ref(10)
const offset = ref(0)
const finishedTextStatus = ref(false);
const emptyStatus = ref(false);
onMounted(async () => {
const { data } = await kgDonateListAPI({ kg_id, limit: limit.value, offset: offset.value });
kgInfo.value = data;
donateList.value = data.donate_list;
offset.value = donateList.value.length;
// 有空格分割name
if (kgInfo.value.kg_name.indexOf(' ') > -1) {
kgInfo.value.multi_name = kgInfo.value.kg_name.split(' ');
}
})
const onLoad = async () => {
const { data } = await kgDonateListAPI({ kg_id, limit: limit.value, offset: offset.value });
donateList.value = [...donateList.value, ...data.donate_list];
// donateList.value = _.uniqBy(donateList.value, 'id');
offset.value = donateList.value.length;
loading.value = false;
// 数据全部加载完成
if (!data.donate_list.length) {
// 加载状态结束
finished.value = true;
}
if (!donateList.value.length) {
finishedTextStatus.value = false;
emptyStatus.value = true;
}
}
</script>
<style lang="less" scoped>
.wrapper {
padding-left: 0.5rem;
padding-right: 1rem;
background-color: #F7F7F7;
position: relative;
.rank {
position: relative;
.avatar {
position: absolute;
top: 0;
left: 20%;
}
.text {
position: absolute;
top: 0.5rem;
left: 40%;
color: #84909F;
}
}
.flower {
text-align: center;
position: absolute;
top: 40%;
right: 1rem;
color: #713610;
font-size: 1.25rem;
}
.kg-name {
position: relative;
height: 3rem;
}
.heightLow {
height: 3rem;
}
.heightHigh {
height: 6rem;
}
}
</style>