TopSearch.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="nav" stype="height:500px">
  3. <!--搜索框-->
  4. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  5. <el-col :span="6">
  6. <div class="pull-left" @click="gotoHome" style="cursor: pointer">
  7. <img class="logo-img" src="../../assets/img/logo-blue.png"/>
  8. <span class="logo-title">群智众测平台</span>
  9. </div>
  10. </el-col>
  11. <el-col :span="12">
  12. <div class="search-nav">
  13. <div id="search-block ">
  14. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  15. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name" :name="item.value"
  16. :key="item.value"></el-tab-pane>
  17. </el-tabs>
  18. <div class="search-input">
  19. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  20. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  21. </el-input>
  22. </div>
  23. </div>
  24. </div>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. </template>
  32. <script>
  33. import {mapGetters, mapActions} from 'vuex'
  34. import commonData from '../../constants/tabMenu'
  35. import Http from '@/js/http.js'
  36. import {storageGet} from '@/js/index.js'
  37. import {notify} from "../../constants";
  38. export default {
  39. name: 'TopSearch',
  40. props: ['searchVal','searchType','searchTypeArr'],
  41. data() {
  42. return {
  43. isLogin: false,
  44. resultList:[],
  45. }
  46. },
  47. methods: {
  48. loadData(){
  49. if (storageGet('user') != null) {
  50. this.isLogin = true;
  51. }
  52. },
  53. checkLogin(){
  54. if(!this.isLogin){
  55. console.log("请登录后访问");
  56. notify('warning','请登录后访问');
  57. }else{
  58. console.log("已登录");
  59. this.$router.push('/project/create');
  60. }
  61. },
  62. handleSearchData() {
  63. console.log(this.searchType);
  64. let url = '/api/common/index/page';
  65. let params = {
  66. "keyword": this.searchVal,
  67. "activePage": 1,
  68. "columnFilters": [
  69. {
  70. "field": "type",
  71. "type": "enums",
  72. "enums": this.searchTypeArr,
  73. "value": this.searchType
  74. }
  75. ]
  76. }
  77. Http.post(url, params).then((res) => {
  78. console.log(res.data.expertPage.content);
  79. resultList = res.data.expertPage.content;
  80. })
  81. },
  82. gotoHome() {
  83. this.$router.push('/home');
  84. },
  85. handleTypeClick(tab){
  86. this.searchType = tab.name
  87. },
  88. },
  89. mounted() {
  90. this.loadData();
  91. }
  92. }
  93. </script>
  94. <style>
  95. </style>