CompetitionList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="home-wrapper">
  3. <!-- <TopSearch :searchVal="searchVal" :searchType="searchType" :searchTypeArr="searchTypeArr"/>-->
  4. <div class="nav" stype="height:500px">
  5. <!--搜索框-->
  6. <el-row class="search-nav" style="padding: 30px 0 20px 0">
  7. <el-col :span="6">
  8. <div class="pull-left" @click="gotoHome" style="cursor: pointer">
  9. <img class="logo-img" src="../../assets/img/logo-blue.png"/>
  10. <span class="logo-title">群智众测平台</span>
  11. </div>
  12. </el-col>
  13. <el-col :span="12">
  14. <div class="search-nav">
  15. <div id="search-block ">
  16. <el-tabs v-model="searchType" type="card" @tab-click="handleTypeClick">
  17. <el-tab-pane v-for="item in searchTypeArr" v-if="item.value!=='all'" :label="item.name"
  18. :name="item.value"
  19. :key="item.value"></el-tab-pane>
  20. </el-tabs>
  21. <div class="search-input">
  22. <el-input placeholder="请输入内容" v-model="searchVal" class="input-with-select">
  23. <el-button class="search-button" slot="append" type="primary" @click="handleSearchData">搜索</el-button>
  24. </el-input>
  25. </div>
  26. </div>
  27. </div>
  28. </el-col>
  29. <el-col :span="6">
  30. <el-button type="primary pull-right" class="releaseBtn" @click="checkLogin()">免费发布众测需求</el-button>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. <div class="container" style="margin: 20px auto;" v-loading="loading">
  35. <div class="create-body">
  36. <div class="title h2">众测大赛</div>
  37. <el-collapse accordion style="margin: 0 30px">
  38. <template style="color: black">
  39. <el-table
  40. ref="multipleTable"
  41. :data="curCompetitionList"
  42. tooltip-effect="dark"
  43. style="width: 100%; font-size: 20px; color: black">
  44. <el-table-column
  45. label="图标"
  46. width="100">
  47. <template slot-scope="scope"><img :src="scope.row.image==null?defaultValue.image:scope.row.image"
  48. style="width: 50px; height: 50px;"/></template>
  49. </el-table-column>
  50. <el-table-column
  51. label="名称"
  52. align="left"
  53. width="500">
  54. <template slot-scope="scope"><a target="_blank" :href="scope.row.linkUrl"
  55. itemscope>{{scope.row.name}}</a></template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="unit"
  59. align="left"
  60. label="单位">
  61. </el-table-column>
  62. <el-table-column
  63. align="left"
  64. label="时间">
  65. <template slot-scope="scope">{{$moment(scope.row.startTime).format("YYYY-MM-DD HH:mm:ss")}}</template>
  66. </el-table-column>
  67. </el-table>
  68. </template>
  69. <el-pagination
  70. v-if="curCompetitionList&&curCompetitionList.length"
  71. :page-size="9"
  72. layout="prev, pager, next"
  73. :total="totalElements"
  74. :current-page="activePage"
  75. @current-change="handlePageChange"
  76. class="pull-right"
  77. >
  78. </el-pagination>
  79. </el-collapse>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import Http from '@/js/http.js';
  86. import TopSearch from "../../components/commons/TopSearch";
  87. import {storageGet, defaultValue} from '@/js/index.js'
  88. import {notify} from "../../constants";
  89. import Apis from '@/js/api';
  90. export default {
  91. name: "CompetitionList",
  92. props: ['searchVal', 'competitionList'],
  93. components: {TopSearch},
  94. data() {
  95. return {
  96. user: {},
  97. isLogin: false,
  98. loading: false,
  99. // searchVal: '',
  100. searchType: '0',
  101. defaultValue: defaultValue,
  102. searchTypeArr: [
  103. {
  104. "name": "大赛",
  105. "value": "0"
  106. }],
  107. curCompetitionList: this.competitionList,
  108. activePage: 1,
  109. totalElements: 0
  110. }
  111. },
  112. methods: {
  113. loadData() {
  114. if (storageGet('user') != null) {
  115. this.isLogin = true;
  116. }
  117. let url = '/api/common/index/competition';
  118. let params = {
  119. "keyword": this.searchVal,
  120. "activePage": this.activePage,
  121. "columnFilters": [
  122. {
  123. "field": "type",
  124. "type": "enums",
  125. "enums": this.searchTypeArr,
  126. "value": this.searchType
  127. }
  128. ]
  129. }
  130. Http.post(url, params).then((res) => {
  131. this.curCompetitionList = res.data.content;
  132. this.totalElements = res.data.totalElements;
  133. })
  134. },
  135. checkLogin() {
  136. this.checkCreateProjectAuth();
  137. },
  138. showLoading() {
  139. this.loading = true
  140. },
  141. hideLoading() {
  142. this.loading = false
  143. },
  144. checkCreateProjectAuth() {
  145. if (!this.isLogin) {
  146. console.log("请登录后访问");
  147. notify('warning', '请登录后访问');
  148. } else if (this.isLogin) {
  149. Http.get(Apis.USER.IS_PART.replace('{userId}', this.user.id)).then((res) => {
  150. this.$router.push('/project/create');
  151. }).catch((error) => {
  152. notify('error', error.data)
  153. })
  154. }
  155. },
  156. handleSearchData() {
  157. let url = '/api/common/index/competition';
  158. let params = {
  159. "keyword": this.searchVal,
  160. "activePage": this.activePage,
  161. "columnFilters": [
  162. {
  163. "field": "type",
  164. "type": "enums",
  165. "enums": this.searchTypeArr,
  166. "value": this.searchType
  167. }
  168. ]
  169. }
  170. Http.post(url, params).then((res) => {
  171. this.curCompetitionList = res.data.content;
  172. })
  173. },
  174. gotoHome() {
  175. this.$router.push('/home');
  176. },
  177. handleTypeClick(tab) {
  178. this.searchType = tab.name
  179. },
  180. handlePageChange(index) {
  181. this.activePage = index;
  182. this.handleSearchData();
  183. },
  184. setUserInfo() {
  185. this.user = storageGet('user') && storageGet('user').userVO;
  186. }
  187. },
  188. mounted() {
  189. this.setUserInfo();
  190. this.loadData();
  191. }
  192. }
  193. </script>
  194. <style lang="less">
  195. @import "../../style/search-nav";
  196. .item-template {
  197. height: 80px;
  198. }
  199. </style>