Homepage.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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 :applicationTypeList="homeData.applicationTypeList"></TestCard>
  44. </el-col>
  45. <el-col :span="5" class="homepage-right-modules">
  46. <LoginCard/>
  47. <HotCrowd :applicationTypeRank="homeDataNoCache.applicationTypeRank"/>
  48. <HotAgency :agencyRank="homeDataNoCache.agencyRank"/>
  49. <HotUser :userRank="homeDataNoCache.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="homeDataNoCache.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/show'},
  142. {label: "找专家", name: "findExpert",linkTo:'/expert/list'},
  143. ],
  144. },
  145. homeData:{},
  146. homeDataNoCache: {},
  147. currTab:'homepage'
  148. }
  149. },
  150. methods:{
  151. loadData(){
  152. if (storageGet('user') != null) {
  153. this.isLogin = true;
  154. }
  155. this.setFields();
  156. Http.get('/api/common/index/info/cache').then((res)=>{
  157. console.log(res.data);
  158. this.homeData = res.data;
  159. // this.homeData.applicationTypeList.map((item)=>{
  160. // item.height = (item.testTypeList.length / 2) * 24 + 100;
  161. // return item;
  162. // })
  163. })
  164. Http.get('/api/common/index/info/nocache').then((res)=>{
  165. this.homeDataNoCache = res.data;
  166. })
  167. },
  168. setFields(){
  169. getAllFields().then((res) => {
  170. this.homeTabArr.menuArr2 = res
  171. // console.log(this.homeTabArr.menuArr2)
  172. })
  173. },
  174. checkLogin(){
  175. if(!this.isLogin){
  176. console.log("请登录后访问");
  177. notify('warning','请登录后访问');
  178. }else{
  179. console.log("已登录");
  180. this.$router.push('/project/create');
  181. }
  182. },
  183. handleTabClick(tab){
  184. this.currTab = tab.name;
  185. // console.log(this.currTab + " " + tab.index + " " + tab.name );
  186. for(let i = 0; i < this.homeTabArr.menuArr3.length; i++){
  187. if (this.currTab === this.homeTabArr.menuArr3[i].name){
  188. this.$router.push(this.homeTabArr.menuArr3[i].linkTo);
  189. }
  190. }
  191. for(let i = 0; i < this.homeTabArr.menuArr2.length; i++){
  192. if (this.currTab === this.homeTabArr.menuArr2[i].code){
  193. this.$router.push('/field/detail');
  194. }
  195. }
  196. this.$router.push(this.homeTabArr.menuArr1[Number(tab.index)].linkTo);
  197. },
  198. handleTypeClick(tab){
  199. this.searchType = tab.name
  200. },
  201. handleSearchData(){
  202. if(this.searchType == 0){
  203. this.$router.push({name: 'Square', params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}});
  204. }else if(this.searchType == 1){
  205. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  206. }else if(this.searchType == 2){
  207. this.$router.push({name: 'ResourceList', params: {searchVal: this.searchVal}});
  208. }else if(this.searchType == 3){
  209. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  210. }
  211. }
  212. },
  213. mounted() {
  214. this.loadData();
  215. }
  216. }
  217. </script>
  218. <style lang="less">
  219. @import "../../style/search-nav";
  220. .home-wrapper {
  221. /deep/ .square-tab .el-tabs__item {
  222. font-size: 16px !important;
  223. margin-right: 0px !important;
  224. }
  225. /deep/ .login-card .popular-list {
  226. padding: 0 10px !important;
  227. }
  228. .home-page {
  229. padding: 15px 0;
  230. }
  231. .test-type-wrapper {
  232. padding-right: 15px;
  233. margin-bottom: 15px;
  234. }
  235. .homepage-right-modules {
  236. .login-card .el-card__body {
  237. padding: 10px !important;
  238. }
  239. .popular-card .el-card__header {
  240. padding: 10px !important;
  241. }
  242. .popular-card .el-card__body {
  243. padding: 10px !important;
  244. }
  245. }
  246. }
  247. </style>