TechnologyMore.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/image/logo-transparent.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. <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="6">
  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="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">
  38. <el-row>
  39. <el-col :span="18" class="project-task">
  40. <TechnologyCard
  41. :techArticleList = techArticleList.content v-if="searchType=='0'" @refreshList="loadTechnologyArticles(activePage)">
  42. </TechnologyCard>
  43. <TechnologyMG :techArticleList = techArticleList.content v-if="searchType=='1'"></TechnologyMG>
  44. <el-pagination
  45. v-if="techArticleList.content&&techArticleList.content.length"
  46. :page-size="5"
  47. layout="prev, pager, next"
  48. :total="techArticleList.totalElements"
  49. @current-change="handlePageChange"
  50. :current-page = activePage
  51. class="pull-right"
  52. >
  53. </el-pagination>
  54. </el-col>
  55. <!-- <el-col :span="6" class="popular-modules">-->
  56. <!-- <HotActicle :articleArr="articleArr" @refreshHotArticle="loadHotArticles"/>-->
  57. <!-- </el-col>-->
  58. </el-row>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import Http from '@/js/http.js'
  64. import Apis from '@/js/api.js'
  65. import SearchBar from '../../components/commons/SearchBar'
  66. import TechnologyCard from './TechnologyCard'
  67. import TechnologyMG from './TechnologyMG'
  68. import {storageGet} from '@/js/index.js'
  69. import {notify} from "../../constants";
  70. export default {
  71. name: 'TechnologyMore',
  72. components: {
  73. SearchBar,
  74. TechnologyCard,
  75. TechnologyMG,
  76. },
  77. data(){
  78. return {
  79. loading: false,
  80. isLogin: false,
  81. searchVal: '',
  82. searchType:'',
  83. searchTypeArr:[
  84. {
  85. "name": "技术文章",
  86. "value": "0",
  87. "label":'文章'
  88. }
  89. ],
  90. articleArr:[],
  91. keyword:"",
  92. activePage:1,
  93. techArticleList:{},
  94. }
  95. },
  96. methods:{
  97. loadData(){
  98. if (storageGet('user') != null) {
  99. this.isLogin = true;
  100. }
  101. },
  102. checkLogin() {
  103. this.checkCreateProjectAuth();
  104. },
  105. checkCreateProjectAuth() {
  106. if (!this.isLogin) {
  107. console.log("请登录后访问");
  108. notify('warning', '请登录后访问');
  109. } else if (this.isLogin) {
  110. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  111. this.$router.push('/project/create');
  112. }).catch((error) => {
  113. notify('error', error.data)
  114. })
  115. }
  116. },
  117. gotoHome(){
  118. this.$router.push('/home');
  119. },
  120. handleTypeClick(tab){
  121. this.handleTabClick(tab);
  122. },
  123. handleTabClick(tab){
  124. this.searchType = tab.name
  125. this.activePage = 1;
  126. this.searchVal = '';
  127. this.loadTechnologyArticles(1);
  128. },
  129. loadTechnologyArticles(index){
  130. this.activePage = index;
  131. let params = {
  132. "keyword": this.searchVal,//查询条件,分页展示时就不填
  133. "activePage": this.activePage,//指定页数
  134. "columnFilters": [
  135. {
  136. "field": "type",
  137. "type": "enums",
  138. "enums": this.searchTypeArr,
  139. "value": this.searchType//展示技术文章value为0
  140. }
  141. ]
  142. }
  143. Http.post(Apis.TECHNOLOGY.GET_MORE, params).then((res) => {
  144. console.log(res.data.technicalArticlesPage)
  145. if(res.data.technicalArticlesPage){
  146. this.techArticleList = res.data.technicalArticlesPage;
  147. this.searchType = '0';
  148. }
  149. else if(res.data.publicationsPage){
  150. this.techArticleList = res.data.publicationsPage;
  151. this.searchType = '1';
  152. }
  153. console.log(this.techArticleList)
  154. })
  155. },
  156. handlePageChange(index){
  157. this.activePage = index;
  158. this.loadTechnologyArticles(index);
  159. },
  160. setUserInfo() {
  161. this.user = storageGet('user') && storageGet('user').userVO;
  162. }
  163. },
  164. mounted() {
  165. this.loadData();
  166. this.setUserInfo();
  167. this.loadTechnologyArticles(1);
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. @import "../../style/search-nav.scss";
  173. .technology-container {
  174. /deep/ .search-input,/deep/ .releaseBtn{
  175. margin: 20px 0 0 0 !important;
  176. }
  177. .popular-modules {
  178. padding-left: 15px;
  179. }
  180. }
  181. </style>