list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <Container title="公告列表" :scrollStyle="{ padding: 0 }" :showBack="false">
  3. <view class="notice-page">
  4. <!-- 公告列表 -->
  5. <view class="notice-list" v-if="noticeList !='' && noticeList != null">
  6. <!-- 公告项1 -->
  7. <view class="notice-item" v-for="(item, index) in noticeList" :key="index" @click="handleItemClick(item)">
  8. <view class="notice-icon">
  9. <image
  10. class="notice-icon-image"
  11. src="https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/8DvVCq6w7CN97Mxdp68vje9WCi8RjKXDC5KwHOOY.png"
  12. mode="aspectFill"
  13. ></image>
  14. </view>
  15. <view class="notice-content" :id="'content-' + index">
  16. <view class="notice-title">{{ item.title }}</view>
  17. <view class="notice-time">{{ formatTimestamp(item.insert_time)}}</view>
  18. </view>
  19. <navigator class="navigator_item" open-type="navigate" :url="'/pages/notice/detail?id=' + item.id">
  20. <view class="notice-link">
  21. <image
  22. class="notice-link-image"
  23. src="https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/05/jYNQJdKYavtqeVoq7bxwYFuF258jFm3sNWVSX1SS.png"
  24. mode="aspectFill"
  25. ></image>
  26. </view>
  27. </navigator>
  28. </view>
  29. </view>
  30. </view>
  31. </Container>
  32. </template>
  33. <script>
  34. import Container from '../../components/Container/Container.vue';
  35. import CustomerService from '@/components/CustomerService/CustomerService.vue';
  36. export default {
  37. data() {
  38. return {
  39. page: '1',
  40. limit: '10',
  41. noticeLink_top: [],
  42. noticeList: []
  43. };
  44. },
  45. mounted() {},
  46. onLoad() {
  47. this.topicnotice_system_list();
  48. },
  49. methods: {
  50. formatTimestamp(timestamp) {
  51. if (timestamp) {
  52. timestamp = timestamp * 1000;
  53. }
  54. const date = new Date(timestamp);
  55. const year = date.getFullYear();
  56. const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,要 +1
  57. const day = String(date.getDate()).padStart(2, '0');
  58. const hours = String(date.getHours()).padStart(2, '0');
  59. const minutes = String(date.getMinutes()).padStart(2, '0');
  60. const seconds = String(date.getSeconds()).padStart(2, '0');
  61. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  62. },
  63. async topicnotice_system_list() {
  64. this.$http.request('api/question_bank/question_reception/notice/list', { page: this.page, limit: this.limit }).then((callback) => {
  65. if (callback.code == 'success') {
  66. let page = this.page;
  67. if (page == 1) {
  68. this.noticeList = callback.data.data;
  69. } else {
  70. this.noticeList.push(...callback.data.data);
  71. }
  72. if (callback.data.data == '') {
  73. this.noMore = true;
  74. } else {
  75. this.noMore = false;
  76. }
  77. } else {
  78. uni.showToast({
  79. title: callback.msg,
  80. icon: 'none'
  81. });
  82. }
  83. });
  84. },
  85. handleItemClick(item) {
  86. // 处理点击事件
  87. console.log('点击公告:');
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss">
  93. .notice-page {
  94. background-color: #f5f5f5;
  95. min-height: 100vh;
  96. .notice-list {
  97. background-color: #fff;
  98. border-radius: 12rpx;
  99. overflow: hidden;
  100. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  101. .notice-item {
  102. display: flex;
  103. align-items: center;
  104. padding: 24rpx 30rpx;
  105. border-bottom: 1rpx solid #eee;
  106. position: relative;
  107. height: 128rpx;
  108. .notice-icon {
  109. position: absolute;
  110. top: 22rpx;
  111. width: 60rpx;
  112. height: 60rpx;
  113. margin-right: 20rpx;
  114. }
  115. .notice-link {
  116. position: absolute;
  117. right: 0rpx;
  118. width: 50rpx;
  119. height: 50rpx;
  120. margin-right: 20rpx;
  121. top:67rpx;
  122. }
  123. .notice-link-image,
  124. .notice-icon-image {
  125. width: 50rpx;
  126. height: 50rpx;
  127. }
  128. .notice-content {
  129. flex: 1;
  130. margin-left: 60rpx;
  131. margin-right: 60rpx;
  132. .notice-title {
  133. font-size: 30rpx;
  134. color: #333;
  135. margin-bottom: 10rpx;
  136. line-height: 1.4;
  137. display: -webkit-box;
  138. -webkit-box-orient: vertical;
  139. -webkit-line-clamp: 2;
  140. overflow: hidden;
  141. text-overflow: ellipsis;
  142. }
  143. .notice-time {
  144. font-size: 24rpx;
  145. color: #999;
  146. }
  147. }
  148. }
  149. }
  150. }
  151. </style>