Technology2.0.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="technology-container">
  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" @click="gotoHome" style="cursor: pointer">
  8. <img class="logo-img" src="../../assets/img/logo-blue.png" />
  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 " class="">
  15. <div class="search-input">
  16. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  17. <el-tab-pane v-for="item in searchTypeArr" :label="item.label" :name="item.value" :key="item.value"></el-tab-pane>
  18. </el-tabs>
  19. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  20. <el-button class="search-button" slot="append" type="primary" @click="loadTechnologyArticles(1)">搜索</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="searchType" @tab-click="handleTabClick" class="square-tab">
  32. <el-tab-pane v-for="item in searchTypeArr" :name="item.value" :key="item.value">
  33. <span slot="label" style="font-size: 18px">{{item.name}}</span>
  34. </el-tab-pane>
  35. </el-tabs>
  36. <div>
  37. </div>
  38. </div>
  39. <div class="container" style="margin: 15px auto">
  40. <el-row>
  41. <el-col :span="18" class="project-task">
  42. <TechnologyCard
  43. :techArticleList = techArticleList.content v-if="searchType=='0'" @refreshList="loadTechnologyArticles(activePage)">
  44. </TechnologyCard>
  45. <TechnologyMG :techArticleList = techArticleList.content v-if="searchType=='1'"></TechnologyMG>
  46. <el-pagination
  47. v-if="techArticleList.content&&techArticleList.content.length"
  48. :page-size="10"
  49. layout="prev, pager, next"
  50. :total="techArticleList.totalElements"
  51. @current-change="handlePageChange"
  52. :current-page = activePage
  53. class="pull-right"
  54. >
  55. </el-pagination>
  56. </el-col>
  57. <el-col :span="6" class="popular-modules">
  58. <HotActicle :articleArr="articleArr" @refreshHotArticle="loadHotArticles"/>
  59. </el-col>
  60. </el-row>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import Http from '@/js/http.js'
  66. import SearchBar from '../../components/commons/SearchBar'
  67. import TechnologyCard from './TechnologyCard'
  68. import TechnologyMG from './TechnologyMG'
  69. import HotActicle from './HotActicle'
  70. import PopularProject from '../Square/PopularProject'
  71. import {storageGet} from '@/js/index.js'
  72. import {notify} from "../../constants";
  73. import qs from 'querystring'
  74. import { mapActions ,mapGetters} from 'vuex';
  75. export default {
  76. name: 'Technology2.0',
  77. components: {
  78. SearchBar,
  79. TechnologyCard,
  80. TechnologyMG,
  81. PopularProject,
  82. HotActicle
  83. },
  84. data(){
  85. return {
  86. isLogin: false,
  87. searchVal: '',
  88. searchType:'',
  89. searchTypeArr:[
  90. {
  91. "name": "技术文章",
  92. "value": "0",
  93. "label":'文章'
  94. },
  95. {
  96. "name": "论文专著",
  97. "value": "1",
  98. "label":'专著'
  99. }
  100. ],
  101. articleArr:[],
  102. keyword:"",
  103. activePage:1,
  104. techArticleList:{},
  105. }
  106. },
  107. methods:{
  108. loadData(){
  109. if (storageGet('user') != null) {
  110. this.isLogin = true;
  111. }
  112. },
  113. checkLogin(){
  114. if(!this.isLogin){
  115. console.log("请登录后访问");
  116. notify('warning','请登录后访问');
  117. }else{
  118. console.log("已登录");
  119. this.$router.push('/project/create');
  120. }
  121. },
  122. gotoHome(){
  123. this.$router.push('/home');
  124. },
  125. handleTypeClick(tab){
  126. this.handleTabClick(tab);
  127. },
  128. handleTabClick(tab){
  129. this.searchType = tab.name
  130. this.activePage = 1;
  131. this.searchVal = '';
  132. this.loadTechnologyArticles(1);
  133. },
  134. loadHotArticles(){
  135. Http.get('/api/technical/ranking').then((res)=>{
  136. this.articleArr = res.data.technicalArticlesPage.content;
  137. })
  138. },
  139. loadTechnologyArticles(index){
  140. // let url=`/api/technical/articles?searchCondition={"keyword":"${this.keyword}","activePage":${this.activePage}}`;
  141. // Http.get(encodeURI(url))
  142. let url = '/api/technical/articles';
  143. this.activePage = index;
  144. let params = {
  145. "keyword": this.searchVal,//查询条件,分页展示时就不填
  146. "activePage": this.activePage,//指定页数
  147. "columnFilters": [
  148. {
  149. "field": "type",
  150. "type": "enums",
  151. "enums": this.searchTypeArr,
  152. "value": this.searchType//展示技术文章value为0
  153. }
  154. ]
  155. }
  156. Http.post(url,params)
  157. .then(res=>{
  158. if(res.data.technicalArticlesPage){
  159. this.techArticleList = res.data.technicalArticlesPage;
  160. this.searchType = '0';
  161. }
  162. else if(res.data.publicationsPage){
  163. this.techArticleList = res.data.publicationsPage;
  164. this.searchType = '1';
  165. }
  166. })
  167. },
  168. handlePageChange(index){
  169. this.activePage = index;
  170. this.loadTechnologyArticles(index);
  171. }
  172. },
  173. mounted() {
  174. this.loadData();
  175. this.loadHotArticles();
  176. this.loadTechnologyArticles(1);
  177. }
  178. }
  179. </script>
  180. <style lang="less">
  181. @import "../../style/search-nav";
  182. .technology-container {
  183. /deep/ .search-input,/deep/ .releaseBtn{
  184. margin: 20px 0 0 0 !important;
  185. }
  186. .popular-modules {
  187. padding-left: 15px;
  188. }
  189. }
  190. </style>