top.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div id="top">
  3. <el-col :span="24" class="one" v-if="topType == '1'">
  4. <van-search v-model="searchName" placeholder="请输入信息标题" @search="search" />
  5. </el-col>
  6. <el-col :span="24" class="two" v-else-if="topType == '2'">
  7. <van-nav-bar :title="this.$route.meta.title" :left-arrow="leftArrow" @click-left="upBack">
  8. <template #left>
  9. <span v-if="leftArrow">
  10. <van-icon name="arrow-left" />
  11. <span style="color: #409eff">返回</span>
  12. </span>
  13. </template>
  14. </van-nav-bar>
  15. </el-col>
  16. <el-col :span="24" class="thr" v-else-if="topType == '3'">
  17. <el-col :span="4" class="back" @click.native="upBack"> <van-icon name="arrow-left" />返回 </el-col>
  18. <el-col :span="20" class="search">
  19. <van-search v-model="searchName" placeholder="请输入信息" @search="search" />
  20. </el-col>
  21. </el-col>
  22. <el-col :span="24" class="four" v-else-if="topType == '4'">
  23. <el-col :span="4" class="back" @click.native="upBack"> <van-icon name="arrow-left" />返回 </el-col>
  24. <el-col :span="16" class="title">
  25. {{ $route.meta.title }}
  26. </el-col>
  27. <el-col :span="4" class="add">
  28. <van-button icon="plus" size="small" type="info" round @click="add" />
  29. </el-col>
  30. </el-col>
  31. </div>
  32. </template>
  33. <script>
  34. import { mapState, createNamespacedHelpers } from 'vuex';
  35. export default {
  36. name: 'top',
  37. props: {
  38. topType: { type: String, default: () => '1' },
  39. // 只有类型为2时,有用
  40. leftArrow: { type: Boolean, default: () => true },
  41. },
  42. components: {},
  43. data: function () {
  44. return {
  45. searchName: '',
  46. };
  47. },
  48. created() {},
  49. methods: {
  50. // 查询
  51. search() {
  52. this.$emit('search', { searchName: this.searchName });
  53. },
  54. // 返回
  55. upBack() {
  56. this.$emit('back');
  57. },
  58. // 添加
  59. add() {
  60. this.$emit('add');
  61. },
  62. },
  63. computed: {
  64. ...mapState(['user']),
  65. },
  66. metaInfo() {
  67. return { title: this.$route.meta.title };
  68. },
  69. watch: {
  70. test: {
  71. deep: true,
  72. immediate: true,
  73. handler(val) {},
  74. },
  75. },
  76. };
  77. </script>
  78. <style lang="less" scoped>
  79. .one {
  80. /deep/.van-search {
  81. padding: 3px 5px;
  82. }
  83. }
  84. .two {
  85. /deep/.van-nav-bar__content {
  86. height: 40px;
  87. }
  88. /deep/.van-icon {
  89. top: 2px;
  90. }
  91. }
  92. .thr {
  93. .back {
  94. color: #409eff;
  95. padding: 8px 0;
  96. text-align: center;
  97. .van-icon {
  98. top: 3px;
  99. }
  100. }
  101. .search {
  102. /deep/.van-search {
  103. padding: 2px 5px 2px 0px;
  104. }
  105. }
  106. }
  107. .four {
  108. .back {
  109. color: #409eff;
  110. padding: 8px 0;
  111. text-align: center;
  112. .van-icon {
  113. top: 3px;
  114. }
  115. }
  116. .title {
  117. text-align: center;
  118. padding: 9px 0;
  119. }
  120. .add {
  121. text-align: center;
  122. padding: 4px 0;
  123. }
  124. }
  125. </style>