index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div id="index">
  3. <mobileMain :useNav="false" @search="search" :total="total" :limit="limit">
  4. <template v-slot:info>
  5. <van-tabs v-model="active" @click="changeActive">
  6. <van-tab title="嘉宾访谈" name="0">
  7. <one-frame :list="list"></one-frame>
  8. </van-tab>
  9. <van-tab title="技能培训" name="1">
  10. <two-frame :list="list"></two-frame>
  11. </van-tab>
  12. </van-tabs>
  13. </template>
  14. </mobileMain>
  15. </div>
  16. </template>
  17. <script>
  18. import oneFrame from '../parts/list_4.vue';
  19. import twoFrame from '../parts/list_5.vue';
  20. import { mapState, createNamespacedHelpers } from 'vuex';
  21. const { mapActions: interview } = createNamespacedHelpers('interview');
  22. const { mapActions: trainLive } = createNamespacedHelpers('trainLive');
  23. export default {
  24. name: 'index',
  25. props: {},
  26. components: {
  27. oneFrame,
  28. twoFrame,
  29. },
  30. data: function() {
  31. return {
  32. active: 0,
  33. list: [],
  34. total: 0,
  35. limit: 10,
  36. };
  37. },
  38. created() {
  39. this.changeActive();
  40. },
  41. methods: {
  42. ...interview(['query']),
  43. ...trainLive({ getTrainlive: 'query' }),
  44. async search({ skip = 0, limit = this.limit, searchName, ...info } = {}) {
  45. if (searchName) info.title = searchName;
  46. if (this.active == 0) {
  47. let res = await this.query({ skip, limit, ...info });
  48. if (this.$checkRes(res)) {
  49. this.$set(this, `list`, res.data);
  50. this.$set(this, `total`, res.total);
  51. }
  52. } else if (this.active == 1) {
  53. let res = await this.getTrainlive({ skip, limit, ...info });
  54. if (this.$checkRes(res)) {
  55. this.$set(this, `list`, res.data);
  56. this.$set(this, `total`, res.total);
  57. }
  58. }
  59. },
  60. changeActive(name) {
  61. this.$set(this, `active`, name || 0);
  62. this.search();
  63. },
  64. },
  65. computed: {
  66. ...mapState(['user']),
  67. },
  68. metaInfo() {
  69. return { title: this.$route.meta.title };
  70. },
  71. watch: {
  72. test: {
  73. deep: true,
  74. immediate: true,
  75. handler(val) {},
  76. },
  77. },
  78. };
  79. </script>
  80. <style lang="less" scoped></style>