detail.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <Container title="公告列表" :scrollStyle="{ padding: 0 }">
  3. <view class="notice-header">
  4. <!-- 上一篇标题 -->
  5. <view class="upper-title" @click="get_notice_detail_prev()">{{ '< 上一篇' }}</view>
  6. <!-- 显示全部内容 -->
  7. <view class="show-all-content" @click="goto_notice_list()">显示全部</view>
  8. <!-- 下一篇标题 -->
  9. <view class="next-title" @click="get_notice_detail_next()">{{ '下一篇 >' }}</view>
  10. </view>
  11. <view class="notice-detail" v-if="notice_data !='' && notice_data !=null">
  12. <!-- 公告标题 -->
  13. <view class="notice-main-title">{{ notice_data.title }}</view>
  14. <!-- 发布时间 -->
  15. <view class="notice-time">{{ formatTimestamp(notice_data.insert_time)}}</view>
  16. <!-- 公告内容 -->
  17. <view class="notice-content">
  18. <rich-text :nodes="htmlContent"></rich-text>
  19. </view>
  20. </view>
  21. </Container>
  22. </template>
  23. <script>
  24. import Container from '../../components/Container/Container.vue';
  25. import CustomerService from '@/components/CustomerService/CustomerService.vue';
  26. export default {
  27. data() {
  28. return {
  29. notice_id: '',
  30. notice_data: [],
  31. htmlContent:''
  32. };
  33. },
  34. mounted() {},
  35. onLoad(param) {
  36. this.notice_id = param.id;
  37. this.get_notice_detail();
  38. },
  39. methods: {
  40. goto_notice_list(){
  41. uni.redirectTo({
  42. url: 'list?refresh=' + Date.now()
  43. });
  44. },
  45. formatTimestamp(timestamp) {
  46. if (timestamp) {
  47. timestamp = timestamp * 1000;
  48. }
  49. const date = new Date(timestamp);
  50. const year = date.getFullYear();
  51. const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,要 +1
  52. const day = String(date.getDate()).padStart(2, '0');
  53. const hours = String(date.getHours()).padStart(2, '0');
  54. const minutes = String(date.getMinutes()).padStart(2, '0');
  55. const seconds = String(date.getSeconds()).padStart(2, '0');
  56. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  57. },
  58. async get_notice_detail() {
  59. this.$http.request('api/question_bank/question_reception/notice/detail', { id: this.notice_id}).then((callback) => {
  60. if (callback.code == 'success') {
  61. this.notice_data = callback.data;
  62. this.htmlContent=callback.data.content;
  63. } else {
  64. uni.showToast({
  65. title: callback.msg,
  66. icon: 'none'
  67. });
  68. }
  69. });
  70. },
  71. async get_notice_detail_next() {
  72. this.$http.request('api/question_bank/question_reception/notice/next', { id: this.notice_id}).then((callback) => {
  73. if (callback.code == 'success') {
  74. this.notice_data = callback.data;
  75. this.htmlContent=callback.data.content;
  76. this.notice_id=callback.data.id;
  77. } else {
  78. uni.showToast({
  79. title: '没有更多内容了',
  80. icon: 'none'
  81. });
  82. }
  83. });
  84. },
  85. async get_notice_detail_prev() {
  86. this.$http.request('api/question_bank/question_reception/notice/prev', { id: this.notice_id}).then((callback) => {
  87. if (callback.code == 'success') {
  88. this.notice_data = callback.data;
  89. this.htmlContent=callback.data.content;
  90. this.notice_id=callback.data.id;
  91. } else {
  92. uni.showToast({
  93. title: '没有更多内容了',
  94. icon: 'none'
  95. });
  96. }
  97. });
  98. },
  99. }
  100. };
  101. </script>
  102. <style lang="scss">
  103. .notice-header {
  104. padding: 30rpx 30rpx 20rpx 30rpx;
  105. display: flex;
  106. text-align: center;
  107. .upper-title {
  108. width: 25%;
  109. min-width: 120rpx;
  110. line-height: 30rpx;
  111. padding: 15rpx 15rpx;
  112. border: 1rpx solid #999999;
  113. border-radius: 200rpx 200rpx 200rpx 200rpx;
  114. font-size: 27rpx;
  115. }
  116. .next-title {
  117. width: 25%;
  118. min-width: 120rpx;
  119. line-height: 30rpx;
  120. padding: 15rpx 15rpx;
  121. border: 1rpx solid #999999;
  122. border-radius: 200rpx 200rpx 200rpx 200rpx;
  123. font-size: 27rpx;
  124. }
  125. .show-all-content {
  126. width: 30%;
  127. line-height: 30rpx;
  128. padding: 15rpx 15rpx;
  129. margin: 0rpx 20rpx;
  130. border: 1rpx solid #999999;
  131. border-radius: 200rpx 200rpx 200rpx 200rpx;
  132. font-size: 27rpx;
  133. }
  134. }
  135. .notice-detail {
  136. padding: 10rpx 30rpx 10rpx 30rpx;
  137. background-color: #fff;
  138. min-height: 100vh;
  139. .next-title {
  140. font-size: 28rpx;
  141. color: #999;
  142. margin-bottom: 20rpx;
  143. }
  144. .notice-main-title {
  145. font-size: 40rpx;
  146. font-weight: bold;
  147. line-height: 1.5;
  148. color: #333;
  149. margin-bottom: 20rpx;
  150. }
  151. .notice-time {
  152. font-size: 26rpx;
  153. color: #999;
  154. margin-bottom: 40rpx;
  155. }
  156. .notice-content {
  157. font-size: 30rpx;
  158. line-height: 1.8;
  159. color: #333;
  160. .notice-subtitle {
  161. font-size: 34rpx;
  162. font-weight: bold;
  163. margin: 40rpx 0 20rpx;
  164. color: #333;
  165. }
  166. .notice-quote {
  167. font-size: 28rpx;
  168. color: #666;
  169. margin-bottom: 40rpx;
  170. padding-left: 20rpx;
  171. border-left: 6rpx solid #1a8cff;
  172. }
  173. .notice-paragraph {
  174. margin-bottom: 40rpx;
  175. text-align: justify;
  176. }
  177. .notice-section-title {
  178. font-size: 34rpx;
  179. font-weight: bold;
  180. margin: 50rpx 0 30rpx;
  181. color: #333;
  182. position: relative;
  183. padding-left: 20rpx;
  184. &::before {
  185. content: '';
  186. position: absolute;
  187. left: 0;
  188. top: 10rpx;
  189. height: 30rpx;
  190. width: 8rpx;
  191. background-color: #1a8cff;
  192. border-radius: 4rpx;
  193. }
  194. }
  195. .notice-highlight {
  196. margin-bottom: 30rpx;
  197. background-color: #f8f9fa;
  198. border-radius: 12rpx;
  199. padding: 20rpx;
  200. .highlight-title {
  201. font-weight: bold;
  202. margin-bottom: 15rpx;
  203. color: #1a8cff;
  204. }
  205. .highlight-item {
  206. margin-left: 30rpx;
  207. margin-bottom: 10rpx;
  208. }
  209. }
  210. .notice-info {
  211. margin-bottom: 25rpx;
  212. display: flex;
  213. .info-title {
  214. font-weight: bold;
  215. min-width: 140rpx;
  216. }
  217. .info-content {
  218. flex: 1;
  219. view {
  220. margin-bottom: 10rpx;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>