ExpertList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div>
  3. <!-- <TopSearch :searchVal="searchVal" :searchType="searchType" :searchTypeArr="searchTypeArr"/>-->
  4. <div class="nav" stype="height:500px">
  5. <!--搜索框-->
  6. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  7. <el-col :span="6">
  8. <div class="pull-left" @click="gotoHome" style="cursor: pointer">
  9. <img class="logo-img" src="../../assets/img/logo-blue.png"/>
  10. <span class="logo-title">群智众测平台</span>
  11. </div>
  12. </el-col>
  13. <el-col :span="12">
  14. <div class="search-nav">
  15. <div id="search-block ">
  16. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  17. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name"
  18. :name="item.value"
  19. :key="item.value"></el-tab-pane>
  20. </el-tabs>
  21. <div class="search-input">
  22. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  23. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  24. </el-input>
  25. </div>
  26. </div>
  27. </div>
  28. </el-col>
  29. <el-col :span="6">
  30. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <div class="container" style="margin: 20px auto;" v-loading="loading">
  35. <div class="title h2">专家</div>
  36. <el-row>
  37. <el-col :span="18" class="">
  38. <el-row :gutter="15" style="margin-bottom: 10px">
  39. <el-col :span="8" v-for="(item,index) in expertList" :key="index" style="margin-bottom: 15px">
  40. <ExpertCard :card="item"></ExpertCard>
  41. </el-col>
  42. </el-row>
  43. <el-pagination
  44. v-if="expertList&&expertList.length"
  45. :page-size="9"
  46. layout="prev, pager, next"
  47. :total="totalElements"
  48. :current-page="activePage"
  49. @current-change="handlePageChange"
  50. class="pull-right"
  51. >
  52. </el-pagination>
  53. </el-col>
  54. </el-row>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import Http from '@/js/http.js';
  60. import TopSearch from "../../components/commons/TopSearch";
  61. import ExpertCard from "./ExpertCard";
  62. import {storageGet} from '@/js/index.js'
  63. import {notify} from "../../constants";
  64. import Apis from '@/js/api';
  65. export default {
  66. name: "ExpertList",
  67. components: {ExpertCard, TopSearch},
  68. data() {
  69. return {
  70. user: {},
  71. isLogin: false,
  72. loading: false,
  73. searchVal: '',
  74. searchType: '3',
  75. searchTypeArr: [
  76. {
  77. "name": "全部",
  78. "value": "all"
  79. },
  80. {
  81. "name": "项目",
  82. "value": "0"
  83. },
  84. {
  85. "name": "机构",
  86. "value": "1"
  87. },
  88. {
  89. "name": "资源",
  90. "value": "2"
  91. },
  92. {
  93. "name": "专家",
  94. "value": "3"
  95. }],
  96. expertList: [],
  97. activePage: 1,
  98. totalElements: 0
  99. }
  100. },
  101. methods: {
  102. loadData() {
  103. if (storageGet('user') != null) {
  104. this.isLogin = true;
  105. }
  106. this.searchVal = this.$route.params.searchVal;
  107. this.handleSearchData();
  108. },
  109. showLoading() {
  110. this.loading = true
  111. },
  112. hideLoading() {
  113. this.loading = false
  114. },
  115. checkLogin() {
  116. this.checkCreateProjectAuth();
  117. },
  118. checkCreateProjectAuth() {
  119. if (!this.isLogin) {
  120. console.log("请登录后访问");
  121. notify('warning', '请登录后访问');
  122. } else if (this.isLogin) {
  123. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  124. this.$router.push('/project/create');
  125. }).catch((error) => {
  126. notify('error', error.data)
  127. })
  128. }
  129. },
  130. handleSearchData() {
  131. if (this.searchType == 0) {
  132. this.$router.push({
  133. name: 'Square',
  134. params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}
  135. });
  136. } else if (this.searchType == 1) {
  137. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  138. } else if (this.searchType == 2) {
  139. this.$router.push({name: 'ResourceList', params: {searchVal: this.searchVal}});
  140. } else if (this.searchType == 3) {
  141. let url = '/api/common/index/page';
  142. let params = {
  143. "keyword": this.searchVal,
  144. "activePage": 1,
  145. "columnFilters": [
  146. {
  147. "field": "type",
  148. "type": "enums",
  149. "enums": this.searchTypeArr,
  150. "value": this.searchType
  151. }
  152. ]
  153. }
  154. Http.post(url, params).then((res) => {
  155. this.expertList = res.data.expertPage.content;
  156. this.totalElements = res.data.expertPage.totalElements;
  157. })
  158. }
  159. },
  160. nextPage() {
  161. let url = '/api/common/index/page';
  162. let params = {
  163. "keyword": this.searchVal,
  164. "activePage": this.activePage,
  165. "columnFilters": [
  166. {
  167. "field": "type",
  168. "type": "enums",
  169. "enums": this.searchTypeArr,
  170. "value": this.searchType
  171. }
  172. ]
  173. }
  174. Http.post(url, params).then((res) => {
  175. this.expertList = res.data.expertPage.content;
  176. this.totalElements = res.data.expertPage.totalElements;
  177. })
  178. },
  179. gotoHome() {
  180. this.$router.push('/home');
  181. },
  182. handleTypeClick(tab) {
  183. this.searchType = tab.name
  184. },
  185. handlePageChange(index) {
  186. this.activePage = index;
  187. this.nextPage();
  188. },
  189. setUserInfo() {
  190. this.user = storageGet('user') && storageGet('user').userVO;
  191. }
  192. },
  193. mounted() {
  194. this.setUserInfo();
  195. this.loadData();
  196. }
  197. }
  198. </script>
  199. <style lang="less">
  200. @import "../../style/search-nav";
  201. </style>