detail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 #376DF7;
  113. border-radius: 200rpx 200rpx 200rpx 200rpx;
  114. font-size: 27rpx;
  115. color: #376DF7;
  116. }
  117. .next-title {
  118. width: 25%;
  119. min-width: 120rpx;
  120. line-height: 30rpx;
  121. padding: 15rpx 15rpx;
  122. border: 1rpx solid #376DF7;
  123. border-radius: 200rpx 200rpx 200rpx 200rpx;
  124. font-size: 27rpx;
  125. color: #376DF7;
  126. }
  127. .show-all-content {
  128. width: 30%;
  129. line-height: 30rpx;
  130. padding: 15rpx 15rpx;
  131. margin: 0rpx 20rpx;
  132. // border: 1rpx solid #999999;
  133. border-radius: 200rpx 200rpx 200rpx 200rpx;
  134. font-size: 27rpx;
  135. background: #376DF7;
  136. font-size: 27rpx;
  137. color: #FFFFFF;
  138. }
  139. }
  140. .notice-detail {
  141. padding: 10rpx 30rpx 10rpx 30rpx;
  142. background-color: #fff;
  143. min-height: 100vh;
  144. .next-title {
  145. font-size: 28rpx;
  146. color: #999;
  147. margin-bottom: 20rpx;
  148. }
  149. .notice-main-title {
  150. font-size: 40rpx;
  151. font-weight: bold;
  152. line-height: 1.5;
  153. color: #333;
  154. margin-bottom: 20rpx;
  155. }
  156. .notice-time {
  157. font-size: 26rpx;
  158. color: #999;
  159. margin-bottom: 40rpx;
  160. }
  161. .notice-content {
  162. font-size: 30rpx;
  163. line-height: 1.8;
  164. color: #333;
  165. .notice-subtitle {
  166. font-size: 34rpx;
  167. font-weight: bold;
  168. margin: 40rpx 0 20rpx;
  169. color: #333;
  170. }
  171. .notice-quote {
  172. font-size: 28rpx;
  173. color: #666;
  174. margin-bottom: 40rpx;
  175. padding-left: 20rpx;
  176. border-left: 6rpx solid #1a8cff;
  177. }
  178. .notice-paragraph {
  179. margin-bottom: 40rpx;
  180. text-align: justify;
  181. }
  182. .notice-section-title {
  183. font-size: 34rpx;
  184. font-weight: bold;
  185. margin: 50rpx 0 30rpx;
  186. color: #333;
  187. position: relative;
  188. padding-left: 20rpx;
  189. &::before {
  190. content: '';
  191. position: absolute;
  192. left: 0;
  193. top: 10rpx;
  194. height: 30rpx;
  195. width: 8rpx;
  196. background-color: #1a8cff;
  197. border-radius: 4rpx;
  198. }
  199. }
  200. .notice-highlight {
  201. margin-bottom: 30rpx;
  202. background-color: #f8f9fa;
  203. border-radius: 12rpx;
  204. padding: 20rpx;
  205. .highlight-title {
  206. font-weight: bold;
  207. margin-bottom: 15rpx;
  208. color: #1a8cff;
  209. }
  210. .highlight-item {
  211. margin-left: 30rpx;
  212. margin-bottom: 10rpx;
  213. }
  214. }
  215. .notice-info {
  216. margin-bottom: 25rpx;
  217. display: flex;
  218. .info-title {
  219. font-weight: bold;
  220. min-width: 140rpx;
  221. }
  222. .info-content {
  223. flex: 1;
  224. view {
  225. margin-bottom: 10rpx;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. </style>