TopSearch.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 Http from '@/js/http.js'
  34. import {storageGet} from '@/js/index.js'
  35. import {notify} from "../../constants";
  36. export default {
  37. name: 'TopSearch',
  38. props: ['searchVal','searchType','searchTypeArr'],
  39. data() {
  40. return {
  41. isLogin: false,
  42. resultList:[],
  43. }
  44. },
  45. methods: {
  46. loadData(){
  47. if (storageGet('user') != null) {
  48. this.isLogin = true;
  49. }
  50. },
  51. checkLogin() {
  52. this.checkCreateProjectAuth();
  53. },
  54. checkCreateProjectAuth() {
  55. if (!this.isLogin) {
  56. console.log("请登录后访问");
  57. notify('warning', '请登录后访问');
  58. } else if (this.isLogin) {
  59. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  60. this.$router.push('/project/create');
  61. }).catch((error) => {
  62. notify('error', error.data)
  63. })
  64. }
  65. },
  66. handleSearchData() {
  67. console.log(this.searchType);
  68. let url = '/api/common/index/page';
  69. let params = {
  70. "keyword": this.searchVal,
  71. "activePage": 1,
  72. "columnFilters": [
  73. {
  74. "field": "type",
  75. "type": "enums",
  76. "enums": this.searchTypeArr,
  77. "value": this.searchType
  78. }
  79. ]
  80. }
  81. Http.post(url, params).then((res) => {
  82. console.log(res.data.expertPage.content);
  83. resultList = res.data.expertPage.content;
  84. })
  85. },
  86. gotoHome() {
  87. this.$router.push('/home');
  88. },
  89. handleTypeClick(tab){
  90. this.searchType = tab.name
  91. },
  92. },
  93. mounted() {
  94. this.loadData();
  95. }
  96. }
  97. </script>
  98. <style>
  99. </style>