index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="index flex-1 flex col-top">
  3. <category @chain="getChainList" class="flex-none" />
  4. <div class="flex-1 " style="overflow: auto;">
  5. <el-tabs v-model="chainIndex" :stretch="false" @tab-click="changeChain">
  6. <el-tab-pane :label="item.title" v-for="(item, index) in chainList" :key="index">
  7. </el-tab-pane>
  8. </el-tabs>
  9. <div v-if="talentsList.length > 0">
  10. <talents-list :list="talentsList" />
  11. <div class="pagination flex row-center" style="padding-bottom: 38px" v-if="count">
  12. <el-pagination background hide-on-single-page layout="prev, pager, next" :page-size="9"
  13. :total="count" prev-text="上一页" next-text="下一页" @current-change="changePage">
  14. </el-pagination>
  15. </div>
  16. </div>
  17. <null-data v-else :img="require('@/static/images/goods_null.png')" text="暂无数据~"></null-data>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. // import HomeSeckill from '../components/home-seckill.vue'
  23. import Category from '~/components/category'
  24. import TalentsList from '~/components/talents-list'
  25. import Cookies from 'js-cookie'
  26. export default {
  27. head() {
  28. return {
  29. title: this.$store.getters.headTitle,
  30. link: [{
  31. rel: 'icon',
  32. type: 'image/x-icon',
  33. href: this.$store.getters.favicon,
  34. }, ],
  35. }
  36. },
  37. layout: 'index',
  38. components: {
  39. Category,
  40. TalentsList,
  41. },
  42. async asyncData({
  43. $get
  44. }) {
  45. },
  46. data() {
  47. return {
  48. chainList: [],
  49. cateTwoId: 0,
  50. chainIndex: '0',
  51. chain: '',
  52. talentsList: [],
  53. page: 1,
  54. }
  55. },
  56. watch: {
  57. },
  58. created() {
  59. },
  60. mounted() {
  61. },
  62. updated() {
  63. },
  64. methods: {
  65. getChainList(list) {
  66. this.chainList = list
  67. this.cateTwoId = list[0].pid
  68. this.chainIndex = '0'
  69. this.setChain()
  70. },
  71. changeChain(tab) {
  72. this.chainIndex = tab.index
  73. this.setChain()
  74. },
  75. setChain() {
  76. this.chain = this.chainList[this.chainIndex].title
  77. this.page = 1
  78. this.getTalents()
  79. },
  80. changePage(current) {
  81. this.page = current
  82. this.getTalents()
  83. },
  84. async getTalents() {
  85. const params = {
  86. page_size: 9,
  87. page_no: this.page,
  88. cid: this.cateTwoId,
  89. chain: this.chain
  90. }
  91. const {
  92. code,
  93. data,
  94. _meta
  95. } = await this.$get('article', {
  96. params,
  97. })
  98. if (code == 1) {
  99. this.talentsList = data
  100. this.count = _meta.totalCount
  101. }
  102. },
  103. },
  104. }
  105. </script>
  106. <style lang="scss">
  107. .index {
  108. :deep(.el-tabs__item:last-child) {
  109. padding: 0 20px;
  110. }
  111. }
  112. </style>