infoSample.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="info-sample-container fx-column">
  3. <el-badge class="self-sta" value="HOT">
  4. <span class="info-sample-title">{{ title }}</span>
  5. </el-badge>
  6. <div class="info-sample-separator" />
  7. <div v-if="dataList.length" class="info-sample-list">
  8. <template v-for="(item) in dataList">
  9. <info-card
  10. :key="item.id"
  11. :name="item.title"
  12. @click.native="detail(item)"
  13. />
  14. </template>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import infoCard from './infoCard.vue'
  20. import * as career from '@/api/webApi/career-news'
  21. export default {
  22. components: { infoCard },
  23. props: {
  24. type: {
  25. type: String,
  26. default: ''
  27. },
  28. title: {
  29. type: String,
  30. default: ''
  31. }
  32. },
  33. data() {
  34. return {
  35. dataList: [],
  36. queryParams: {
  37. pageNum: 1,
  38. pageSize: 10,
  39. tag: 'hot'
  40. }
  41. }
  42. },
  43. watch: {
  44. type: {
  45. immediate: true,
  46. handler: function() {
  47. this.getList()
  48. }
  49. }
  50. },
  51. methods: {
  52. detail(item) {
  53. this.$emit('click', item)
  54. },
  55. getList() {
  56. if (!this.type) return
  57. career.list({ ...this.queryParams, type: this.type }).then((res) => {
  58. console.log('career news list res', res)
  59. if (res.code == 200 || res.code == 0) {
  60. this.dataList = res.rows
  61. this.total = res.total
  62. } else {
  63. this.msgError(res.msg || 'career news list 请求异常')
  64. }
  65. })
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .info-sample-container {
  72. padding: 20px;
  73. border: 1px solid #dddddd;
  74. }
  75. .info-sample-title {
  76. font-size: 14px;
  77. font-weight: 600;
  78. color: #414141;
  79. }
  80. .info-sample-separator {
  81. width: 21px;
  82. height: 2px;
  83. background-color: #414141;
  84. }
  85. .info-sample-item-separator {
  86. margin: 5px -5px;
  87. }
  88. </style>