This commit is contained in:
@jyuhsin
2025-05-06 19:40:35 +08:00
parent c60ec90770
commit 6f5f6b8076
5 changed files with 55 additions and 8 deletions
+38 -6
View File
@@ -1,5 +1,10 @@
<template>
<view class="page-container">
<t-dropdown-menu class="top-dropdown">
<t-dropdown-item :options="actOptions" :value="activityId"/>
</t-dropdown-menu>
<view class="rank-header">
<view class="title-container">
<view class="title">活动排行榜</view>
@@ -75,17 +80,27 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import {ref, onMounted, computed} from 'vue';
import { Toast } from 'tdesign-mobile-vue';
import { useRequest } from "@/utils/request";
import {onLoad} from "@dcloudio/uni-app";
// 排行榜数据
const actList = ref([])
const rankList = ref([]);
const activityId = ref([]);
const activityId = ref(null);
const loading = ref(false);
const refresherTriggered = ref(false);
const actOptions = computed(() => {
return actList.value.map(item => {
return {
value: item.id,
label: item.title
}
})
})
// 获取排行榜数据
const getRankData = async () => {
loading.value = true;
@@ -110,6 +125,22 @@ const getRankData = async () => {
}
};
async function listMineAct() {
try {
const {data, code, msg} = await useRequest().get('/client/activity/list-mine-act')
if (code === 0) {
actList.value = data
if (actList.value.length && activityId.value == null) {
activityId.value = actList.value[0].id
}
} else {
Toast.error(msg)
}
} catch (e) {
Toast.error(e.message)
}
}
// 刷新
const handleRefresh = () => {
if (loading.value) {
@@ -122,12 +153,13 @@ const handleRefresh = () => {
};
onLoad((option) => {
if (option.id) {
activityId.value=option.id
activityId.value = Number(option.id)
}
});
// 页面加载时获取数据
onMounted(() => {
getRankData();
onMounted(async () => {
await listMineAct()
await getRankData()
});
</script>
@@ -441,7 +473,7 @@ onMounted(() => {
.refresh-btn {
position: fixed;
right: 30rpx;
bottom: 40rpx;
bottom: 140rpx;
width: 90rpx;
height: 90rpx;
border-radius: 50%;