feat(反馈): 修改反馈详情页跳转链接并支持反馈类型

重构文章详情页以支持反馈类型,添加获取反馈详情和标记已读功能
This commit is contained in:
砂糖
2025-11-07 10:45:43 +08:00
parent 884b1bb311
commit 750f66441b
2 changed files with 262 additions and 198 deletions

View File

@@ -13,7 +13,8 @@
<!-- 用户信息 --> <!-- 用户信息 -->
<view class="user-info"> <view class="user-info">
<image v-if="article.avatar" class="user-avatar" :src="article.avatar || '/static/default-avatar.png'" mode="cover"></image> <image v-if="article.avatar" class="user-avatar" :src="article.avatar || '/static/default-avatar.png'"
mode="cover"></image>
<view class="user-meta"> <view class="user-meta">
<view class="user-name"> <view class="user-name">
{{ article.author || '未知用户' }} {{ article.author || '未知用户' }}
@@ -41,9 +42,15 @@
</template> </template>
<script> <script>
import { getNotice } from '@/api/oa/notice'; import {
getNotice
} from '@/api/oa/notice';
import {
getFeedback,
toRead
} from "@/api/oa/feedback";
export default { export default {
data() { data() {
return { return {
article: null, article: null,
@@ -51,9 +58,15 @@ export default {
}; };
}, },
onLoad(options) { onLoad(options) {
const { type, id } = options; const {
type,
id
} = options;
if (!type || !id) { if (!type || !id) {
uni.showToast({ title: '参数错误', icon: 'none' }); uni.showToast({
title: '参数错误',
icon: 'none'
});
setTimeout(() => uni.navigateBack(), 1000); setTimeout(() => uni.navigateBack(), 1000);
return; return;
} }
@@ -72,149 +85,200 @@ export default {
title: res.data.noticeTitle, title: res.data.noticeTitle,
content: res.data.noticeContent, content: res.data.noticeContent,
}; };
uni.setNavigationBarTitle({
title: '通知详情'
})
this.loading = false; this.loading = false;
}) })
.catch(err => { .catch(err => {
console.error('获取文章失败', err); console.error('获取文章失败', err);
this.article = null; this.article = null;
this.loading = false; this.loading = false;
uni.showToast({ title: '加载失败', icon: 'none' }); uni.showToast({
title: '加载失败',
icon: 'none'
});
});
break;
case 'feedback':
getFeedback(id)
.then(res => {
if (res.data) {
this.article = res.data;
uni.setNavigationBarTitle({
title: '反馈详情'
})
// 标记为已读
toRead(this.article);
} else {
uni.showToast({
title: '未找到消息',
icon: 'none'
});
}
})
.catch(err => {
uni.showToast({
title: err.message || '获取消息失败',
icon: 'none'
});
})
.finally(() => {
this.loading = false;
}); });
break; break;
default: default:
uni.showToast({ title: '未知类型', icon: 'none' }); uni.showToast({
title: '未知类型',
icon: 'none'
});
setTimeout(() => uni.navigateBack(), 1000); setTimeout(() => uni.navigateBack(), 1000);
break; break;
} }
}, },
reload() { reload() {
const { type, id } = this.$options.onLoad.options; const {
type,
id
} = this.$options.onLoad.options;
this.fetchData(type, id); this.fetchData(type, id);
}, },
navigateBack() { navigateBack() {
uni.navigateBack(); uni.navigateBack();
} }
} }
}; };
</script> </script>
<style scoped> <style scoped>
.article-container { .article-container {
min-height: 100vh; min-height: 100vh;
background-color: #fff; background-color: #fff;
} }
.loading { .loading {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 50px 0; padding: 50px 0;
} }
.loading-text {
.loading-text {
margin-top: 10px; margin-top: 10px;
color: #666; color: #666;
font-size: 14px; font-size: 14px;
} }
.error { .error {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 50px 0; padding: 50px 0;
} }
.error-text {
.error-text {
margin: 15px 0; margin: 15px 0;
color: #ff4d4f; color: #ff4d4f;
font-size: 16px; font-size: 16px;
} }
.retry-btn {
.retry-btn {
background-color: #007aff; background-color: #007aff;
color: #fff; color: #fff;
border-radius: 4px; border-radius: 4px;
padding: 8px 20px; padding: 8px 20px;
font-size: 14px; font-size: 14px;
} }
.article-content { .article-content {
padding: 16px; padding: 16px;
} }
.post-title { .post-title {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
margin-bottom: 12px; margin-bottom: 12px;
line-height: 1.4; line-height: 1.4;
} }
.user-info { .user-info {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 16px; margin-bottom: 16px;
} }
.user-avatar {
.user-avatar {
width: 40px; width: 40px;
height: 40px; height: 40px;
border-radius: 50%; border-radius: 50%;
margin-right: 10px; margin-right: 10px;
} }
.user-meta {
.user-meta {
flex: 1; flex: 1;
} }
.user-name {
.user-name {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
color: #333; color: #333;
margin-bottom: 4px; margin-bottom: 4px;
} }
.user-level {
.user-level {
background-color: #dff0d8; background-color: #dff0d8;
color: #5cb85c; color: #5cb85c;
font-size: 10px; font-size: 10px;
padding: 1px 4px; padding: 1px 4px;
border-radius: 3px; border-radius: 3px;
margin-left: 6px; margin-left: 6px;
} }
.user-time-area {
.user-time-area {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
} }
.follow-btn {
.follow-btn {
font-size: 12px; font-size: 12px;
color: #5cb85c; color: #5cb85c;
background-color: #e8f5e9; background-color: #e8f5e9;
padding: 4px 8px; padding: 4px 8px;
border-radius: 12px; border-radius: 12px;
} }
.mp-html { .mp-html {
font-size: 15px; font-size: 15px;
color: #333; color: #333;
line-height: 1.8; line-height: 1.8;
} }
.mp-html img {
.mp-html img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
margin: 10px 0; margin: 10px 0;
border-radius: 8px; border-radius: 8px;
} }
.interact-area { .interact-area {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
margin-top: 20px; margin-top: 20px;
padding: 10px 0; padding: 10px 0;
border-top: 1px solid #eee; border-top: 1px solid #eee;
} }
.interact-item {
.interact-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
font-size: 12px; font-size: 12px;
color: #999; color: #999;
} }
.interact-count {
.interact-count {
margin-top: 4px; margin-top: 4px;
} }
</style> </style>

View File

@@ -219,7 +219,7 @@
// 跳转到详情页 // 跳转到详情页
navigateToDetail(msg) { navigateToDetail(msg) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/workbench/feedback/detail?feedbackId=${msg.feedbackId}` url: `/pages/workbench/article/article?id=${msg.feedbackId}&type=feedback`
}); });
}, },