图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.0 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="feedback-detail-page">
  3. <view class="section">
  4. <text class="subject">{{ detail.title }}</text>
  5. <view class="section-content">{{ detail.suggestion }}</view>
  6. <text class="time">{{ formatTimestamp(detail.suggestionTime) }}</text>
  7. </view>
  8. <view class="section reply-section">
  9. <view class="section-title">馆方回复</view>
  10. <view class="section-content" v-if="detail.reply">{{ detail.reply }}</view>
  11. <view class="section-content no-reply" v-else>暂未回复~</view>
  12. <text class="time" v-if="detail.reply">{{ formatTimestamp(detail.replyTime) }}</text>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { FetchReaderMessageDetailsById } from '@/api/user';
  18. export default {
  19. data() {
  20. return {
  21. detail: {}
  22. };
  23. },
  24. onLoad(options) {
  25. if (options.item) {
  26. this.detail = JSON.parse(decodeURIComponent(options.item));
  27. this.getReaderMessageDetailsById();
  28. }
  29. },
  30. methods: {
  31. async getReaderMessageDetailsById(){
  32. try {
  33. // 检查 id 是否存在
  34. if (!this.detail.id) {
  35. console.warn('缺少留言 ID');
  36. return;
  37. }
  38. const res = await FetchReaderMessageDetailsById({
  39. id: this.detail.id
  40. });
  41. console.log(res);
  42. if (res && res.code === 200) {
  43. this.detail = res.data || {};
  44. } else {
  45. uni.showToast({ title: res?.msg || '获取留言详情失败', icon: 'none' });
  46. }
  47. } catch (error) {
  48. console.error('获取留言详情异常:', error);
  49. uni.showToast({ title: '获取留言详情失败', icon: 'none' });
  50. }
  51. },
  52. formatTimestamp(timestamp) {
  53. if (!timestamp || typeof timestamp !== 'number') {
  54. return '暂无时间';
  55. }
  56. const date = new Date(timestamp);
  57. const year = date.getFullYear();
  58. const month = String(date.getMonth() + 1).padStart(2, '0');
  59. const day = String(date.getDate()).padStart(2, '0');
  60. const hours = String(date.getHours()).padStart(2, '0');
  61. const minutes = String(date.getMinutes()).padStart(2, '0');
  62. return `${year}-${month}-${day} ${hours}:${minutes}`;
  63. }
  64. }
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .feedback-detail-page {
  69. padding: 15px;
  70. background-color: #f7f8fa;
  71. min-height: 100vh;
  72. }
  73. .section {
  74. background-color: #fff;
  75. border-radius: 10px;
  76. padding: 15px;
  77. margin-bottom: 12px;
  78. }
  79. .section-title {
  80. font-size: 14px;
  81. font-weight: bold;
  82. color: #333;
  83. margin-bottom: 10px;
  84. }
  85. .section-content {
  86. font-size: 15px;
  87. color: #666;
  88. line-height: 1.6;
  89. margin-bottom: 6px;
  90. }
  91. .section-content:last-child {
  92. margin-bottom: 0;
  93. }
  94. .subject {
  95. font-size: 16px;
  96. font-weight: bold;
  97. color: #333;
  98. display: block;
  99. margin-bottom: 10px;
  100. }
  101. .time {
  102. font-size: 12px;
  103. color: #999;
  104. display: block;
  105. text-align: right;
  106. }
  107. .no-reply {
  108. color: #999;
  109. font-style: italic;
  110. }
  111. .reply-section {
  112. background-color: #f0f9ff;
  113. }
  114. </style>