index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="down">
  9. <el-col :span="24" class="search">
  10. <van-search v-model="name" @search="search" placeholder="请输入信息标题" />
  11. </el-col>
  12. <el-col :span="24" class="data">
  13. <list :list="list"></list>
  14. </el-col>
  15. </el-col>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import list from './parts/list.vue';
  22. import { mapState, createNamespacedHelpers } from 'vuex';
  23. import NavBar from '@/layout/common/topInfo.vue';
  24. const { mapActions: product } = createNamespacedHelpers('product');
  25. export default {
  26. metaInfo() {
  27. return { title: this.$route.meta.title };
  28. },
  29. name: 'index',
  30. props: {},
  31. components: {
  32. NavBar,
  33. list,
  34. },
  35. data: function() {
  36. return {
  37. // 头部标题
  38. title: '',
  39. // meta为true
  40. isleftarrow: '',
  41. // 返回
  42. navShow: true,
  43. active: 0,
  44. // 查询
  45. name: '',
  46. list: [],
  47. };
  48. },
  49. async created() {
  50. await this.search();
  51. },
  52. methods: {
  53. ...product(['query']),
  54. async search({ ...info } = {}) {
  55. if (this.name) info.name = this.name;
  56. let res = await this.query({ type: 1, ...info });
  57. if (this.$checkRes(res)) {
  58. this.$set(this, `list`, res.data);
  59. }
  60. },
  61. },
  62. computed: {
  63. ...mapState(['user']),
  64. },
  65. mounted() {
  66. this.title = this.$route.meta.title;
  67. this.isleftarrow = this.$route.meta.isleftarrow;
  68. },
  69. metaInfo() {
  70. return { title: this.$route.meta.title };
  71. },
  72. watch: {},
  73. };
  74. </script>
  75. <style lang="less" scoped>
  76. .style {
  77. width: 100%;
  78. height: 100%;
  79. position: relative;
  80. background-color: #f9fafc;
  81. .top {
  82. height: 45px;
  83. overflow: hidden;
  84. }
  85. .down {
  86. .search {
  87. position: fixed;
  88. width: 100%;
  89. z-index: 999;
  90. border-bottom: 1px dashed #ccc;
  91. }
  92. .data {
  93. position: absolute;
  94. width: 100%;
  95. top: 100px;
  96. }
  97. }
  98. }
  99. </style>