Homepage.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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"
  17. :name="item.value" :key="item.value"></el-tab-pane>
  18. </el-tabs>
  19. <div class="search-input">
  20. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  21. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  22. </el-input>
  23. </div>
  24. </div>
  25. </div>
  26. </el-col>
  27. <el-col :span="6">
  28. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  29. </el-col>
  30. </el-row>
  31. <!--TabNav-->
  32. <el-tabs v-model="currTab" @tab-click="handleTabClick" class="square-tab">
  33. <el-tab-pane v-for="item in homeTabArr.menuArr1" :label="item.label" :name="item.name"
  34. :key="item.name"></el-tab-pane>
  35. <el-tab-pane v-for="item in homeTabArr.menuArr2" :label="item.name" :name="item.code"
  36. :key="item.code"></el-tab-pane>
  37. <el-tab-pane v-for="item in homeTabArr.menuArr3" :label="item.label" :name="item.name"
  38. :key="item.name"></el-tab-pane>
  39. </el-tabs>
  40. <div>
  41. </div>
  42. </div>
  43. <div class="home-page container" >
  44. <el-row>
  45. <el-col :span="19" class="test-type-wrapper">
  46. <TestMenu :testTypeList="homeData.testTypeList"></TestMenu>
  47. <TestCard :applicationTypeList="homeData.applicationTypeList"></TestCard>
  48. <el-row style="margin-top: 10px">
  49. <ResourceAndTool :resourceList="homeDataNoCache.resourceList"></ResourceAndTool>
  50. </el-row>
  51. <el-row>
  52. <BrandCard :residentAgencyList=homeData.residentAgencyList></BrandCard>
  53. </el-row>
  54. </el-col>
  55. <el-col :span="5" class="homepage-right-modules">
  56. <LoginCard/>
  57. <HotCrowd :applicationTypeRank="homeDataNoCache.applicationTypeRank"/>
  58. <HotAgency :agencyRank="homeDataNoCache.agencyRank"/>
  59. <HotUser :userRank="homeDataNoCache.userRank"/>
  60. <HotContest :competitionList="homeData.competitionList"/>
  61. </el-col>
  62. </el-row>
  63. <InstitutionCard></InstitutionCard>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. // import commonData from '../../constants/tabMenu'
  69. import SearchBar from '../../components/commons/SearchBar'
  70. import TestMenu from './TestMenu'
  71. import LoginCard from './LoginCard'
  72. import BrandCard from './BrandCard'
  73. import ResourceAndTool from './ResourceAndTool'
  74. import TestCard from './TestCard'
  75. import InstitutionCard from './InstitutionCard'
  76. import HotCrowd from './HotCrowd'
  77. import HotAgency from './HotAgency'
  78. import HotUser from './HotUser'
  79. import HotContest from './HotContest'
  80. import PopularProject from '../Square/PopularProject'
  81. import Http from '@/js/http.js'
  82. import {mapActions, mapGetters} from 'vuex'
  83. import Waterfall from 'vue-waterfall/lib/waterfall'
  84. import WaterfallSlot from 'vue-waterfall/lib/waterfall-slot'
  85. import {storageGet, getAllFields} from '@/js/index.js'
  86. import {notify} from "../../constants";
  87. import Apis from '@/js/api'
  88. // console.log(commonData);
  89. export default {
  90. name: 'Homepage',
  91. components: {
  92. HotCrowd,
  93. HotContest,
  94. HotUser,
  95. HotAgency,
  96. InstitutionCard,
  97. SearchBar,
  98. TestMenu,
  99. PopularProject,
  100. LoginCard,
  101. TestCard,
  102. BrandCard,
  103. ResourceAndTool,
  104. Waterfall,
  105. WaterfallSlot
  106. // vueWaterfallEasy
  107. },
  108. data() {
  109. return {
  110. user: {},
  111. isLogin: false,
  112. loading: false,
  113. searchType: '0',
  114. searchTypeArr: [
  115. {
  116. "name": "全部",
  117. "value": "all"
  118. },
  119. {
  120. "name": "项目",
  121. "value": "0"
  122. },
  123. {
  124. "name": "机构",
  125. "value": "1"
  126. },
  127. {
  128. "name": "工具",
  129. "value": "2"
  130. },
  131. {
  132. "name": "专家",
  133. "value": "3"
  134. }],
  135. searchVal: '',
  136. homeTabArr: {
  137. menuArr1: [
  138. {label: "首页", name: "homepage", linkTo: '/home'},
  139. {label: "众测广场", name: "square", linkTo: '/square'},
  140. {label: "众测技术", name: "technology", linkTo: 'technology'}
  141. ],
  142. menuArr2: [
  143. {code: '', name: ''}
  144. ],
  145. menuArr3: [
  146. {label: "找机构", name: "findInstitution", linkTo: '/agency/list/show'},
  147. {label: "找专家", name: "findExpert", linkTo: '/expert/list'},
  148. ],
  149. },
  150. homeData: {},
  151. homeDataNoCache: {},
  152. currTab: 'homepage'
  153. }
  154. },
  155. methods: {
  156. loadData() {
  157. this.showLoading();
  158. if (storageGet('user') != null) {
  159. this.isLogin = true;
  160. }
  161. this.setFields();
  162. let p1 = new Promise((resolve, reject) => {
  163. Http.get('/api/common/index/info/cache').then((res) => {
  164. this.homeData = res.data;
  165. // this.homeData.applicationTypeList.map((item)=>{
  166. // item.height = (item.testTypeList.length / 2) * 24 + 100;
  167. // return item;
  168. // })
  169. resolve(res.data);
  170. }).catch((error) => {
  171. notify('error', error.data)
  172. reject(error)
  173. })
  174. });
  175. let p2 = new Promise((resolve, reject) => {
  176. Http.get('/api/common/index/info/nocache').then((res) => {
  177. this.homeDataNoCache = res.data;
  178. resolve(res.data);
  179. }).catch((error) => {
  180. notify('error', error.data)
  181. reject(error)
  182. })
  183. });
  184. Promise.all([p1, p2]).then((result) => {
  185. this.hideLoading();
  186. }).catch((error) => {
  187. notify('error', error.data)
  188. })
  189. },
  190. setFields() {
  191. getAllFields().then((res) => {
  192. this.homeTabArr.menuArr2 = res
  193. // console.log(this.homeTabArr.menuArr2)
  194. })
  195. },
  196. checkLogin() {
  197. this.checkCreateProjectAuth();
  198. },
  199. checkCreateProjectAuth() {
  200. if (!this.isLogin) {
  201. console.log("请登录后访问");
  202. notify('warning', '请登录后访问');
  203. } else if (this.isLogin) {
  204. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  205. this.$router.push('/project/create');
  206. }).catch((error) => {
  207. notify('error', error.data)
  208. })
  209. }
  210. },
  211. handleTabClick(tab) {
  212. this.currTab = tab.name;
  213. // console.log(this.currTab + " " + tab.index + " " + tab.name );
  214. for (let i = 0; i < this.homeTabArr.menuArr3.length; i++) {
  215. if (this.currTab === this.homeTabArr.menuArr3[i].name) {
  216. this.$router.push(this.homeTabArr.menuArr3[i].linkTo);
  217. }
  218. }
  219. for (let i = 0; i < this.homeTabArr.menuArr2.length; i++) {
  220. if (this.currTab === this.homeTabArr.menuArr2[i].code) {
  221. this.$router.push('/field/detail');
  222. }
  223. }
  224. this.$router.push(this.homeTabArr.menuArr1[Number(tab.index)].linkTo);
  225. },
  226. handleTypeClick(tab) {
  227. this.searchType = tab.name
  228. },
  229. handleSearchData() {
  230. if (this.searchType == 0) {
  231. this.$router.push({
  232. name: 'Square',
  233. params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}
  234. });
  235. } else if (this.searchType == 1) {
  236. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  237. } else if (this.searchType == 2) {
  238. this.$router.push({name: 'ResourceList', params: {searchVal: this.searchVal}});
  239. } else if (this.searchType == 3) {
  240. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  241. }
  242. },
  243. showLoading() {
  244. this.loading = true
  245. },
  246. hideLoading() {
  247. this.loading = false
  248. },
  249. setUserInfo() {
  250. this.user = storageGet('user') && storageGet('user').userVO;
  251. }
  252. },
  253. mounted() {
  254. this.setUserInfo();
  255. this.loadData();
  256. }
  257. }
  258. </script>
  259. <style lang="less">
  260. @import "../../style/search-nav";
  261. .home-wrapper {
  262. /deep/ .square-tab .el-tabs__item {
  263. font-size: 16px !important;
  264. margin-right: 0px !important;
  265. }
  266. /deep/ .login-card .popular-list {
  267. padding: 0 10px !important;
  268. }
  269. .home-page {
  270. padding: 15px 0;
  271. }
  272. .test-type-wrapper {
  273. padding-right: 15px;
  274. margin-bottom: 15px;
  275. }
  276. .homepage-right-modules {
  277. .login-card .el-card__body {
  278. padding: 10px !important;
  279. }
  280. .popular-card .el-card__header {
  281. padding: 10px !important;
  282. }
  283. .popular-card .el-card__body {
  284. padding: 10px !important;
  285. }
  286. }
  287. }
  288. </style>