History.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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>
  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. color: #1e80ff;
  106. }
  107. .entry-list{
  108. width: 100%;
  109. background-color: #fff;
  110. position: relative;
  111. }
  112. .list-item:hover {
  113. background: #fafafa;
  114. }
  115. .list-item{
  116. position: relative;
  117. cursor: pointer;
  118. padding: 12px 20px 0;
  119. }
  120. .list-item .meta-container{
  121. display: flex;
  122. align-items: center;
  123. }
  124. .list-item .meta-container .user-message{
  125. max-width: 162px;
  126. font-size: 13px;
  127. line-height: 22px;
  128. color: #4e5969;
  129. white-space: nowrap;
  130. overflow: hidden;
  131. text-overflow: ellipsis;
  132. word-break: break-all;
  133. }
  134. .list-item .meta-container .dividing{
  135. line-height: 22px;
  136. width: 1px;
  137. height: 14px;
  138. background: #e5e6eb;
  139. margin: 0 8px;
  140. }
  141. .list-item .meta-container .date{
  142. line-height: 22px;
  143. font-size: 13px;
  144. color: #86909c;
  145. }
  146. .list-item .main{
  147. margin-top: 6px;
  148. padding-bottom: 12px;
  149. display: flex;
  150. border-bottom: 1px solid #e5e6eb;
  151. }
  152. .list-item .main .info-box{
  153. flex-grow: 1;
  154. }
  155. .list-item .main .info-box .title:visited {
  156. color: #86909c;
  157. }
  158. .list-item .main .info-box .title{
  159. font-weight: 700;
  160. font-size: 16px;
  161. line-height: 24px;
  162. color: #1d2129;
  163. margin-bottom: 8px;
  164. display: -webkit-box;
  165. overflow: hidden;
  166. text-overflow: ellipsis;
  167. -webkit-box-orient: vertical;
  168. -webkit-line-clamp: 1;
  169. }
  170. .list-item .main .info-box .description{
  171. font-weight: 400;
  172. font-size: 13px;
  173. line-height: 22px;
  174. color: #86909c;
  175. display: -webkit-box;
  176. overflow: hidden;
  177. text-overflow: ellipsis;
  178. -webkit-box-orient: vertical;
  179. -webkit-line-clamp: 2;
  180. }
  181. .list-item .thumb{
  182. flex: 0 0 auto;
  183. width: 120px;
  184. height: 80px;
  185. margin-left: 24px;
  186. border-radius: 2px;
  187. }
  188. </style>