items.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="news-item">
  3. <div class="empty" v-if="listInfo.total == 0">无快讯信息!</div>
  4. <a class="item" :href="'/news/' + item.nc_id + '?type=' + item.nc_type" v-for="item in listData">
  5. <div class="date">
  6. <p v-text="new Date(item.nc_publishdate).getDay()">1</p>
  7. <p v-text="formatTime(item.nc_publishdate)">Jan</p>
  8. </div>
  9. <div class="img" v-if="item.nc_image != null">
  10. <img :src="item.nc_image">
  11. </div>
  12. <div :class="{content_img: item.nc_image != null, content: item.nc_image == null}">
  13. <h4 v-text="item.nc_title">11</h4>
  14. <p v-text="item.nc_desc">11</p>
  15. <span v-text="item.nc_readnum" v-if="item.nc_image != null">323</span>
  16. </div>
  17. </a>
  18. <div class="page" v-if="listInfo.total > 10">
  19. <el-pagination
  20. @current-change="handleCurrentChange"
  21. :current-page="page"
  22. :page-size="count"
  23. layout="total, prev, pager, next, jumper"
  24. :total="listInfo.total"/>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'ItemView',
  31. data () {
  32. return {
  33. count: 10,
  34. page: 1
  35. }
  36. },
  37. computed: {
  38. listInfo () {
  39. return this.$store.state.news.list.data
  40. },
  41. listData () {
  42. return this.listInfo.list
  43. }
  44. },
  45. methods: {
  46. handleCurrentChange(val) {
  47. this.$store.dispatch('loadNewsList', {page: val, limit: this.count, type: this.step})
  48. },
  49. // 输出时间日期
  50. formatTime (row) {
  51. let count = new Date(row).getMonth()
  52. switch (count) {
  53. case 0 : return 'Jan'
  54. case 1 : return 'Feb'
  55. case 2 : return 'Mar'
  56. case 3 : return 'Apr'
  57. case 4 : return 'May'
  58. case 5 : return 'Jun'
  59. case 6 : return 'Jul'
  60. case 7 : return 'Aug'
  61. case 8 : return 'Sep'
  62. case 9 : return 'Oct'
  63. case 10 : return 'Nov'
  64. case 11 : return 'Dec'
  65. }
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped type="text/scss" lang="scss">
  71. .news-item{
  72. .empty{
  73. padding-top:120px;
  74. font-size: 30px;
  75. text-align: center;
  76. font-weight: bold;
  77. color:#333;
  78. }
  79. .page{
  80. padding:20px 0;
  81. text-align: center;
  82. }
  83. .item{
  84. position:relative;
  85. display:block;
  86. padding:35px 40px 35px 145px;
  87. border-bottom:1px solid #f1f1f1;
  88. &:hover{
  89. .date{
  90. p{
  91. color:#149ccf;
  92. }
  93. }
  94. .content{
  95. h4{
  96. color:#149ccf;
  97. }
  98. }
  99. .content_img{
  100. h4{
  101. color:#149ccf;
  102. }
  103. }
  104. }
  105. .date{
  106. position:absolute;
  107. top:35px;
  108. left:75px;
  109. width:70px;
  110. height:90px;
  111. background: #f4f4f4;
  112. text-align: center;
  113. p{
  114. font-size: 18px;
  115. font-weight: bold;
  116. color:#323232;
  117. margin:0;
  118. line-height: 45px;
  119. }
  120. }
  121. .img{
  122. display:inline-block;
  123. vertical-align: top;
  124. width:200px;
  125. height:160px;
  126. img{
  127. width:200px;
  128. height:160px;
  129. }
  130. }
  131. .content_img{
  132. width:520px;
  133. height:160px;
  134. display:inline-block;
  135. vertical-align: top;
  136. padding-left:30px;
  137. position:relative;
  138. h4{
  139. font-size: 20px;
  140. color:#1e1e1e;
  141. width:500px;
  142. overflow:hidden;
  143. text-overflow: ellipsis;
  144. white-space:nowrap;
  145. margin-bottom:25px;
  146. }
  147. p{
  148. font-size: 14px;
  149. color:#797979;
  150. line-height: 20px;
  151. overflow: hidden;
  152. text-overflow: ellipsis;
  153. display: -webkit-box;
  154. -webkit-line-clamp: 2;
  155. -webkit-box-orient: vertical;
  156. }
  157. span{
  158. position:absolute;
  159. bottom:0;
  160. left:25px;
  161. font-size: 14px;
  162. color:#797979;
  163. &:before{
  164. content: '';
  165. display: inline-block;
  166. width: 16px;
  167. height: 16px;
  168. margin-right: 10px;
  169. vertical-align: middle;
  170. background: url(/icon/new.png) no-repeat 0 2px;
  171. }
  172. }
  173. }
  174. .content{
  175. width:700px;
  176. display:inline-block;
  177. vertical-align: top;
  178. padding-left:30px;
  179. position:relative;
  180. height:90px;
  181. h4{
  182. font-size: 20px;
  183. color:#1e1e1e;
  184. width:700px;
  185. overflow:hidden;
  186. text-overflow: ellipsis;
  187. white-space:nowrap;
  188. margin-bottom:25px;
  189. }
  190. p{
  191. font-size: 14px;
  192. color:#797979;
  193. line-height: 20px;
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. display: -webkit-box;
  197. -webkit-line-clamp: 2;
  198. -webkit-box-orient: vertical;
  199. }
  200. }
  201. }
  202. }
  203. </style>