HomepagePrivate.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class="home-wrapper">
  3. <div class="nav" stype="height:500px">
  4. <!--搜索框-->
  5. <el-row class="container search-nav" style="padding: 30px 0 20px 0">
  6. <el-col :span="5">
  7. <div class="pull-left to-mooctest-ranking" :style="{backgroundImage: 'url(' + mooctest_rank_logo_url + ')'}" @click="handleLogoClick"></div>
  8. </el-col>
  9. <el-col :span="15">
  10. <!-- <div class="search-nav-input">-->
  11. <!-- <div id="search-block ">-->
  12. <!-- <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">-->
  13. <!-- <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name"-->
  14. <!-- :name="item.value" :key="item.value"></el-tab-pane>-->
  15. <!-- </el-tabs>-->
  16. <!-- <div class="search-input">-->
  17. <!-- <el-input ref="searchInput" placeholder="请输入内容" v-model="searchVal" class="input-with-select">-->
  18. <!-- <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>-->
  19. <!-- </el-input>-->
  20. <!-- </div>-->
  21. <!-- </div>-->
  22. <!-- </div>-->
  23. </el-col>
  24. <el-col :span="19">
  25. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">发布众测需求</el-button>
  26. </el-col>
  27. </el-row>
  28. <!--TabNav-->
  29. <el-tabs v-model="currTab" @tab-click="handleTabClick" class="container square-tab">
  30. <el-tab-pane v-for="item in homeTabArr.menuArr1" :name="item.name"
  31. :key="item.name">
  32. <span slot="label" style="font-size: 18px">{{item.label}}</span>
  33. </el-tab-pane>
  34. <el-tab-pane v-for="item in homeTabArr.menuArr2" :name="item.code"
  35. :key="item.code">
  36. <span slot="label" style="font-size: 18px">{{item.label}}</span>
  37. </el-tab-pane>
  38. <el-tab-pane v-for="item in homeTabArr.menuArr3" :name="item.name"
  39. :key="item.name">
  40. <span slot="label" style="font-size: 18px">{{item.label}}</span>
  41. </el-tab-pane>
  42. </el-tabs>
  43. <div>
  44. </div>
  45. </div>
  46. <div class="container home-page ">
  47. <el-row :gutter="15">
  48. <el-col :span="5" class="homepage-right-modules">
  49. <LoginCard v-if="HOME_DISPLAY.login_card"/>
  50. <PopularProject :hotCrowdTestProjectVOs="homeDataNoCache.projectList" v-if="HOME_DISPLAY.hot_project"/>
  51. <PopularTask :hotCrowdTaskVOs="homeDataNoCache.taskList" v-if="HOME_DISPLAY.hot_task"/>
  52. <HotCrowd :applicationTypeRank="homeDataNoCache.applicationTypeRank" v-if="HOME_DISPLAY.hot_crowd"/>
  53. <HotAgency :agencyRank="homeDataNoCache.agencyRank" v-if="HOME_DISPLAY.hot_agency"/>
  54. <HotUser :userRank="homeDataNoCache.userRank" v-if="HOME_DISPLAY.hot_user"/>
  55. <HotContest :competitionList="homeData.competitionList" v-if="HOME_DISPLAY.hot_contest"/>
  56. </el-col>
  57. <el-col :span="19" class="test-type-wrapper">
  58. <TestMenu :testTypeList="homeData.testTypeList" v-if="HOME_DISPLAY.test_menu && homeData.testTypeList"></TestMenu>
  59. <RankingCard v-if="HOME_DISPLAY.mooctest_rank"></RankingCard>
  60. <TestCard :applicationTypeList="homeData.applicationTypeList" v-if="HOME_DISPLAY.test_card && homeData.applicationTypeList"></TestCard>
  61. <el-row style="margin-top: 10px" v-if="HOME_DISPLAY.resource_and_tool">
  62. <ResourceAndTool :resourceList="homeData.toolList && homeData.toolList"></ResourceAndTool>
  63. </el-row>
  64. <el-row>
  65. <BrandCard :residentAgencyList="homeData.residentAgencyList" v-if="HOME_DISPLAY.brand_card && homeData.residentAgencyList"></BrandCard>
  66. </el-row>
  67. </el-col>
  68. </el-row>
  69. <InstitutionCard v-if="HOME_DISPLAY.institution_card"></InstitutionCard>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. // import commonData from '../../constants/tabMenu'
  75. import SearchBar from '../../components/commons/SearchBar'
  76. import TestMenu from './TestMenu'
  77. import LoginCard from './LoginCard'
  78. import BrandCard from './BrandCard'
  79. import ResourceAndTool from './ResourceAndTool'
  80. import TestCard from './TestCard'
  81. import InstitutionCard from './InstitutionCard'
  82. import HotCrowd from './HotCrowd'
  83. import HotAgency from './HotAgency'
  84. import HotUser from './HotUser'
  85. import RankingCard from './RankingCard'
  86. import HotContest from './HotContest'
  87. import PopularTask from '../Square/PopularTask'
  88. import PopularProject from '../Square/PopularProject'
  89. import Http from '@/js/http.js'
  90. import {mapGetters} from 'vuex'
  91. import Waterfall from 'vue-waterfall/lib/waterfall'
  92. import WaterfallSlot from 'vue-waterfall/lib/waterfall-slot'
  93. import {getAllFields, storageGet} from '@/js/index.js'
  94. import {notify} from "../../constants";
  95. import Apis from '@/js/api'
  96. import {CONFIG} from "../../config";
  97. export default {
  98. name: 'Homepage',
  99. components: {
  100. HotCrowd,
  101. HotContest,
  102. HotUser,
  103. HotAgency,
  104. PopularTask,
  105. InstitutionCard,
  106. SearchBar,
  107. TestMenu,
  108. PopularProject,
  109. LoginCard,
  110. RankingCard,
  111. TestCard,
  112. BrandCard,
  113. ResourceAndTool,
  114. Waterfall,
  115. WaterfallSlot
  116. // vueWaterfallEasy
  117. },
  118. data() {
  119. return {
  120. logoTitle:CONFIG.logoTitle,
  121. HOME_DISPLAY:CONFIG.HOME_DISPLAY,
  122. logo_transparent:CONFIG.logo_transparent,
  123. background_image: CONFIG.background_image,
  124. mooctest_rank_url: CONFIG.mooctest_rank_url,
  125. mooctest_rank_logo_url: CONFIG.mooctest_rank_logo_url,
  126. user: {},
  127. isLogin: false,
  128. searchType: CONFIG.home_searchType,
  129. searchTypeArr: CONFIG.home_searchTypeArr,
  130. searchVal: '',
  131. homeTabArr: {
  132. menuArr1: CONFIG.home_homeTabArr_left,
  133. menuArr2: [{code: '', name: ''}],
  134. menuArr3: CONFIG.home_homeTabArr_right
  135. },
  136. homeData: {},
  137. homeDataNoCache: {},
  138. currTab: CONFIG.home_homeTabArr_default
  139. }
  140. },
  141. computed: {
  142. ...mapGetters(['getUserInfo'])
  143. },
  144. methods: {
  145. loadData() {
  146. this.showLoading();
  147. if (storageGet('user') != null) {
  148. this.isLogin = true;
  149. }
  150. // this.setFields();
  151. let p1 = new Promise((resolve, reject) => {
  152. Http.get('/api/common/index/info/cache').then((res) => {
  153. this.homeData = res.data;
  154. // this.homeData.applicationTypeList.map((item)=>{
  155. // item.height = (item.testTypeList.length / 2) * 24 + 100;
  156. // return item;
  157. // })
  158. this.homeTabArr.menuArr2 = res.data.fieldList
  159. resolve(res.data);
  160. }).catch((error) => {
  161. notify('error', error.data)
  162. reject(error)
  163. })
  164. });
  165. let p2 = new Promise((resolve, reject) => {
  166. Http.get('/api/common/index/info/nocache').then((res) => {
  167. this.homeDataNoCache = res.data;
  168. resolve(res.data);
  169. }).catch((error) => {
  170. notify('error', error.data)
  171. reject(error)
  172. })
  173. });
  174. Promise.all([p1, p2]).then((result) => {
  175. this.hideLoading();
  176. }).catch((error) => {
  177. notify('error', error.data)
  178. })
  179. },
  180. setFields() {
  181. getAllFields().then((res) => {
  182. this.homeTabArr.menuArr2 = res
  183. })
  184. },
  185. checkLogin() {
  186. this.checkCreateProjectAuth();
  187. },
  188. handleLogoClick(){
  189. window.open(this.mooctest_rank_url, "_blank");
  190. },
  191. checkCreateProjectAuth() {
  192. if (!this.isLogin) {
  193. notify('warning', '请登录后访问');
  194. } else if (this.isLogin) {
  195. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  196. this.$router.push('/project/create');
  197. }).catch((error) => {
  198. notify('error', error.data)
  199. })
  200. }
  201. },
  202. handleTabClick(tab) {
  203. this.currTab = tab.name;
  204. // console.log(this.currTab + " " + tab.index + " " + tab.name );
  205. for (let i = 0; i < this.homeTabArr.menuArr3.length; i++) {
  206. if (this.currTab === this.homeTabArr.menuArr3[i].name) {
  207. this.$router.push(this.homeTabArr.menuArr3[i].linkTo);
  208. }
  209. }
  210. for (let i = 0; i < this.homeTabArr.menuArr2.length; i++) {
  211. if (this.currTab === this.homeTabArr.menuArr2[i].code) {
  212. // this.$router.push('/field/detail');
  213. this.$router.push({name: 'PopularProjectAndTaskList', params: {fieldCode: this.homeTabArr.menuArr2[i].code}})
  214. }
  215. }
  216. this.$router.push(this.homeTabArr.menuArr1[Number(tab.index)] && this.homeTabArr.menuArr1[Number(tab.index)].linkTo);
  217. },
  218. handleTypeClick(tab, e) {
  219. this.searchType = tab.name;
  220. // e.target.style.backgroundColor = $color-primary
  221. this.$refs.searchInput.focus()
  222. },
  223. handleSearchData() {
  224. if (this.searchType == 0) {
  225. this.$router.push({
  226. name: 'Square',
  227. params: {searchVal: this.searchVal, searchType: "project", currTab: "project"}
  228. });
  229. } else if (this.searchType == 1) {
  230. this.$router.push({name: 'AgencyList', params: {searchVal: this.searchVal}});
  231. } else if (this.searchType == 2) {
  232. this.$router.push({name: 'ResourceList', params: {searchVal: this.searchVal}});
  233. } else if (this.searchType == 3) {
  234. this.$router.push({name: 'ExpertList', params: {searchVal: this.searchVal}});
  235. }
  236. },
  237. showLoading() {
  238. this.loading = true
  239. },
  240. hideLoading() {
  241. this.loading = false
  242. },
  243. setUserInfo() {
  244. this.user = storageGet('user') && storageGet('user').userVO;
  245. }
  246. },
  247. mounted() {
  248. this.setUserInfo();
  249. this.loadData();
  250. },
  251. watch: {
  252. getUserInfo(val) {
  253. this.setUserInfo();
  254. this.loadData();
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss">
  260. @import "../../style/search-nav.scss";
  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>