feat: 更新前端多个页面和后端服务

- 前端: 更新AI营养师、计算器、打卡、食物详情等页面
- 前端: 更新食物百科、知识详情、营养知识页面
- 前端: 更新社区首页
- 后端: 更新ToolKieAIServiceImpl服务
- API: 更新models-api.js和user.js
This commit is contained in:
2026-03-07 22:26:37 +08:00
parent 1632801880
commit f692c75f7b
11 changed files with 221 additions and 85 deletions

View File

@@ -4,32 +4,32 @@
<view class="tab-nav">
<view
class="tab-item"
:class="{ active: currentTab === 'recommend' }"
@click="switchTab('recommend')"
:class="{ active: currentTab === '推荐' }"
@click="switchTab('推荐')"
>
<!-- <text class="tab-icon">📊</text> -->
<text class="tab-text">推荐</text>
</view>
<view
class="tab-item"
:class="{ active: currentTab === 'latest' }"
@click="switchTab('latest')"
:class="{ active: currentTab === '最新' }"
@click="switchTab('最新')"
>
<!-- <text class="tab-icon">🕐</text> -->
<text class="tab-text">最新</text>
</view>
<view
class="tab-item"
:class="{ active: currentTab === 'follow' }"
@click="switchTab('follow')"
:class="{ active: currentTab === '关注' }"
@click="switchTab('关注')"
>
<!-- <text class="tab-icon">👥</text> -->
<text class="tab-text">关注</text>
</view>
<view
class="tab-item"
:class="{ active: currentTab === 'hot' }"
@click="switchTab('hot')"
:class="{ active: currentTab === '热门' }"
@click="switchTab('热门')"
>
<!-- <text class="tab-icon">🔥</text> -->
<text class="tab-text">热门</text>
@@ -46,7 +46,7 @@
<view class="empty-container" v-else-if="isEmpty">
<text class="empty-icon">📭</text>
<text class="empty-text">暂无内容</text>
<text class="empty-hint" v-if="currentTab === 'follow'">关注更多用户查看他们的打卡动态</text>
<text class="empty-hint" v-if="currentTab === '关注'">关注更多用户查看他们的打卡动态</text>
<text class="empty-hint" v-else>快来发布第一条打卡动态吧</text>
</view>
@@ -144,7 +144,7 @@ import { checkLogin, toLogin } from '@/libs/login.js'
export default {
data() {
return {
currentTab: 'recommend',
currentTab: '推荐',
postList: [],
page: 1,
limit: 10,
@@ -173,12 +173,18 @@ export default {
this.loadMore()
},
methods: {
// Tab 中文转接口参数(不改动接口逻辑,仅在此处映射)
getTabApiValue() {
const map = { '推荐': 'recommend', '最新': 'latest', '关注': 'follow', '热门': 'hot' }
return map[this.currentTab] || 'recommend'
},
// 切换Tab
switchTab(tab) {
if (this.currentTab === tab) return
// 关注Tab需要登录
if (tab === 'follow' && !checkLogin()) {
if (tab === '关注' && !checkLogin()) {
uni.showToast({
title: '请先登录查看关注内容',
icon: 'none'
@@ -214,7 +220,7 @@ export default {
try {
const res = await getCommunityList({
tab: this.currentTab,
tab: this.getTabApiValue(),
page: this.page,
limit: this.limit
})
@@ -385,7 +391,7 @@ export default {
try {
const res = await getCommunityList({
tab: this.currentTab,
tab: this.getTabApiValue(),
page: this.page,
limit: this.limit
})
@@ -415,18 +421,18 @@ export default {
})
},
// 格式化数量显示
// 格式化数量显示(中文单位)
formatCount(count) {
if (!count) return '0'
if (count >= 10000) {
return (count / 10000).toFixed(1) + 'w'
return (count / 10000).toFixed(1) + ''
} else if (count >= 1000) {
return (count / 1000).toFixed(1) + 'k'
return (count / 1000).toFixed(1) + ''
}
return String(count)
},
// 帖子类型英文转中文显示(仅用于展示,保证 label 均为中文)
// 帖子类型英文/拼音转中文显示(仅用于展示,保证 label 均为中文)
getMealTypeLabel(mealType) {
if (!mealType) return '分享'
const map = {
@@ -435,7 +441,16 @@ export default {
dinner: '晚餐',
snack: '加餐',
share: '分享',
checkin: '打卡'
checkin: '打卡',
zaocan: '早餐',
wucan: '午餐',
wancan: '晚餐',
jiacan: '加餐',
fenxiang: '分享',
daka: '打卡',
morning: '早餐',
noon: '午餐',
night: '晚餐'
}
const str = String(mealType).trim()
const lower = str.toLowerCase()