news.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div id="news">
  3. <el-row v-loading="loading">
  4. <el-col :span="24" class="news">
  5. <el-col :span="24" class="newsTop">
  6. <el-col :span="18" class="text">
  7. {{ newsList.title || title }}
  8. </el-col>
  9. <el-col :span="6" class="link">
  10. <el-link :underline="false" @click="$router.push({ path: path, query: { title: newsList.title } })">
  11. MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i>
  12. </el-link>
  13. </el-col>
  14. </el-col>
  15. <el-col :span="24" class="info">
  16. <el-col :span="11" class="block">
  17. <el-carousel :interval="5000" arrow="always" ref="shubiao">
  18. <el-carousel-item v-for="(item, index) in infoList" :key="index" :name="`${index}`">
  19. <el-link :underline="false" @click="$router.push({ path: `/detail?id=${item.id}` })">
  20. <el-image style="width:369px;height:242px;" :src="item.pic"></el-image>
  21. <el-col :span="24" class="cont">
  22. <p>{{ item.title }}</p>
  23. </el-col>
  24. </el-link>
  25. </el-carousel-item>
  26. </el-carousel>
  27. </el-col>
  28. <el-col :span="12" class="content">
  29. <el-col
  30. :span="24"
  31. class="titList"
  32. @mouseover="shuYi(index)"
  33. :class="newListActive(item)"
  34. v-for="(item, index) in infoList"
  35. :key="index"
  36. @click.native="$router.push({ path: `/detail?id=${item.id}` })"
  37. >
  38. <span class="shu"></span>
  39. <span class="title">{{ item.title }}</span>
  40. <span class="time">{{ item.publish_time }}</span>
  41. </el-col>
  42. </el-col>
  43. </el-col>
  44. </el-col>
  45. </el-row>
  46. </div>
  47. </template>
  48. <script>
  49. import _ from 'lodash';
  50. export default {
  51. name: 'news',
  52. props: {
  53. newsList: null,
  54. },
  55. components: {},
  56. data: () => ({
  57. loading: true,
  58. title: '就业动态',
  59. infoList: [],
  60. path: undefined,
  61. }),
  62. watch: {
  63. newsList: {
  64. handler(val) {
  65. if (val) this.assignData(val);
  66. },
  67. },
  68. },
  69. created() {},
  70. computed: {},
  71. methods: {
  72. assignData(data) {
  73. let columns = _.get(data, 'children');
  74. let news = [];
  75. for (const item of columns) {
  76. if (!this.path) this.path = item.path;
  77. let newsList = _.get(item, `children`);
  78. if (newsList) {
  79. news = news.concat(news, newsList);
  80. }
  81. }
  82. this.$set(this, `infoList`, news);
  83. this.loading = false;
  84. },
  85. shuYi(index) {
  86. this.$refs.shubiao.setActiveItem(`${index}`);
  87. },
  88. newListActive(item) {},
  89. },
  90. filters: {
  91. getDate(meta) {
  92. let createdAt = _.get(meta, `createdAt`);
  93. let date = new Date(createdAt)
  94. .toLocaleDateString()
  95. .replace('/', '-')
  96. .replace('/', '-');
  97. return date;
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="less" scoped>
  103. p {
  104. padding: 0;
  105. margin: 0;
  106. }
  107. /deep/.el-carousel__indicators {
  108. display: none;
  109. }
  110. .newsTop {
  111. height: 35px;
  112. line-height: 35px;
  113. border-bottom: 2px solid #0656d1;
  114. }
  115. .newsTop .text {
  116. font-size: 20px;
  117. color: #0874ee;
  118. font-weight: 600;
  119. padding: 0 10px;
  120. }
  121. .newsTop .link {
  122. text-align: right;
  123. padding: 0 5px;
  124. }
  125. .info {
  126. margin: 24px 0 0 0;
  127. }
  128. .block {
  129. width: 369px;
  130. height: 242px;
  131. overflow: hidden;
  132. }
  133. .cont {
  134. position: absolute;
  135. bottom: 0;
  136. height: 40px;
  137. line-height: 40px;
  138. background-color: #0656d19f;
  139. }
  140. .cont p {
  141. font-size: 18px;
  142. color: #fff;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. white-space: nowrap;
  146. padding: 0 15px;
  147. }
  148. /deep/.el-carousel__container {
  149. height: 242px;
  150. }
  151. .content {
  152. float: right;
  153. width: 415px;
  154. }
  155. .titList {
  156. border-bottom: 1px dashed #ccc;
  157. padding: 5px 0;
  158. }
  159. .titList .shu {
  160. display: inline-block;
  161. width: 2px;
  162. height: 16px;
  163. background-color: transparent;
  164. }
  165. .titList .title {
  166. font-size: 14px;
  167. color: #5b5b5b;
  168. display: inline-block;
  169. width: 270px;
  170. padding: 0 10px;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. white-space: nowrap;
  174. }
  175. .titList .time {
  176. font-size: 14px;
  177. color: #5b5b5b;
  178. display: inline-block;
  179. width: 100px;
  180. overflow: hidden;
  181. padding: 0 10px;
  182. }
  183. .titList:hover {
  184. cursor: pointer;
  185. }
  186. .titList:hover .title {
  187. color: #333333;
  188. }
  189. .titList:hover .shu {
  190. background-color: #0656d1;
  191. }
  192. /deep/.el-carousel__arrow {
  193. width: 17px;
  194. height: 39px;
  195. border-radius: 0;
  196. background-color: #0656d1;
  197. }
  198. /deep/.el-carousel__arrow--left {
  199. left: 0;
  200. }
  201. /deep/.el-carousel__arrow--right {
  202. right: 0;
  203. }
  204. .el-carousel__item h3 {
  205. color: #475669;
  206. font-size: 18px;
  207. opacity: 0.75;
  208. line-height: 300px;
  209. margin: 0;
  210. }
  211. .el-carousel__item:nth-child(2n) {
  212. background-color: #99a9bf;
  213. }
  214. .el-carousel__item:nth-child(2n + 1) {
  215. background-color: #d3dce6;
  216. }
  217. </style>