TechnologyMore.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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="logo_transparent" />
  9. <span class="logo-title">{{logoTitle}}</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. import {CONFIG} from "../../config";
  71. export default {
  72. name: 'TechnologyMore',
  73. components: {
  74. SearchBar,
  75. TechnologyCard,
  76. TechnologyMG,
  77. },
  78. data(){
  79. return {
  80. logoTitle:CONFIG.logoTitle,
  81. logo_transparent:CONFIG.logo_transparent,
  82. loading: false,
  83. isLogin: false,
  84. searchVal: '',
  85. searchType:'',
  86. searchTypeArr:[
  87. {
  88. "name": "技术文章",
  89. "value": "0",
  90. "label":'文章'
  91. }
  92. ],
  93. articleArr:[],
  94. keyword:"",
  95. activePage:1,
  96. techArticleList:{},
  97. }
  98. },
  99. methods:{
  100. loadData(){
  101. if (storageGet('user') != null) {
  102. this.isLogin = true;
  103. }
  104. },
  105. checkLogin() {
  106. this.checkCreateProjectAuth();
  107. },
  108. checkCreateProjectAuth() {
  109. if (!this.isLogin) {
  110. console.log("请登录后访问");
  111. notify('warning', '请登录后访问');
  112. } else if (this.isLogin) {
  113. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  114. this.$router.push('/project/create');
  115. }).catch((error) => {
  116. notify('error', error.data)
  117. })
  118. }
  119. },
  120. gotoHome(){
  121. this.$router.push('/home');
  122. },
  123. handleTypeClick(tab){
  124. this.handleTabClick(tab);
  125. },
  126. handleTabClick(tab){
  127. this.searchType = tab.name
  128. this.activePage = 1;
  129. this.searchVal = '';
  130. this.loadTechnologyArticles(1);
  131. },
  132. loadTechnologyArticles(index){
  133. this.activePage = index;
  134. let params = {
  135. "keyword": this.searchVal,//查询条件,分页展示时就不填
  136. "activePage": this.activePage,//指定页数
  137. "columnFilters": [
  138. {
  139. "field": "type",
  140. "type": "enums",
  141. "enums": this.searchTypeArr,
  142. "value": this.searchType//展示技术文章value为0
  143. }
  144. ]
  145. }
  146. Http.post(Apis.TECHNOLOGY.GET_MORE, params).then((res) => {
  147. console.log(res.data.technicalArticlesPage)
  148. if(res.data.technicalArticlesPage){
  149. this.techArticleList = res.data.technicalArticlesPage;
  150. this.searchType = '0';
  151. }
  152. else if(res.data.publicationsPage){
  153. this.techArticleList = res.data.publicationsPage;
  154. this.searchType = '1';
  155. }
  156. console.log(this.techArticleList)
  157. })
  158. },
  159. handlePageChange(index){
  160. this.activePage = index;
  161. this.loadTechnologyArticles(index);
  162. },
  163. setUserInfo() {
  164. this.user = storageGet('user') && storageGet('user').userVO;
  165. }
  166. },
  167. mounted() {
  168. this.loadData();
  169. this.setUserInfo();
  170. this.loadTechnologyArticles(1);
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. @import "../../style/search-nav.scss";
  176. .technology-container {
  177. /deep/ .search-input,/deep/ .releaseBtn{
  178. margin: 20px 0 0 0 !important;
  179. }
  180. .popular-modules {
  181. padding-left: 15px;
  182. }
  183. }
  184. </style>