index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__zoomInDown">
  5. <el-col :span="24" class="zero one">
  6. <el-col :span="16" class="one_1">
  7. <el-carousel height="500px">
  8. <el-carousel-item v-for="(item, index) in bannerList" :key="index">
  9. <el-image class="image" :src="item.url"></el-image>
  10. </el-carousel-item>
  11. </el-carousel>
  12. </el-col>
  13. <el-col :span="8" class="one_2">
  14. <el-col :span="24" class="newsList" v-for="(item, index) in newsList" :key="index">
  15. <el-col :span="24" class="title textOver">{{ item.title }}</el-col>
  16. <el-col :span="24" class="date">{{ item.date }}</el-col>
  17. <el-col :span="24" class="brief">{{ item.brief }}</el-col>
  18. </el-col>
  19. </el-col>
  20. </el-col>
  21. <el-col :span="24" class="zero two">
  22. <el-col :span="24" class="common_1">
  23. <span>新闻资讯</span>
  24. <span></span>
  25. <span></span>
  26. </el-col>
  27. <el-col :span="24" class="two_1">
  28. <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
  29. <el-col :span="2" class="date">
  30. <p>
  31. <span>{{ getDate(item.date, 'day') }}</span>
  32. <span>{{ getDate(item.date, 'year') }}</span>
  33. </p>
  34. </el-col>
  35. <el-col :span="2" class="info">
  36. <el-col :span="24" class="title">{{ item.name }}</el-col>
  37. <el-col :span="24" class="brief">{{ item.path || '暂无' }}</el-col>
  38. </el-col>
  39. </el-col>
  40. <el-col :span="24" class="page">
  41. <c-page :total="total" :limit="limit" @query="search"></c-page>
  42. </el-col>
  43. </el-col>
  44. </el-col>
  45. </el-col>
  46. </el-row>
  47. </div>
  48. </template>
  49. <script>
  50. import { mapState, createNamespacedHelpers } from 'vuex';
  51. const { mapActions } = createNamespacedHelpers('program');
  52. const moment = require('moment');
  53. export default {
  54. name: 'index',
  55. props: {},
  56. components: {},
  57. data: function () {
  58. return {
  59. // 轮播图
  60. bannerList: [{ url: require('@a/news_1.jpg') }],
  61. // 新闻
  62. newsList: [
  63. {
  64. title: '软件定义一切 下一个数据中心模式?',
  65. date: '2023-02-02',
  66. brief: '虚拟化在数据中心的应用意味着软件定义计算逐渐成为主流,而在软件定义计算的成功摸下下,软件定义存储也迅速获得市场的认.',
  67. },
  68. {
  69. title: '软件定义一切 下一个数据中心模式?',
  70. date: '2023-02-02',
  71. brief: '虚拟化在数据中心的应用意味着软件定义计算逐渐成为主流,而在软件定义计算的成功摸下下,软件定义存储也迅速获得市场的认.',
  72. },
  73. {
  74. title: '软件定义一切 下一个数据中心模式?',
  75. date: '2023-02-02',
  76. brief: '虚拟化在数据中心的应用意味着软件定义计算逐渐成为主流,而在软件定义计算的成功摸下下,软件定义存储也迅速获得市场的认.',
  77. },
  78. {
  79. title: '软件定义一切 下一个数据中心模式?',
  80. date: '2023-02-02',
  81. brief: '虚拟化在数据中心的应用意味着软件定义计算逐渐成为主流,而在软件定义计算的成功摸下下,软件定义存储也迅速获得市场的认.',
  82. },
  83. ],
  84. list: [],
  85. total: 0,
  86. limit: 6,
  87. };
  88. },
  89. created() {
  90. this.search();
  91. },
  92. methods: {
  93. ...mapActions(['query']),
  94. async search({ skip = 0, limit = this.limit, ...info } = {}) {
  95. let res = await this.query({ skip, limit, ...info });
  96. if (this.$checkRes(res)) {
  97. this.$set(this, `list`, res.data);
  98. this.$set(this, `total`, res.total);
  99. }
  100. },
  101. // 整理时间
  102. getDate(e, type) {
  103. if (type == 'day') {
  104. let day = moment(e).format('DD');
  105. if (day) return day;
  106. else '暂无';
  107. } else if (type == 'year') {
  108. let year = moment(e).format('YYYY/MM');
  109. if (year) return year;
  110. else '暂无';
  111. }
  112. },
  113. },
  114. computed: {
  115. ...mapState(['user']),
  116. },
  117. metaInfo() {
  118. return { title: this.$route.meta.title };
  119. },
  120. watch: {
  121. test: {
  122. deep: true,
  123. immediate: true,
  124. handler(val) {},
  125. },
  126. },
  127. };
  128. </script>
  129. <style lang="less" scoped>
  130. .main {
  131. .zero {
  132. margin: 0 0 2vw 0;
  133. .common_1 {
  134. margin: 0 0 20px 0;
  135. span:nth-child(1) {
  136. color: #ffc001;
  137. font-size: 18px;
  138. }
  139. span:nth-child(2) {
  140. display: inline-block;
  141. width: 8px;
  142. height: 10px;
  143. background-color: #ffc001;
  144. margin: 0 10px;
  145. }
  146. span:nth-child(3) {
  147. display: inline-block;
  148. width: 91%;
  149. height: 10px;
  150. background-color: #f1f1f1;
  151. }
  152. }
  153. }
  154. .one {
  155. .one_1 {
  156. .image {
  157. width: 100%;
  158. height: 100%;
  159. }
  160. }
  161. .one_2 {
  162. padding: 0 10px;
  163. .newsList {
  164. margin: 0 0 20px 0;
  165. padding: 0 0 20px 0;
  166. border-bottom: 1px dashed #353535;
  167. .title {
  168. font-size: 20px;
  169. margin: 0 0 5px 0;
  170. font-weight: bold;
  171. font-family: cursive;
  172. }
  173. .date {
  174. font-size: 14px;
  175. margin: 0 0 5px 0;
  176. }
  177. .brief {
  178. font-size: 14px;
  179. color: #7e7e7e;
  180. line-height: 1.5;
  181. overflow: hidden;
  182. text-overflow: ellipsis;
  183. -webkit-line-clamp: 2;
  184. word-break: break-all;
  185. display: -webkit-box;
  186. -webkit-box-orient: vertical;
  187. }
  188. }
  189. .newsList:last-child {
  190. border-bottom: none;
  191. margin: 0;
  192. padding: 0;
  193. }
  194. .newsList:hover {
  195. cursor: pointer;
  196. .title {
  197. color: #ffc001;
  198. }
  199. .date {
  200. color: #ffc001;
  201. }
  202. }
  203. }
  204. }
  205. .two {
  206. .two_1 {
  207. .list {
  208. border-bottom: 1px solid #f1f1f1;
  209. padding: 0 0 20px 0;
  210. margin: 0 0 10px 0;
  211. .date {
  212. p {
  213. background-color: #f2f2f2;
  214. padding: 10px;
  215. text-align: center;
  216. span {
  217. display: inline-block;
  218. font-size: 14px;
  219. color: #747474;
  220. }
  221. span:nth-child(1) {
  222. font-size: 25px;
  223. }
  224. }
  225. }
  226. .info {
  227. padding: 0 0 0 10px;
  228. .title {
  229. font-size: 18px;
  230. margin: 0 0 5px 0;
  231. }
  232. .brief {
  233. font-size: 14px;
  234. color: #747474;
  235. }
  236. }
  237. }
  238. .list:last-child {
  239. border-bottom: none;
  240. }
  241. .list:hover {
  242. cursor: pointer;
  243. .info {
  244. .title {
  245. color: #ffc001;
  246. }
  247. }
  248. }
  249. .page {
  250. text-align: center;
  251. }
  252. }
  253. }
  254. }
  255. </style>