detail.vue 5.6 KB

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