index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="bg-page fx-column fx-cen-cen">
  3. <div class="bg-white index-block fx-row jc-bet">
  4. <div class="fx-1 width0">
  5. <div class="info-tabs ml20 mt20">
  6. <el-radio-group v-if="showTabHead" v-model="type" @change="detailMode = false">
  7. <el-radio-button v-for="opt in typeOptions" :key="opt.value" :label="opt.label">{{ opt.label }}</el-radio-button>
  8. </el-radio-group>
  9. <div v-if="showSingleHead" class="news-single-head">
  10. <span class="pl60">{{ type }}</span>
  11. </div>
  12. </div>
  13. <info-list
  14. v-show="!detailMode"
  15. class="mt10"
  16. :type="type"
  17. @click="detailList"
  18. />
  19. <info-detail
  20. v-if="detailMode"
  21. :id="detailId"
  22. class="mt10"
  23. :type="type"
  24. :title="detailTitle"
  25. @close="detailClose"
  26. />
  27. </div>
  28. <div v-if="showHot" v-show="!detailMode" style="width: 400px; padding: 20px; margin-top: 38px">
  29. <info-sample
  30. :type="type"
  31. :title="type"
  32. @click="detailSample"
  33. />
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import transferMixin from '@/components/mx-transfer-mixin'
  40. import InfoDetail from '../components/infoDetail.vue'
  41. import infoList from '../components/infoList.vue'
  42. import InfoSample from '../components/infoSample.vue'
  43. import * as career from '@/api/webApi/career-news'
  44. export default {
  45. components: { infoList, InfoSample, InfoDetail },
  46. mixins: [transferMixin],
  47. data() {
  48. return {
  49. detailMode: false,
  50. detailTitle: '',
  51. detailId: 0,
  52. type: '',
  53. typeOptions: [],
  54. showHot: true
  55. }
  56. },
  57. computed: {
  58. showTabHead() {
  59. // return false
  60. // eslint-disable-next-line no-unreachable
  61. return this.typeOptions?.length &&
  62. this.typeOptions.some(t => t.label === this.type)
  63. },
  64. showSingleHead() {
  65. // return true
  66. // eslint-disable-next-line no-unreachable
  67. return this.typeOptions?.length && !this.showTabHead
  68. }
  69. },
  70. created() {
  71. this.getTypes()
  72. },
  73. methods: {
  74. detailList(item) {
  75. if (item.url) return window.open(item.url)
  76. this.detailTitle = item.title
  77. this.detailId = item.id
  78. this.detailMode = true
  79. },
  80. detailSample(item) {
  81. if (item.url) return window.open(item.url)
  82. this.detailTitle = item.title
  83. this.detailId = item.id
  84. this.detailMode = true
  85. },
  86. detailClose() {
  87. this.detailMode = false
  88. },
  89. async getTypes() {
  90. const res = await career.types()
  91. this.typeOptions = res.rows
  92. this.type = this.$route.meta.type || this.typeOptions.first()?.label
  93. // this.showHot = this.$route.meta.hot || false
  94. const news = this.prevData?.news
  95. if (news) this.detailList(news)
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. @import "~@/assets/styles/common.scss";
  102. .news-single-head {
  103. @extend .pf;
  104. @extend .f-fff;
  105. @extend .relative;
  106. width: 450px;
  107. height: 40px;
  108. display: flex;
  109. align-items: center;
  110. border-radius: 0 40px 0 0;
  111. background: linear-gradient(to right, $--color-primary-active, rgba($--color-primary-active, 0.2));
  112. &:before {
  113. content: '\00A0';
  114. height: 2px;
  115. width: 100%;
  116. position: absolute;
  117. bottom: -3px;
  118. background: linear-gradient(to right, $--color-primary-active, rgba($--color-primary-active, 0.2));
  119. }
  120. }
  121. </style>