feat(排行榜): 重构排行榜接口和组件以支持多类型数据
修改API接口参数从current_county变为type参数,支持上海家庭榜、区县家庭榜和单位助力榜 移除mock数据,统一使用接口返回数据 更新组件逻辑以适应新的数据结构
Showing
3 changed files
with
84 additions
and
225 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2023-12-22 10:29:37 | 2 | * @Date: 2023-12-22 10:29:37 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-09 14:56:34 | 4 | + * @LastEditTime: 2025-09-18 17:23:51 |
| 5 | * @FilePath: /lls_program/src/api/points.js | 5 | * @FilePath: /lls_program/src/api/points.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -51,24 +51,24 @@ export const getPointListAPI = (params) => fn(fetch.get(Api.POINT_LIST, params)) | ... | @@ -51,24 +51,24 @@ export const getPointListAPI = (params) => fn(fetch.get(Api.POINT_LIST, params)) |
| 51 | /** | 51 | /** |
| 52 | * @description: 查询步数排行榜, 数据长度为10个, 不加上county参数查询的是上海数据, 数据长度是20个, 都是固定长度. | 52 | * @description: 查询步数排行榜, 数据长度为10个, 不加上county参数查询的是上海数据, 数据长度是20个, 都是固定长度. |
| 53 | * @param {Object} params - 请求参数 | 53 | * @param {Object} params - 请求参数 |
| 54 | - * @param {string} params.current_county - 是否只查我的当前家庭所在区县的排行榜。1=是,0=否。默认为否 | 54 | + * @param {string} params.type - shanghai_family=上海家庭步数榜,county_family=和我同区县的家庭步数榜,institution=单位助力榜 |
| 55 | * @returns {Object} response - 响应对象 | 55 | * @returns {Object} response - 响应对象 |
| 56 | * @returns {number} response.code - 响应状态码 | 56 | * @returns {number} response.code - 响应状态码 |
| 57 | * @returns {string} response.msg - 响应消息 | 57 | * @returns {string} response.msg - 响应消息 |
| 58 | * @returns {Object} response.data - 响应数据 | 58 | * @returns {Object} response.data - 响应数据 |
| 59 | * @returns {Array} response.data.yesterday - 昨天日期 | 59 | * @returns {Array} response.data.yesterday - 昨天日期 |
| 60 | - * @returns {Array} response.data.families[] - 家庭列表 | 60 | + * @returns {Array} response.data.families[] - 家庭列表, 也可以是单位列表 |
| 61 | - * @returns {string} response.data.families[].family_id - 家庭ID | 61 | + * @returns {string} response.data.families[].family_id - 家庭ID, 也可以是单位ID |
| 62 | - * @returns {string} response.data.families[].name - 家庭名称 | 62 | + * @returns {string} response.data.families[].name - 家庭名称, 也可以是单位名称 |
| 63 | - * @returns {string} response.data.families[].avatar_url - 头像URL | 63 | + * @returns {string} response.data.families[].avatar_url - 头像URL, 也可以是单位头像 |
| 64 | - * @returns {string} response.data.families[].created_by_nickname - 创建人昵称 | 64 | + * @returns {string} response.data.families[].created_by_nickname - 创建人昵称, 也可以是家庭数量 |
| 65 | * @returns {number} response.data.families[].step - 步数 | 65 | * @returns {number} response.data.families[].step - 步数 |
| 66 | * @returns {number} response.data.families[].rank - 排名 | 66 | * @returns {number} response.data.families[].rank - 排名 |
| 67 | * @returns {Array} response.data.current_family[] - 当前家庭列表 | 67 | * @returns {Array} response.data.current_family[] - 当前家庭列表 |
| 68 | - * @returns {string} response.data.current_family[].family_id - 家庭ID | 68 | + * @returns {string} response.data.current_family[].family_id - 家庭ID, 也可以是单位ID |
| 69 | - * @returns {string} response.data.current_family[].name - 家庭名称 | 69 | + * @returns {string} response.data.current_family[].name - 家庭名称, 也可以是单位名称 |
| 70 | - * @returns {string} response.data.current_family[].avatar_url - 头像URL | 70 | + * @returns {string} response.data.current_family[].avatar_url - 头像URL, 也可以是单位头像 |
| 71 | - * @returns {string} response.data.current_family[].created_by_nickname - 创建人昵称 | 71 | + * @returns {string} response.data.current_family[].created_by_nickname - 创建人昵称, 也可以是家庭数量 |
| 72 | * @returns {number} response.data.current_family[].step - 步数 | 72 | * @returns {number} response.data.current_family[].step - 步数 |
| 73 | * @returns {number} response.data.current_family[].rank - 排名 | 73 | * @returns {number} response.data.current_family[].rank - 排名 |
| 74 | * @returns {number} response.data.current_family[].country - 区县 | 74 | * @returns {number} response.data.current_family[].country - 区县 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-01-09 00:00:00 | 2 | * @Date: 2025-01-09 00:00:00 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-18 17:09:27 | 4 | + * @LastEditTime: 2025-09-18 17:39:14 |
| 5 | * @FilePath: /lls_program/src/components/RankingCard.vue | 5 | * @FilePath: /lls_program/src/components/RankingCard.vue |
| 6 | * @Description: 排行榜卡片组件 | 6 | * @Description: 排行榜卡片组件 |
| 7 | --> | 7 | --> |
| ... | @@ -56,10 +56,10 @@ | ... | @@ -56,10 +56,10 @@ |
| 56 | <image :src="activeTab === 'support' ? (topRanks[1]?.logo || defaultAvatar) : (topRanks[1]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 56 | <image :src="activeTab === 'support' ? (topRanks[1]?.logo || defaultAvatar) : (topRanks[1]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 57 | </view> | 57 | </view> |
| 58 | <view class="family-name">{{ activeTab === 'support' ? topRanks[1]?.name : topRanks[1]?.name }}</view> | 58 | <view class="family-name">{{ activeTab === 'support' ? topRanks[1]?.name : topRanks[1]?.name }}</view> |
| 59 | - <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[1]?.family_count}个家庭` : `大家长:${topRanks[1]?.created_by_nickname}` }}</view> | 59 | + <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[1]?.created_by_nickname}个家庭` : `大家长:${topRanks[1]?.created_by_nickname}` }}</view> |
| 60 | <view class="rank-number"> | 60 | <view class="rank-number"> |
| 61 | <view class="rank-num">2</view> | 61 | <view class="rank-num">2</view> |
| 62 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[1]?.total_steps) : formatSteps(topRanks[1]?.step) }}</view> | 62 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[1]?.step) : formatSteps(topRanks[1]?.step) }}</view> |
| 63 | </view> | 63 | </view> |
| 64 | </view> | 64 | </view> |
| 65 | 65 | ||
| ... | @@ -72,10 +72,10 @@ | ... | @@ -72,10 +72,10 @@ |
| 72 | <image :src="activeTab === 'support' ? (topRanks[0]?.logo || defaultAvatar) : (topRanks[0]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 72 | <image :src="activeTab === 'support' ? (topRanks[0]?.logo || defaultAvatar) : (topRanks[0]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 73 | </view> | 73 | </view> |
| 74 | <view class="family-name">{{ topRanks[0]?.name }}</view> | 74 | <view class="family-name">{{ topRanks[0]?.name }}</view> |
| 75 | - <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[0]?.family_count}个家庭` : `大家长:${topRanks[0]?.created_by_nickname}` }}</view> | 75 | + <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[0]?.created_by_nickname}个家庭` : `大家长:${topRanks[0]?.created_by_nickname}` }}</view> |
| 76 | <view class="rank-number"> | 76 | <view class="rank-number"> |
| 77 | <view class="rank-num">1</view> | 77 | <view class="rank-num">1</view> |
| 78 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[0]?.total_steps) : formatSteps(topRanks[0]?.step) }}</view> | 78 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[0]?.step) : formatSteps(topRanks[0]?.step) }}</view> |
| 79 | </view> | 79 | </view> |
| 80 | </view> | 80 | </view> |
| 81 | 81 | ||
| ... | @@ -88,10 +88,10 @@ | ... | @@ -88,10 +88,10 @@ |
| 88 | <image :src="activeTab === 'support' ? (topRanks[2]?.logo || defaultAvatar) : (topRanks[2]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 88 | <image :src="activeTab === 'support' ? (topRanks[2]?.logo || defaultAvatar) : (topRanks[2]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 89 | </view> | 89 | </view> |
| 90 | <view class="family-name">{{ topRanks[2]?.name }}</view> | 90 | <view class="family-name">{{ topRanks[2]?.name }}</view> |
| 91 | - <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[2]?.family_count}个家庭` : `大家长:${topRanks[2]?.created_by_nickname}` }}</view> | 91 | + <view class="leader-name">{{ activeTab === 'support' ? `${topRanks[2]?.created_by_nickname}个家庭` : `大家长:${topRanks[2]?.created_by_nickname}` }}</view> |
| 92 | <view class="rank-number"> | 92 | <view class="rank-number"> |
| 93 | <view class="rank-num">3</view> | 93 | <view class="rank-num">3</view> |
| 94 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[2]?.total_steps) : formatSteps(topRanks[2]?.step) }}</view> | 94 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topRanks[2]?.step) : formatSteps(topRanks[2]?.step) }}</view> |
| 95 | </view> | 95 | </view> |
| 96 | </view> | 96 | </view> |
| 97 | </view> | 97 | </view> |
| ... | @@ -157,62 +157,8 @@ const isContentSwitching = ref(false) | ... | @@ -157,62 +157,8 @@ const isContentSwitching = ref(false) |
| 157 | // 排行榜数据 | 157 | // 排行榜数据 |
| 158 | const leaderboardData = ref(null) | 158 | const leaderboardData = ref(null) |
| 159 | 159 | ||
| 160 | -// 助力榜mock数据 | 160 | +// 助力榜数据 |
| 161 | -const supportData = ref({ | 161 | +const supportData = ref(null) |
| 162 | - yesterday: '2024年1月15日', | ||
| 163 | - kindergartens: [ | ||
| 164 | - { | ||
| 165 | - id: 1, | ||
| 166 | - name: '阳光幼儿园', | ||
| 167 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 168 | - family_count: 156, | ||
| 169 | - total_steps: 430000 | ||
| 170 | - }, | ||
| 171 | - { | ||
| 172 | - id: 2, | ||
| 173 | - name: '彩虹幼儿园', | ||
| 174 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 175 | - family_count: 142, | ||
| 176 | - total_steps: 380000 | ||
| 177 | - }, | ||
| 178 | - { | ||
| 179 | - id: 3, | ||
| 180 | - name: '小星星幼儿园', | ||
| 181 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 182 | - family_count: 128, | ||
| 183 | - total_steps: 320000 | ||
| 184 | - }, | ||
| 185 | - { | ||
| 186 | - id: 4, | ||
| 187 | - name: '快乐幼儿园', | ||
| 188 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 189 | - family_count: 115, | ||
| 190 | - total_steps: 280000 | ||
| 191 | - }, | ||
| 192 | - { | ||
| 193 | - id: 5, | ||
| 194 | - name: '智慧幼儿园', | ||
| 195 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 196 | - family_count: 98, | ||
| 197 | - total_steps: 250000 | ||
| 198 | - }, | ||
| 199 | - { | ||
| 200 | - id: 6, | ||
| 201 | - name: '梦想幼儿园', | ||
| 202 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 203 | - family_count: 87, | ||
| 204 | - total_steps: 220000 | ||
| 205 | - } | ||
| 206 | - ], | ||
| 207 | - current_kindergarten: { | ||
| 208 | - id: 7, | ||
| 209 | - name: '我的幼儿园', | ||
| 210 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 211 | - family_count: 45, | ||
| 212 | - total_steps: 120000, | ||
| 213 | - rank: 8 | ||
| 214 | - } | ||
| 215 | -}) | ||
| 216 | 162 | ||
| 217 | const joinOrganization = () => { | 163 | const joinOrganization = () => { |
| 218 | Taro.navigateTo({ | 164 | Taro.navigateTo({ |
| ... | @@ -226,6 +172,8 @@ const loading = ref(false) | ... | @@ -226,6 +172,8 @@ const loading = ref(false) |
| 226 | // 排行榜日期 | 172 | // 排行榜日期 |
| 227 | const currentDate = ref('') | 173 | const currentDate = ref('') |
| 228 | 174 | ||
| 175 | + | ||
| 176 | + | ||
| 229 | /** | 177 | /** |
| 230 | * 切换tab | 178 | * 切换tab |
| 231 | * @param {string} tab - tab名称 | 179 | * @param {string} tab - tab名称 |
| ... | @@ -233,25 +181,6 @@ const currentDate = ref('') | ... | @@ -233,25 +181,6 @@ const currentDate = ref('') |
| 233 | const switchTab = async (tab) => { | 181 | const switchTab = async (tab) => { |
| 234 | if (activeTab.value === tab) return | 182 | if (activeTab.value === tab) return |
| 235 | 183 | ||
| 236 | - // 助力榜使用mock数据 | ||
| 237 | - if (tab === 'support') { | ||
| 238 | - // 开始切换动画 | ||
| 239 | - isContentSwitching.value = true | ||
| 240 | - | ||
| 241 | - // 延迟切换内容,让淡出动画先执行 | ||
| 242 | - setTimeout(() => { | ||
| 243 | - activeTab.value = tab | ||
| 244 | - // 设置助力榜的日期 | ||
| 245 | - currentDate.value = supportData.value.yesterday | ||
| 246 | - | ||
| 247 | - // 内容切换后,结束切换状态,开始淡入动画 | ||
| 248 | - setTimeout(() => { | ||
| 249 | - isContentSwitching.value = false | ||
| 250 | - }, 50) | ||
| 251 | - }, 200) | ||
| 252 | - return | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | // 开始切换动画 | 184 | // 开始切换动画 |
| 256 | isContentSwitching.value = true | 185 | isContentSwitching.value = true |
| 257 | 186 | ||
| ... | @@ -278,13 +207,22 @@ const loadLeaderboardData = async (isInitialLoad = false) => { | ... | @@ -278,13 +207,22 @@ const loadLeaderboardData = async (isInitialLoad = false) => { |
| 278 | loading.value = true | 207 | loading.value = true |
| 279 | const params = {} | 208 | const params = {} |
| 280 | 209 | ||
| 281 | - // 添加current_county参数:1=是,0=否,默认为否 | 210 | + // 根据activeTab设置type参数 |
| 282 | - // 根据activeTab动态设置:上海榜时为0,区域榜时为1 | 211 | + if (activeTab.value === 'shanghai') { |
| 283 | - params.current_county = activeTab.value === 'shanghai' ? '0' : '1' | 212 | + params.type = 'shanghai_family' |
| 213 | + } else if (activeTab.value === 'support') { | ||
| 214 | + params.type = 'institution' | ||
| 215 | + } else { | ||
| 216 | + params.type = 'county_family' | ||
| 217 | + } | ||
| 284 | 218 | ||
| 285 | const response = await getStepLeaderboardAPI(params) | 219 | const response = await getStepLeaderboardAPI(params) |
| 286 | if (response.code) { | 220 | if (response.code) { |
| 287 | - leaderboardData.value = response.data | 221 | + if (activeTab.value === 'support') { |
| 222 | + supportData.value = response.data | ||
| 223 | + } else { | ||
| 224 | + leaderboardData.value = response.data | ||
| 225 | + } | ||
| 288 | // 设置当前日期 | 226 | // 设置当前日期 |
| 289 | currentDate.value = response.data.yesterday | 227 | currentDate.value = response.data.yesterday |
| 290 | } | 228 | } |
| ... | @@ -393,10 +331,10 @@ const handleViewMore = () => { | ... | @@ -393,10 +331,10 @@ const handleViewMore = () => { |
| 393 | const topRanks = computed(() => { | 331 | const topRanks = computed(() => { |
| 394 | if (activeTab.value === 'support') { | 332 | if (activeTab.value === 'support') { |
| 395 | // 助力榜数据 | 333 | // 助力榜数据 |
| 396 | - if (!supportData.value || !supportData.value.kindergartens) { | 334 | + if (!supportData.value || !supportData.value.families) { |
| 397 | return [] | 335 | return [] |
| 398 | } | 336 | } |
| 399 | - return supportData.value.kindergartens.slice(0, 3) | 337 | + return supportData.value.families.slice(0, 3) |
| 400 | } | 338 | } |
| 401 | 339 | ||
| 402 | // 家庭排行榜数据 | 340 | // 家庭排行榜数据 |
| ... | @@ -409,20 +347,18 @@ const topRanks = computed(() => { | ... | @@ -409,20 +347,18 @@ const topRanks = computed(() => { |
| 409 | // 计算我的排名信息 | 347 | // 计算我的排名信息 |
| 410 | const myRank = computed(() => { | 348 | const myRank = computed(() => { |
| 411 | if (activeTab.value === 'support') { | 349 | if (activeTab.value === 'support') { |
| 412 | - // 助力榜我的幼儿园信息 | 350 | + // 助力榜我的单位信息 |
| 413 | - if (!supportData.value || !supportData.value.current_kindergarten) { | 351 | + if (!supportData.value || !supportData.value.current_family) { |
| 414 | return null | 352 | return null |
| 415 | } | 353 | } |
| 416 | 354 | ||
| 417 | - const currentKindergarten = supportData.value.current_kindergarten | 355 | + const currentInstitution = supportData.value.current_family |
| 418 | return { | 356 | return { |
| 419 | - ...currentKindergarten, | 357 | + ...currentInstitution, |
| 420 | - name: currentKindergarten.name, | 358 | + name: currentInstitution.name, |
| 421 | - avatar_url: currentKindergarten.logo, | 359 | + avatar_url: currentInstitution.avatar_url, |
| 422 | - step: currentKindergarten.total_steps, | 360 | + step: currentInstitution.step, |
| 423 | - created_by_nickname: `${currentKindergarten.family_count}个家庭`, | 361 | + rank: currentInstitution.rank |
| 424 | - status: currentKindergarten.rank > 100 ? '未上榜' : '已上榜', | ||
| 425 | - isNotRanked: !currentKindergarten.rank || currentKindergarten.rank === 0 || currentKindergarten.rank > 100 | ||
| 426 | } | 362 | } |
| 427 | } | 363 | } |
| 428 | 364 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-09-01 13:07:52 | 2 | * @Date: 2025-09-01 13:07:52 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-18 16:56:23 | 4 | + * @LastEditTime: 2025-09-18 17:38:03 |
| 5 | * @FilePath: /lls_program/src/pages/FamilyRank/index.vue | 5 | * @FilePath: /lls_program/src/pages/FamilyRank/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -56,10 +56,10 @@ | ... | @@ -56,10 +56,10 @@ |
| 56 | <image :src="activeTab === 'support' ? topThreeData[1]?.logo : (topThreeData[1]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 56 | <image :src="activeTab === 'support' ? topThreeData[1]?.logo : (topThreeData[1]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 57 | </view> | 57 | </view> |
| 58 | <view class="family-name">{{ topThreeData[1]?.name }}</view> | 58 | <view class="family-name">{{ topThreeData[1]?.name }}</view> |
| 59 | - <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[1]?.family_count}个家庭` : `大家长:${topThreeData[1]?.created_by_nickname}` }}</view> | 59 | + <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[1]?.created_by_nickname}个家庭` : `大家长:${topThreeData[1]?.created_by_nickname}` }}</view> |
| 60 | <view class="rank-number"> | 60 | <view class="rank-number"> |
| 61 | <view class="rank-num">2</view> | 61 | <view class="rank-num">2</view> |
| 62 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[1]?.total_steps) : formatSteps(topThreeData[1]?.step) }}</view> | 62 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[1]?.step) : formatSteps(topThreeData[1]?.step) }}</view> |
| 63 | </view> | 63 | </view> |
| 64 | </view> | 64 | </view> |
| 65 | 65 | ||
| ... | @@ -72,10 +72,10 @@ | ... | @@ -72,10 +72,10 @@ |
| 72 | <image :src="activeTab === 'support' ? topThreeData[0]?.logo : (topThreeData[0]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 72 | <image :src="activeTab === 'support' ? topThreeData[0]?.logo : (topThreeData[0]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 73 | </view> | 73 | </view> |
| 74 | <view class="family-name">{{ topThreeData[0]?.name }}</view> | 74 | <view class="family-name">{{ topThreeData[0]?.name }}</view> |
| 75 | - <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[0]?.family_count}个家庭` : `大家长:${topThreeData[0]?.created_by_nickname}` }}</view> | 75 | + <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[0]?.created_by_nickname}个家庭` : `大家长:${topThreeData[0]?.created_by_nickname}` }}</view> |
| 76 | <view class="rank-number"> | 76 | <view class="rank-number"> |
| 77 | <view class="rank-num">1</view> | 77 | <view class="rank-num">1</view> |
| 78 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[0]?.total_steps) : formatSteps(topThreeData[0]?.step) }}</view> | 78 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[0]?.step) : formatSteps(topThreeData[0]?.step) }}</view> |
| 79 | </view> | 79 | </view> |
| 80 | </view> | 80 | </view> |
| 81 | 81 | ||
| ... | @@ -88,10 +88,10 @@ | ... | @@ -88,10 +88,10 @@ |
| 88 | <image :src="activeTab === 'support' ? topThreeData[2]?.logo : (topThreeData[2]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> | 88 | <image :src="activeTab === 'support' ? topThreeData[2]?.logo : (topThreeData[2]?.avatar_url || defaultAvatar)" class="avatar-img" mode="aspectFill" /> |
| 89 | </view> | 89 | </view> |
| 90 | <view class="family-name">{{ topThreeData[2]?.name }}</view> | 90 | <view class="family-name">{{ topThreeData[2]?.name }}</view> |
| 91 | - <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[2]?.family_count}个家庭` : `大家长:${topThreeData[2]?.created_by_nickname}` }}</view> | 91 | + <view class="leader-name">{{ activeTab === 'support' ? `${topThreeData[2]?.created_by_nickname}个家庭` : `大家长:${topThreeData[2]?.created_by_nickname}` }}</view> |
| 92 | <view class="rank-number"> | 92 | <view class="rank-number"> |
| 93 | <view class="rank-num">3</view> | 93 | <view class="rank-num">3</view> |
| 94 | - <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[2]?.total_steps) : formatSteps(topThreeData[2]?.step) }}</view> | 94 | + <view class="steps-in-rank">{{ activeTab === 'support' ? formatSupportSteps(topThreeData[2]?.step) : formatSteps(topThreeData[2]?.step) }}</view> |
| 95 | </view> | 95 | </view> |
| 96 | </view> | 96 | </view> |
| 97 | </view> | 97 | </view> |
| ... | @@ -106,15 +106,15 @@ | ... | @@ -106,15 +106,15 @@ |
| 106 | <view class="rank-info"> | 106 | <view class="rank-info"> |
| 107 | <view class="rank-num">{{ index + 4 }}</view> | 107 | <view class="rank-num">{{ index + 4 }}</view> |
| 108 | <view class="avatar-small"> | 108 | <view class="avatar-small"> |
| 109 | - <image :src="activeTab === 'support' ? item.logo : (item.avatar_url || defaultAvatar)" class="avatar-small-img" mode="aspectFill" /> | 109 | + <image :src="activeTab === 'support' ? item.avatar_url : (item.avatar_url || defaultAvatar)" class="avatar-small-img" mode="aspectFill" /> |
| 110 | </view> | 110 | </view> |
| 111 | <view class="family-info"> | 111 | <view class="family-info"> |
| 112 | <view class="family-name-small">{{ item.name }}</view> | 112 | <view class="family-name-small">{{ item.name }}</view> |
| 113 | - <view class="leader-name-small">{{ activeTab === 'support' ? `${item.family_count}个家庭` : `大家长:${item.created_by_nickname}` }}</view> | 113 | + <view class="leader-name-small">{{ activeTab === 'support' ? `${item.created_by_nickname}个家庭` : `大家长:${item.created_by_nickname}` }}</view> |
| 114 | </view> | 114 | </view> |
| 115 | </view> | 115 | </view> |
| 116 | <view class="steps-info"> | 116 | <view class="steps-info"> |
| 117 | - <view class="steps">{{ activeTab === 'support' ? formatSupportSteps(item.total_steps) : formatStepsForList(item.step) }}</view> | 117 | + <view class="steps">{{ activeTab === 'support' ? formatSupportSteps(item.step) : formatStepsForList(item.step) }}</view> |
| 118 | </view> | 118 | </view> |
| 119 | </view> | 119 | </view> |
| 120 | </view> | 120 | </view> |
| ... | @@ -180,76 +180,8 @@ const isContentSwitching = ref(false) | ... | @@ -180,76 +180,8 @@ const isContentSwitching = ref(false) |
| 180 | // 排行榜数据 | 180 | // 排行榜数据 |
| 181 | const leaderboardData = ref(null) | 181 | const leaderboardData = ref(null) |
| 182 | 182 | ||
| 183 | -// 助力榜mock数据 | 183 | +// 助力榜数据 |
| 184 | -const supportData = ref({ | 184 | +const supportData = ref(null) |
| 185 | - yesterday: '2024年1月15日', | ||
| 186 | - kindergartens: [ | ||
| 187 | - { | ||
| 188 | - id: 1, | ||
| 189 | - name: '阳光幼儿园', | ||
| 190 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 191 | - family_count: 156, | ||
| 192 | - total_steps: 430000 | ||
| 193 | - }, | ||
| 194 | - { | ||
| 195 | - id: 2, | ||
| 196 | - name: '彩虹幼儿园', | ||
| 197 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 198 | - family_count: 142, | ||
| 199 | - total_steps: 380000 | ||
| 200 | - }, | ||
| 201 | - { | ||
| 202 | - id: 3, | ||
| 203 | - name: '小星星幼儿园', | ||
| 204 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 205 | - family_count: 128, | ||
| 206 | - total_steps: 320000 | ||
| 207 | - }, | ||
| 208 | - { | ||
| 209 | - id: 4, | ||
| 210 | - name: '快乐幼儿园', | ||
| 211 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 212 | - family_count: 115, | ||
| 213 | - total_steps: 280000 | ||
| 214 | - }, | ||
| 215 | - { | ||
| 216 | - id: 5, | ||
| 217 | - name: '智慧幼儿园', | ||
| 218 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 219 | - family_count: 98, | ||
| 220 | - total_steps: 250000 | ||
| 221 | - }, | ||
| 222 | - { | ||
| 223 | - id: 6, | ||
| 224 | - name: '梦想幼儿园', | ||
| 225 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 226 | - family_count: 87, | ||
| 227 | - total_steps: 220000 | ||
| 228 | - }, | ||
| 229 | - { | ||
| 230 | - id: 7, | ||
| 231 | - name: '未来幼儿园', | ||
| 232 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 233 | - family_count: 76, | ||
| 234 | - total_steps: 190000 | ||
| 235 | - }, | ||
| 236 | - { | ||
| 237 | - id: 8, | ||
| 238 | - name: '希望幼儿园', | ||
| 239 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 240 | - family_count: 65, | ||
| 241 | - total_steps: 160000 | ||
| 242 | - } | ||
| 243 | - ], | ||
| 244 | - current_kindergarten: { | ||
| 245 | - id: 9, | ||
| 246 | - name: '我的幼儿园', | ||
| 247 | - logo: 'https://cdn.ipadbiz.cn/mlaj/images/icon_1.jpeg', | ||
| 248 | - family_count: 45, | ||
| 249 | - total_steps: 120000, | ||
| 250 | - rank: 10 | ||
| 251 | - } | ||
| 252 | -}) | ||
| 253 | 185 | ||
| 254 | const joinOrganization = () => { | 186 | const joinOrganization = () => { |
| 255 | Taro.navigateTo({ | 187 | Taro.navigateTo({ |
| ... | @@ -263,6 +195,8 @@ const loading = ref(false) | ... | @@ -263,6 +195,8 @@ const loading = ref(false) |
| 263 | // 当前日期 | 195 | // 当前日期 |
| 264 | const currentDate = ref('') | 196 | const currentDate = ref('') |
| 265 | 197 | ||
| 198 | + | ||
| 199 | + | ||
| 266 | /** | 200 | /** |
| 267 | * 切换tab | 201 | * 切换tab |
| 268 | * @param {string} tab - tab名称 | 202 | * @param {string} tab - tab名称 |
| ... | @@ -270,25 +204,6 @@ const currentDate = ref('') | ... | @@ -270,25 +204,6 @@ const currentDate = ref('') |
| 270 | const switchTab = async (tab) => { | 204 | const switchTab = async (tab) => { |
| 271 | if (activeTab.value === tab) return | 205 | if (activeTab.value === tab) return |
| 272 | 206 | ||
| 273 | - // 助力榜使用mock数据 | ||
| 274 | - if (tab === 'support') { | ||
| 275 | - // 开始切换动画 | ||
| 276 | - isContentSwitching.value = true | ||
| 277 | - | ||
| 278 | - // 延迟切换内容,让淡出动画先执行 | ||
| 279 | - setTimeout(() => { | ||
| 280 | - activeTab.value = tab | ||
| 281 | - // 设置助力榜的日期 | ||
| 282 | - currentDate.value = supportData.value.yesterday | ||
| 283 | - | ||
| 284 | - // 内容切换后,结束切换状态,开始淡入动画 | ||
| 285 | - setTimeout(() => { | ||
| 286 | - isContentSwitching.value = false | ||
| 287 | - }, 50) | ||
| 288 | - }, 200) | ||
| 289 | - return | ||
| 290 | - } | ||
| 291 | - | ||
| 292 | // 开始切换动画 | 207 | // 开始切换动画 |
| 293 | isContentSwitching.value = true | 208 | isContentSwitching.value = true |
| 294 | 209 | ||
| ... | @@ -349,13 +264,22 @@ const loadLeaderboardData = async (isInitialLoad = false) => { | ... | @@ -349,13 +264,22 @@ const loadLeaderboardData = async (isInitialLoad = false) => { |
| 349 | loading.value = true | 264 | loading.value = true |
| 350 | const params = {} | 265 | const params = {} |
| 351 | 266 | ||
| 352 | - // 添加current_county参数:1=是,0=否,默认为否 | 267 | + // 根据activeTab设置type参数 |
| 353 | - // 根据activeTab动态设置:上海榜时为0,区域榜时为1 | 268 | + if (activeTab.value === 'shanghai') { |
| 354 | - params.current_county = activeTab.value === 'shanghai' ? '0' : '1' | 269 | + params.type = 'shanghai_family' |
| 270 | + } else if (activeTab.value === 'support') { | ||
| 271 | + params.type = 'institution' | ||
| 272 | + } else { | ||
| 273 | + params.type = 'county_family' | ||
| 274 | + } | ||
| 355 | 275 | ||
| 356 | const response = await getStepLeaderboardAPI(params) | 276 | const response = await getStepLeaderboardAPI(params) |
| 357 | if (response.code) { | 277 | if (response.code) { |
| 358 | - leaderboardData.value = response.data | 278 | + if (activeTab.value === 'support') { |
| 279 | + supportData.value = response.data | ||
| 280 | + } else { | ||
| 281 | + leaderboardData.value = response.data | ||
| 282 | + } | ||
| 359 | currentDate.value = response.data.yesterday | 283 | currentDate.value = response.data.yesterday |
| 360 | } | 284 | } |
| 361 | } catch (error) { | 285 | } catch (error) { |
| ... | @@ -422,10 +346,10 @@ const getTabDisplayName = (region) => { | ... | @@ -422,10 +346,10 @@ const getTabDisplayName = (region) => { |
| 422 | const topThreeData = computed(() => { | 346 | const topThreeData = computed(() => { |
| 423 | if (activeTab.value === 'support') { | 347 | if (activeTab.value === 'support') { |
| 424 | // 助力榜数据 | 348 | // 助力榜数据 |
| 425 | - if (!supportData.value || !supportData.value.kindergartens) { | 349 | + if (!supportData.value || !supportData.value.families) { |
| 426 | return [] | 350 | return [] |
| 427 | } | 351 | } |
| 428 | - return supportData.value.kindergartens.slice(0, 3) | 352 | + return supportData.value.families.slice(0, 3) |
| 429 | } | 353 | } |
| 430 | 354 | ||
| 431 | // 家庭排行榜数据 | 355 | // 家庭排行榜数据 |
| ... | @@ -441,10 +365,10 @@ const topThreeData = computed(() => { | ... | @@ -441,10 +365,10 @@ const topThreeData = computed(() => { |
| 441 | const otherRankData = computed(() => { | 365 | const otherRankData = computed(() => { |
| 442 | if (activeTab.value === 'support') { | 366 | if (activeTab.value === 'support') { |
| 443 | // 助力榜数据 | 367 | // 助力榜数据 |
| 444 | - if (!supportData.value || !supportData.value.kindergartens) { | 368 | + if (!supportData.value || !supportData.value.families) { |
| 445 | return [] | 369 | return [] |
| 446 | } | 370 | } |
| 447 | - return supportData.value.kindergartens.slice(3) | 371 | + return supportData.value.families.slice(3) |
| 448 | } | 372 | } |
| 449 | 373 | ||
| 450 | // 家庭排行榜数据 | 374 | // 家庭排行榜数据 |
| ... | @@ -459,19 +383,18 @@ const otherRankData = computed(() => { | ... | @@ -459,19 +383,18 @@ const otherRankData = computed(() => { |
| 459 | */ | 383 | */ |
| 460 | const myRankInfo = computed(() => { | 384 | const myRankInfo = computed(() => { |
| 461 | if (activeTab.value === 'support') { | 385 | if (activeTab.value === 'support') { |
| 462 | - // 助力榜我的幼儿园信息 | 386 | + // 助力榜我的单位信息 |
| 463 | - if (!supportData.value || !supportData.value.current_kindergarten) { | 387 | + if (!supportData.value || !supportData.value.current_family) { |
| 464 | return null | 388 | return null |
| 465 | } | 389 | } |
| 466 | 390 | ||
| 467 | - const currentKindergarten = supportData.value.current_kindergarten | 391 | + const currentInstitution = supportData.value.current_family |
| 468 | return { | 392 | return { |
| 469 | - ...currentKindergarten, | 393 | + ...currentInstitution, |
| 470 | - family_name: currentKindergarten.name, | 394 | + name: currentInstitution.name, |
| 471 | - avatar_url: currentKindergarten.logo, | 395 | + avatar_url: currentInstitution.avatar_url, |
| 472 | - step: currentKindergarten.total_steps, | 396 | + step: currentInstitution.step, |
| 473 | - created_by_nickname: `${currentKindergarten.family_count}个家庭`, | 397 | + rank: currentInstitution.rank |
| 474 | - isNotRanked: !currentKindergarten.rank || currentKindergarten.rank === 0 || currentKindergarten.rank > 100 | ||
| 475 | } | 398 | } |
| 476 | } | 399 | } |
| 477 | 400 | ... | ... |
-
Please register or login to post a comment