History.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="entry-list-container">
  6. 历史总积分排行
  7. </div>
  8. </div>
  9. <SiderInfo></SiderInfo>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import { msgList } from "@/api/allApi";
  15. import SiderInfo from '@/components/SiderInfo.vue'
  16. export default{
  17. components: {
  18. SiderInfo,
  19. },
  20. data() {
  21. return {
  22. dataList:[],
  23. page:1,
  24. pages:1,
  25. };
  26. },
  27. created(){
  28. this.getDataList();
  29. },
  30. methods:{
  31. handleClickMag(id) {
  32. this.$router.push({
  33. path: '/home/index/msgDetail',
  34. query: {
  35. id: id,
  36. }
  37. });
  38. },
  39. getDataList(){
  40. let data = {
  41. limit:10,
  42. page:this.page,
  43. type:0,
  44. };
  45. msgList(data).then(response=>{
  46. if(this.page==1){
  47. this.dataList = response.data.data.list;
  48. this.page = response.data.data.pageNum;
  49. this.pages = response.data.data.pages;
  50. }else{
  51. this.dataList = [
  52. ...this.dataList,
  53. ...response.data.data.list
  54. ]
  55. }
  56. ++this.page
  57. })
  58. },
  59. // 保存滚动值,这是兼容的写法
  60. handleScroll () {
  61. if((document.documentElement.scrollTop + window.innerHeight) == document.body.offsetHeight){
  62. if(this.page > this.pages){
  63. return
  64. }else{
  65. this.getDataList();
  66. }
  67. }
  68. },
  69. },
  70. mounted () {
  71. window.addEventListener('scroll', this.handleScroll, true)
  72. },
  73. destroyed () {
  74. // 离开该页面需要移除这个监听的事件,不然会报错
  75. window.removeEventListener('scroll', this.handleScroll)
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .timeline-container{
  81. margin: 0 auto;
  82. }
  83. .timeline-entry-list{
  84. margin-right: 17.5rem;
  85. border-radius: 2px;
  86. width: 720px;
  87. position: relative;
  88. }
  89. .entry-list-container{
  90. background-color: #fff;
  91. border-radius: 4px;
  92. }
  93. .entry-list-container .tab-header {
  94. display: flex;
  95. align-items: center;
  96. justify-content: space-between;
  97. padding: 20px 20px 16px;
  98. border-bottom: 1px solid #e5e6eb;
  99. overflow: hidden;
  100. }
  101. .tab-header .tab-title {
  102. white-space: nowrap;
  103. font-size: 18px;
  104. font-weight: 600;
  105. }
  106. .entry-list{
  107. width: 100%;
  108. background-color: #fff;
  109. position: relative;
  110. }
  111. .list-item:hover {
  112. background: #fafafa;
  113. }
  114. .list-item{
  115. position: relative;
  116. cursor: pointer;
  117. padding: 12px 20px 0;
  118. }
  119. .list-item .meta-container{
  120. display: flex;
  121. align-items: center;
  122. }
  123. .list-item .meta-container .user-message{
  124. max-width: 162px;
  125. font-size: 13px;
  126. line-height: 22px;
  127. color: #4e5969;
  128. white-space: nowrap;
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. word-break: break-all;
  132. }
  133. .list-item .meta-container .dividing{
  134. line-height: 22px;
  135. width: 1px;
  136. height: 14px;
  137. background: #e5e6eb;
  138. margin: 0 8px;
  139. }
  140. .list-item .meta-container .date{
  141. line-height: 22px;
  142. font-size: 13px;
  143. color: #86909c;
  144. }
  145. .list-item .main{
  146. margin-top: 6px;
  147. padding-bottom: 12px;
  148. display: flex;
  149. border-bottom: 1px solid #e5e6eb;
  150. }
  151. .list-item .main .info-box{
  152. flex-grow: 1;
  153. }
  154. .list-item .main .info-box .title:visited {
  155. color: #86909c;
  156. }
  157. .list-item .main .info-box .title{
  158. font-weight: 700;
  159. font-size: 16px;
  160. line-height: 24px;
  161. color: #1d2129;
  162. margin-bottom: 8px;
  163. display: -webkit-box;
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. -webkit-box-orient: vertical;
  167. -webkit-line-clamp: 1;
  168. }
  169. .list-item .main .info-box .description{
  170. font-weight: 400;
  171. font-size: 13px;
  172. line-height: 22px;
  173. color: #86909c;
  174. display: -webkit-box;
  175. overflow: hidden;
  176. text-overflow: ellipsis;
  177. -webkit-box-orient: vertical;
  178. -webkit-line-clamp: 2;
  179. }
  180. .list-item .thumb{
  181. flex: 0 0 auto;
  182. width: 120px;
  183. height: 80px;
  184. margin-left: 24px;
  185. border-radius: 2px;
  186. }
  187. </style>