|
@@ -2,7 +2,7 @@
|
|
|
<Empty v-if="list.length === 0" description="暂无排名数据" />
|
|
<Empty v-if="list.length === 0" description="暂无排名数据" />
|
|
|
<FlexRow align="flex-end" justify="space-around">
|
|
<FlexRow align="flex-end" justify="space-around">
|
|
|
<Touchable
|
|
<Touchable
|
|
|
- v-for="(item) in list"
|
|
|
|
|
|
|
+ v-for="(item) in first3"
|
|
|
position="relative"
|
|
position="relative"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
:width="item.rank == 1 ? '35%' : '32.5%'"
|
|
:width="item.rank == 1 ? '35%' : '32.5%'"
|
|
@@ -15,7 +15,7 @@
|
|
|
}"
|
|
}"
|
|
|
direction="column"
|
|
direction="column"
|
|
|
overflow="hidden"
|
|
overflow="hidden"
|
|
|
- @click="emit('goDetails', item)"
|
|
|
|
|
|
|
+ @click="handleGoDetails(item)"
|
|
|
>
|
|
>
|
|
|
<FlexCol
|
|
<FlexCol
|
|
|
position="absolute"
|
|
position="absolute"
|
|
@@ -32,7 +32,7 @@
|
|
|
<Height :height="item.rank == 1 ? 15 : 10" />
|
|
<Height :height="item.rank == 1 ? 15 : 10" />
|
|
|
<Text fontConfig="h4" :text="item.title" :lines="1" color="white" />
|
|
<Text fontConfig="h4" :text="item.title" :lines="1" color="white" />
|
|
|
<Height :height="6" />
|
|
<Height :height="6" />
|
|
|
- <Text fontConfig="h2" :text="`${item.score}`" :fontSize="30" :color="scoreColors[item.rank - 1]" fontFamily="SongtiSCBlack" />
|
|
|
|
|
|
|
+ <Text fontConfig="h2" :text="item.score >= 0 ? `${item.score}` : '等你加入'" :fontSize="30" :color="scoreColors[item.rank - 1]" fontFamily="SongtiSCBlack" />
|
|
|
<Text fontFamily="SongtiSCBlack" :fontSize="18" :text="scoreSuffix" :color="scoreColors[item.rank - 1]" />
|
|
<Text fontFamily="SongtiSCBlack" :fontSize="18" :text="scoreSuffix" :color="scoreColors[item.rank - 1]" />
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
</Touchable>
|
|
</Touchable>
|
|
@@ -40,6 +40,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
|
|
+import { computed } from 'vue';
|
|
|
import Text from '@/components/basic/Text.vue';
|
|
import Text from '@/components/basic/Text.vue';
|
|
|
import Avatar from '@/components/display/Avatar.vue';
|
|
import Avatar from '@/components/display/Avatar.vue';
|
|
|
import Empty from '@/components/feedback/Empty.vue';
|
|
import Empty from '@/components/feedback/Empty.vue';
|
|
@@ -47,6 +48,15 @@ import Touchable from '@/components/feedback/Touchable.vue';
|
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
|
import FlexRow from '@/components/layout/FlexRow.vue';
|
|
import FlexRow from '@/components/layout/FlexRow.vue';
|
|
|
import Height from '@/components/layout/space/Height.vue';
|
|
import Height from '@/components/layout/space/Height.vue';
|
|
|
|
|
+import { ArrayUtils } from '@imengyu/imengyu-utils';
|
|
|
|
|
+
|
|
|
|
|
+export interface UserRankItem {
|
|
|
|
|
+ id: number;
|
|
|
|
|
+ image: string;
|
|
|
|
|
+ title: string;
|
|
|
|
|
+ rank: number;
|
|
|
|
|
+ score: number;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const scoreColors = [
|
|
const scoreColors = [
|
|
|
'#cb8833',
|
|
'#cb8833',
|
|
@@ -54,27 +64,41 @@ const scoreColors = [
|
|
|
'#cd7853',
|
|
'#cd7853',
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-withDefaults(defineProps<{
|
|
|
|
|
- list?: {
|
|
|
|
|
- id: number;
|
|
|
|
|
- image: string;
|
|
|
|
|
- title: string;
|
|
|
|
|
- rank: number;
|
|
|
|
|
- score: number;
|
|
|
|
|
- }[];
|
|
|
|
|
|
|
+const props = withDefaults(defineProps<{
|
|
|
|
|
+ list?: UserRankItem[];
|
|
|
scoreSuffix?: string;
|
|
scoreSuffix?: string;
|
|
|
}>(), {
|
|
}>(), {
|
|
|
list: () => [],
|
|
list: () => [],
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
const emit = defineEmits<{
|
|
|
- (e: 'goDetails', item: {
|
|
|
|
|
- id: number;
|
|
|
|
|
- image: string;
|
|
|
|
|
- title: string;
|
|
|
|
|
- rank: number;
|
|
|
|
|
- score: number;
|
|
|
|
|
- }): void;
|
|
|
|
|
|
|
+ (e: 'goDetails', item: UserRankItem): void;
|
|
|
}>();
|
|
}>();
|
|
|
|
|
|
|
|
|
|
+const first3 = computed(() => {
|
|
|
|
|
+ const list = props.list.concat();
|
|
|
|
|
+ if (list.length < 3) {
|
|
|
|
|
+ let rank = list.length;
|
|
|
|
|
+ for (let i = 0; i < 3 - list.length; i++) {
|
|
|
|
|
+ list.push({
|
|
|
|
|
+ id: -i,
|
|
|
|
|
+ image: 'https://xy.wenlvti.net/app_static/images/mine/DefaultAvatar.png',
|
|
|
|
|
+ title: '?',
|
|
|
|
|
+ rank: ++rank,
|
|
|
|
|
+ score: -1,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //移动第一名到中间
|
|
|
|
|
+ const first = list[0];
|
|
|
|
|
+ ArrayUtils.removeAt(list, 0);
|
|
|
|
|
+ ArrayUtils.insert(list, 1, first);
|
|
|
|
|
+ return list.slice(0, 3);
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+function handleGoDetails(item: UserRankItem) {
|
|
|
|
|
+ if (item.id <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ emit('goDetails', item)
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|