图书馆小程序
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.

130 lines
2.9 KiB

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