Technology2.0.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="technology-container">
  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" @click="handleLogoClick">
  8. <!-- <img class="logo-img" :src="logo_transparent" :to="'/home'"/>-->
  9. <!-- <span class="logo-title">{{ logoTitle }}</span>-->
  10. </div>
  11. </el-col>
  12. <el-col :span="15">
  13. <div class="search-nav-input">
  14. <div id="search-block " class="">
  15. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  16. <el-tab-pane v-for="item in searchTypeArr" :label="item.label" :name="item.value" :key="item.value"></el-tab-pane>
  17. </el-tabs>
  18. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  19. <el-button class="search-button" slot="append" type="primary" @click="loadTechnologyArticles(1)">搜索</el-button>
  20. </el-input>
  21. </div>
  22. </div>
  23. </el-col>
  24. <el-col :span="4">
  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="searchType" @tab-click="handleTabClick" class="container square-tab">
  30. <el-tab-pane v-for="item in searchTypeArr" :name="item.value" :key="item.value">
  31. <span slot="label" style="font-size: 18px">{{item.name}}</span>
  32. </el-tab-pane>
  33. </el-tabs>
  34. <div>
  35. </div>
  36. </div>
  37. <div class="container" style="margin: 15px auto" v-loading="loading">
  38. <el-row>
  39. <el-col :span="18" class="project-task">
  40. <CrowdTool
  41. :toolList = techArticleList.content v-if="searchType=='2'">
  42. </CrowdTool>
  43. <CrowdCase
  44. :caseList = techArticleList.content v-if="searchType=='3'" @refreshList="loadTechnologyArticles(activePage)">
  45. </CrowdCase>
  46. <TechnologyCard
  47. :techArticleList = techArticleList.content v-if="searchType=='0'" @refreshList="loadTechnologyArticles(activePage)">
  48. </TechnologyCard>
  49. <TechnologyMG :techArticleList = techArticleList.content v-if="searchType=='1'"></TechnologyMG>
  50. <el-pagination
  51. v-if="techArticleList.content&&techArticleList.content.length"
  52. :page-size="5"
  53. layout="prev, pager, next"
  54. :total="techArticleList.totalElements"
  55. @current-change="handlePageChange"
  56. :current-page = activePage
  57. class="pull-right"
  58. >
  59. </el-pagination>
  60. </el-col>
  61. <el-col :span="6" class="popular-modules" v-if="TECHNOLOGY_DISPLAY.hot_article">
  62. <HotActicle :articleArr="articleArr" @refreshHotArticle="loadHotArticles" />
  63. </el-col>
  64. </el-row>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import Http from '@/js/http.js'
  70. import Apis from '@/js/api.js'
  71. import SearchBar from '../../components/commons/SearchBar'
  72. import TechnologyCard from './TechnologyCard'
  73. import TechnologyMG from './TechnologyMG'
  74. import CrowdCase from './CrowdCase'
  75. import CrowdTool from './CrowdTool'
  76. import HotActicle from './HotActicle'
  77. import PopularProject from '../Square/PopularProject'
  78. import {storageGet} from '@/js/index.js'
  79. import {notify} from "../../constants";
  80. import {CONFIG} from "../../config";
  81. export default {
  82. name: 'Technology2.0',
  83. components: {
  84. SearchBar,
  85. TechnologyCard,
  86. TechnologyMG,
  87. PopularProject,
  88. HotActicle,
  89. CrowdCase,
  90. CrowdTool
  91. },
  92. data(){
  93. return {
  94. logoTitle:CONFIG.logoTitle,
  95. logo_transparent:CONFIG.logo_transparent,
  96. TECHNOLOGY_DISPLAY:CONFIG.TECHNOLOGY_DISPLAY,
  97. loading: false,
  98. isLogin: false,
  99. searchVal: '',
  100. searchType:CONFIG.technology_searchType,
  101. searchTypeArr:CONFIG.technology_searchTypeArr,
  102. articleArr:[],
  103. keyword:"",
  104. activePage:1,
  105. techArticleList:{},
  106. }
  107. },
  108. methods:{
  109. handleLogoClick(){
  110. window.open('http://47.98.174.59:8200/#/');
  111. },
  112. loadData(){
  113. if (storageGet('user') != null) {
  114. this.isLogin = true;
  115. }
  116. },
  117. checkLogin() {
  118. this.checkCreateProjectAuth();
  119. },
  120. checkCreateProjectAuth() {
  121. if (!this.isLogin) {
  122. notify('warning', '请登录后访问');
  123. } else if (this.isLogin) {
  124. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  125. this.$router.push('/project/create');
  126. }).catch((error) => {
  127. notify('error', error.data)
  128. })
  129. }
  130. },
  131. //显示页面加载画面
  132. showLoading() {
  133. this.loading = true
  134. },
  135. //隐藏页面加载画面
  136. hideLoading() {
  137. this.loading = false
  138. },
  139. gotoHome(){
  140. this.$router.push('/home');
  141. },
  142. handleTypeClick(tab){
  143. this.handleTabClick(tab);
  144. },
  145. handleTabClick(tab){
  146. this.searchType = tab.name
  147. this.activePage = 1;
  148. this.searchVal = '';
  149. this.loadTechnologyArticles(1);
  150. },
  151. loadHotArticles(){
  152. Http.get('/api/technical/ranking').then((res)=>{
  153. this.articleArr = res.data.technicalArticlesPage.content;
  154. })
  155. },
  156. loadTechnologyArticles(index){
  157. this.showLoading()
  158. let url = '/api/technical/articles';
  159. this.activePage = index;
  160. let params = {
  161. "keyword": this.searchVal,//查询条件,分页展示时就不填
  162. "activePage": this.activePage,//指定页数
  163. "columnFilters": [
  164. {
  165. "field": "type",
  166. "type": "enums",
  167. "enums": this.searchTypeArr,
  168. "value": this.searchType//展示技术文章value为0
  169. }
  170. ],
  171. "sortType":(this.searchType === '2' || this.searchType === '3' ) ? 'id' : 'publicTime'
  172. };
  173. Http.post(url,params)
  174. .then(res=>{
  175. let { technicalArticlesPage , publicationsPage ,toolVOPage,taskVOS} = res.data;
  176. this.techArticleList = technicalArticlesPage || publicationsPage || toolVOPage || taskVOS;
  177. // console.log(res.data)
  178. this.hideLoading()
  179. // if(res.data.technicalArticlesPage){
  180. // this.techArticleList = res.data.technicalArticlesPage;
  181. // }else if(res.data.publicationsPage){
  182. // this.techArticleList = res.data.publicationsPage;
  183. // }else if(res.data.toolVOPage){
  184. // this.techArticleList = res.data.toolVOPage;
  185. // } else if(res.data.taskVOS){
  186. // this.techArticleList = res.data.taskVOS
  187. // }
  188. })
  189. },
  190. handlePageChange(index){
  191. this.activePage = index;
  192. this.loadTechnologyArticles(index);
  193. },
  194. setUserInfo() {
  195. this.user = storageGet('user') && storageGet('user').userVO;
  196. }
  197. },
  198. mounted() {
  199. this.loadData();
  200. this.setUserInfo();
  201. this.loadHotArticles();
  202. this.loadTechnologyArticles(1);
  203. }
  204. }
  205. </script>
  206. <style lang="scss">
  207. @import "../../style/search-nav.scss";
  208. .technology-container {
  209. /deep/ .search-input,/deep/ .releaseBtn{
  210. margin: 20px 0 0 0 !important;
  211. }
  212. .popular-modules {
  213. padding-left: 15px;
  214. }
  215. }
  216. </style>