Homepage.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="home-wrapper">
  3. <div class="nav" stype="height:500px">
  4. <!--搜索框-->
  5. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  6. <el-col :span="6">
  7. <div class="pull-left">
  8. <img class="logo-img" src="../../assets/img/logo-blue.png" :to="'/home'"/>
  9. <span class="logo-title">群智众测平台</span>
  10. </div>
  11. </el-col>
  12. <el-col :span="12">
  13. <div class="search-nav">
  14. <div id="search-block ">
  15. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  16. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name" :name="item.value" :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. <!--TabNav-->
  31. <el-tabs v-model="currTab" @tab-click="handleTabClick" class="square-tab">
  32. <el-tab-pane v-for="item in homeTabArr.menuArr1" :label="item.label" :name="item.name" :key="item.name"></el-tab-pane>
  33. <el-tab-pane v-for="item in homeTabArr.menuArr2" :label="item.name" :name="item.code" :key="item.code"></el-tab-pane>
  34. <el-tab-pane v-for="item in homeTabArr.menuArr3" :label="item.label" :name="item.name" :key="item.name"></el-tab-pane>
  35. </el-tabs>
  36. <div>
  37. </div>
  38. </div>
  39. <div class="home-page container">
  40. <el-row>
  41. <el-col :span="19" class="test-type-wrapper">
  42. <TestMenu :testTypeList="homeData.testTypeList"></TestMenu>
  43. <TestCard :homeData="homeData"></TestCard>
  44. </el-col>
  45. <el-col :span="5" class="homepage-right-modules">
  46. <LoginCard/>
  47. <HotCrowd :applicationTypeRank="homeData.applicationTypeRank"/>
  48. <HotAgency :agencyRank="homeData.agencyRank"/>
  49. <HotUser :userRank="homeData.userRank"/>
  50. <HotContest :competitionList="homeData.competitionList"/>
  51. </el-col>
  52. </el-row>
  53. <el-row :gutter="15">
  54. <el-col :span="12">
  55. <ResourceAndTool :resourceList="homeData.resourceList"></ResourceAndTool>
  56. </el-col>
  57. <el-col :span="12">
  58. <BrandCard :residentAgencyList = homeData.residentAgencyList></BrandCard>
  59. </el-col>
  60. </el-row>
  61. <InstitutionCard></InstitutionCard>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. // import commonData from '../../constants/tabMenu'
  67. import SearchBar from '../../components/commons/SearchBar'
  68. import TestMenu from './TestMenu'
  69. import LoginCard from './LoginCard'
  70. import BrandCard from './BrandCard'
  71. import ResourceAndTool from './ResourceAndTool'
  72. import TestCard from './TestCard'
  73. import InstitutionCard from './InstitutionCard'
  74. import HotCrowd from './HotCrowd'
  75. import HotAgency from './HotAgency'
  76. import HotUser from './HotUser'
  77. import HotContest from './HotContest'
  78. import PopularProject from '../Square/PopularProject'
  79. import Http from '@/js/http.js'
  80. import {mapActions,mapGetters} from 'vuex'
  81. import Waterfall from 'vue-waterfall/lib/waterfall'
  82. import WaterfallSlot from 'vue-waterfall/lib/waterfall-slot'
  83. import {storageGet, getAllFields} from '@/js/index.js'
  84. import {notify} from "../../constants";
  85. // console.log(commonData);
  86. export default {
  87. name: 'Homepage',
  88. components: {
  89. HotCrowd,
  90. HotContest,
  91. HotUser,
  92. HotAgency,
  93. InstitutionCard,
  94. SearchBar,
  95. TestMenu,
  96. PopularProject,
  97. LoginCard,
  98. TestCard,
  99. BrandCard,
  100. ResourceAndTool,
  101. Waterfall,
  102. WaterfallSlot
  103. // vueWaterfallEasy
  104. },
  105. data() {
  106. return {
  107. isLogin: false,
  108. searchType:'0',
  109. searchTypeArr:[
  110. {
  111. "name": "全部",
  112. "value": "all"
  113. },
  114. {
  115. "name": "项目",
  116. "value": "0"
  117. },
  118. {
  119. "name": "机构",
  120. "value": "1"
  121. },
  122. {
  123. "name": "工具",
  124. "value": "2"
  125. },
  126. {
  127. "name": "专家",
  128. "value": "3"
  129. }],
  130. searchVal: '',
  131. homeTabArr:{
  132. menuArr1: [
  133. {label: "首页", name: "homepage",linkTo:'/home'},
  134. {label: "众测广场", name: "square",linkTo:'/square'},
  135. {label: "众测技术", name: "technology",linkTo:'technology'}
  136. ],
  137. menuArr2:[
  138. {code: '', name: ''}
  139. ],
  140. menuArr3:[
  141. {label: "找机构", name: "findInstitution",linkTo:'/agency/list'},
  142. {label: "找专家", name: "findExpert",linkTo:'/expert/list'},
  143. ],
  144. },
  145. homeData:{},
  146. currTab:'homepage'
  147. }
  148. },
  149. methods:{
  150. loadData(){
  151. if (storageGet('user') != null) {
  152. this.isLogin = true;
  153. }
  154. this.setFields();
  155. Http.get('/api/common/index/info').then((res)=>{
  156. this.homeData = res.data;
  157. this.homeData.applicationTypeList.map((item)=>{
  158. item.height = (item.testTypeList.length / 2) * 24 + 100;
  159. return item;
  160. })
  161. })
  162. },
  163. setFields(){
  164. getAllFields().then((res) => {
  165. this.homeTabArr.menuArr2 = res
  166. // console.log(this.homeTabArr.menuArr2)
  167. })
  168. },
  169. checkLogin(){
  170. if(!this.isLogin){
  171. console.log("请登录后访问");
  172. notify('warning','请登录后访问');
  173. }else{
  174. console.log("已登录");
  175. this.$router.push('/project/create');
  176. }
  177. },
  178. handleTabClick(tab){
  179. this.currTab = tab.name;
  180. console.log(this.currTab);
  181. console.log(this.homeTabArr.menuArr1[Number(tab.index)].linkTo)
  182. this.$router.push(this.homeTabArr.menuArr1[Number(tab.index)].linkTo);
  183. },
  184. handleTypeClick(tab){
  185. this.searchType = tab.name
  186. },
  187. handleSearchData(){
  188. if(this.searchType == 0){
  189. // this.$router.push({name: 'Square2.0', params: {searchVal: this.searchVal, searchType: "project"}});
  190. }else if(this.searchType == 1){
  191. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  192. }else if(this.searchType == 2){
  193. this.$router.push({name: 'ResourceList', params: {searchVal: this.searchVal}});
  194. }else if(this.searchType == 3){
  195. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  196. }
  197. }
  198. },
  199. mounted() {
  200. this.loadData();
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. @import "../../style/search-nav";
  206. .home-wrapper {
  207. /deep/ .square-tab .el-tabs__item {
  208. font-size: 16px !important;
  209. margin-right: 0px !important;
  210. }
  211. /deep/ .login-card .popular-list {
  212. padding: 0 10px !important;
  213. }
  214. .home-page {
  215. padding: 15px 0;
  216. }
  217. .test-type-wrapper {
  218. padding-right: 15px;
  219. margin-bottom: 15px;
  220. }
  221. .homepage-right-modules {
  222. .login-card .el-card__body {
  223. padding: 10px !important;
  224. }
  225. .popular-card .el-card__header {
  226. padding: 10px !important;
  227. }
  228. .popular-card .el-card__body {
  229. padding: 10px !important;
  230. }
  231. }
  232. }
  233. </style>