Index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="hot-list-wrap">
  6. <el-empty :image-size="200" v-if="bannerList.length < 1"></el-empty>
  7. <el-carousel arrow="never" indicator-position="none" height="207px" :interval="5000" v-if="bannerList.length > 0">
  8. <el-carousel-item v-for="(item, index) in bannerList" :key="index">
  9. <!-- <router-link to="/productTrials"> -->
  10. <img style="width: 100%; height: 100%" :src="item.url" />
  11. <!-- </router-link> -->
  12. </el-carousel-item>
  13. </el-carousel>
  14. </div>
  15. <div class="entry-list-container">
  16. <div class="tab-header">
  17. <span class="tab-title">最新通知</span>
  18. </div>
  19. <el-empty v-if="dataList.length==0" :image-size="200"></el-empty>
  20. <div v-else class="entry-list">
  21. <div v-for="(item,index) in dataList" :key="index" @click="handleClickMag(item.msgId)" class="list-item">
  22. <div class="meta-container">
  23. <div class="user-message">
  24. 系统通知
  25. </div>
  26. <div class="dividing"></div>
  27. <div class="date">{{ item.createTime }}</div>
  28. </div>
  29. <div class="main">
  30. <div class="info-box">
  31. <div class="title">
  32. {{ item.title }}
  33. </div>
  34. <div class="description">
  35. {{ item.subTitle }}
  36. </div>
  37. </div>
  38. <img v-if="item.imgUrl" :src="item.imgUrl" :alt="item.title" class="lazy thumb">
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <SiderInfo></SiderInfo>
  45. </div>
  46. </div>
  47. </template>
  48. <script scoped>
  49. import { msgList } from "@/api/allApi";
  50. import SiderInfo from '@/components/SiderInfo.vue'
  51. export default{
  52. components: {
  53. SiderInfo
  54. },
  55. data() {
  56. return {
  57. bannerList: [
  58. {
  59. url: require('@/assets/image/banner.png')
  60. },
  61. {
  62. url: require('@/assets/image/banner.jpg')
  63. },
  64. ],
  65. dataList:[],
  66. page:1,
  67. pages:1,
  68. };
  69. },
  70. created(){
  71. this.getDataList();
  72. },
  73. methods:{
  74. handleClickMag(id) {
  75. this.$router.push({
  76. path: '/home/index/msgDetail',
  77. query: {
  78. id: id,
  79. }
  80. });
  81. },
  82. getDataList(){
  83. let data = {
  84. limit:10,
  85. page:this.page,
  86. type:0,
  87. };
  88. msgList(data).then(response=>{
  89. if(this.page==1){
  90. this.dataList = response.data.data.list;
  91. this.page = response.data.data.pageNum;
  92. this.pages = response.data.data.pages;
  93. }else{
  94. this.dataList = [
  95. ...this.dataList,
  96. ...response.data.data.list
  97. ]
  98. }
  99. ++this.page
  100. })
  101. },
  102. // 保存滚动值,这是兼容的写法
  103. handleScroll () {
  104. if((document.documentElement.scrollTop + window.innerHeight) == document.body.offsetHeight){
  105. if(this.page > this.pages){
  106. return
  107. }else{
  108. this.getDataList();
  109. }
  110. }
  111. },
  112. },
  113. mounted () {
  114. window.addEventListener('scroll', this.handleScroll)
  115. },
  116. destroyed () {
  117. // 离开该页面需要移除这个监听的事件,不然会报错
  118. window.removeEventListener('scroll', this.handleScroll)
  119. }
  120. }
  121. </script>
  122. <style scoped>
  123. .timeline-container{
  124. margin: 0 auto;
  125. }
  126. .timeline-entry-list{
  127. margin-right: 17.5rem;
  128. border-radius: 2px;
  129. width: 720px;
  130. position: relative;
  131. }
  132. .entry-list-container{
  133. background-color: #fff;
  134. border-radius: 4px;
  135. }
  136. .entry-list-container .tab-header {
  137. display: flex;
  138. align-items: center;
  139. justify-content: space-between;
  140. padding: 20px 20px 16px;
  141. border-bottom: 1px solid #e5e6eb;
  142. overflow: hidden;
  143. }
  144. .tab-header .tab-title {
  145. white-space: nowrap;
  146. font-size: 18px;
  147. font-weight: 600;
  148. }
  149. .entry-list{
  150. width: 100%;
  151. background-color: #fff;
  152. position: relative;
  153. }
  154. .list-item:hover {
  155. background: #fafafa;
  156. }
  157. .list-item{
  158. position: relative;
  159. cursor: pointer;
  160. padding: 12px 20px 0;
  161. }
  162. .list-item .meta-container{
  163. display: flex;
  164. align-items: center;
  165. }
  166. .list-item .meta-container .user-message{
  167. max-width: 162px;
  168. font-size: 13px;
  169. line-height: 22px;
  170. color: #4e5969;
  171. white-space: nowrap;
  172. overflow: hidden;
  173. text-overflow: ellipsis;
  174. word-break: break-all;
  175. }
  176. .list-item .meta-container .dividing{
  177. line-height: 22px;
  178. width: 1px;
  179. height: 14px;
  180. background: #e5e6eb;
  181. margin: 0 8px;
  182. }
  183. .list-item .meta-container .date{
  184. line-height: 22px;
  185. font-size: 13px;
  186. color: #86909c;
  187. }
  188. .list-item .main{
  189. margin-top: 6px;
  190. padding-bottom: 12px;
  191. display: flex;
  192. border-bottom: 1px solid #e5e6eb;
  193. }
  194. .list-item .main .info-box{
  195. flex-grow: 1;
  196. }
  197. .list-item .main .info-box .title:visited {
  198. color: #86909c;
  199. }
  200. .list-item .main .info-box .title{
  201. font-weight: 700;
  202. font-size: 16px;
  203. line-height: 24px;
  204. color: #1d2129;
  205. margin-bottom: 8px;
  206. display: -webkit-box;
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. -webkit-box-orient: vertical;
  210. -webkit-line-clamp: 1;
  211. }
  212. .list-item .main .info-box .description{
  213. font-weight: 400;
  214. font-size: 13px;
  215. line-height: 22px;
  216. color: #86909c;
  217. display: -webkit-box;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. -webkit-box-orient: vertical;
  221. -webkit-line-clamp: 2;
  222. }
  223. .list-item .thumb{
  224. flex: 0 0 auto;
  225. width: 120px;
  226. height: 80px;
  227. margin-left: 24px;
  228. border-radius: 2px;
  229. }
  230. </style>