Bläddra i källkod

feat: 列表部分(todo: 发布者、列表联系方式优化)

icenaked 3 år sedan
förälder
incheckning
d8a273c598

+ 5 - 2
src/api/communication.js

@@ -10,11 +10,14 @@ function getAllCommunications(payload) {
 }
 }
 
 
 function getCommunicationStarers(communicationId) {
 function getCommunicationStarers(communicationId) {
-    return axios.get(`https://www.fastmock.site/mock/7626b3aeb545b939cbf526e8fcfda744/api/communications/${communicationId}/stars/users`);
+    // return axios.get(`https://www.fastmock.site/mock/7626b3aeb545b939cbf526e8fcfda744/api/communications/${communicationId}/stars/users`);
+    return axios.get(`${prefix}/${communicationId}/stars/users`);
 }
 }
 
 
 function getCommunicationDetail(communicationId) {
 function getCommunicationDetail(communicationId) {
-    return axios.get(`https://www.fastmock.site/mock/7626b3aeb545b939cbf526e8fcfda744/api/communications/${communicationId}`);
+    // return axios.get(`https://www.fastmock.site/mock/7626b3aeb545b939cbf526e8fcfda744/api/communications/${communicationId}`);
+    return axios.get(`${prefix}/${communicationId}`);
+
 }
 }
 
 
 function getUserPublishCommunication(userId,page,size){
 function getUserPublishCommunication(userId,page,size){

+ 11 - 4
src/views/CommunicationPage/CommunicationDetail.vue

@@ -13,7 +13,7 @@
             <div class="course-info-main">
             <div class="course-info-main">
               <el-row>发布作者: {{ communicationInfo.publisherName }}</el-row>
               <el-row>发布作者: {{ communicationInfo.publisherName }}</el-row>
               <el-row>所属组织: {{ communicationInfo.organization }}</el-row>
               <el-row>所属组织: {{ communicationInfo.organization }}</el-row>
-              <el-row>持续时间: {{ communicationInfo.publishTime }}~{{ communicationInfo.deadline }}</el-row>
+              <el-row>持续时间: {{ publishTime }}~{{ deadline }}</el-row>
             </div>
             </div>
             <div class="explore-item-star" >
             <div class="explore-item-star" >
               <el-tooltip placement="top-start" effect="light">
               <el-tooltip placement="top-start" effect="light">
@@ -78,6 +78,8 @@ export default {
       attachments: [],
       attachments: [],
       starersList: [],
       starersList: [],
       starersListString: "",
       starersListString: "",
+      publishTime: "",
+      deadline: ""
     };
     };
   },
   },
   async mounted() {
   async mounted() {
@@ -85,12 +87,17 @@ export default {
   },
   },
   methods: {
   methods: {
     fetchData(){
     fetchData(){
-      this.$apis.getCommunicationDetail(this.$route.params.id).then(res=>{
+      this.$apis.getCommunicationDetail(this.$route.params.communicationId).then(res=>{
         this.communicationInfo = res.data.data;
         this.communicationInfo = res.data.data;
-        this.communicationInfo.img = this.communicationInfo.photos[0].fileUrl;
+        if (this.communicationInfo.photos.length != 0){
+          this.communicationInfo.img = this.communicationInfo.photos[0].fileUrl;
+        }
+        else this.communicationInfo.img = this.$variables.noImgUrl;
         this.attachments = this.communicationInfo.attachments;
         this.attachments = this.communicationInfo.attachments;
+        this.publishTime = this.communicationInfo.publishTime.substring(0,9) + " " + this.communicationInfo.publishTime.substring(11,19);
+        this.deadline = this.communicationInfo.deadline.substring(0,9) + " " + this.communicationInfo.deadline.substring(11,19);
       });
       });
-      this.$apis.getCommunicationStarers(this.$route.params.id).then(starRes=>{
+      this.$apis.getCommunicationStarers(this.$route.params.communicationId).then(starRes=>{
             this.starersList = starRes.data.data;
             this.starersList = starRes.data.data;
             this.starersListString = "";
             this.starersListString = "";
             this.starersList.forEach(starer=>{
             this.starersList.forEach(starer=>{

+ 2 - 3
src/views/CommunicationPage/ExplorePage.vue

@@ -87,9 +87,8 @@ export default {
         sort: this.sort
         sort: this.sort
       };
       };
       this.$apis.getAllCommunications(payload).then(res=>{
       this.$apis.getAllCommunications(payload).then(res=>{
-        console.log(res.data);
         this.communicationList = res.data.data.content;
         this.communicationList = res.data.data.content;
-        this.total = this.communicationList.length;
+        this.total = res.data.data.totalElements;
       });
       });
     },
     },
     handleCheckAllChange(val) {
     handleCheckAllChange(val) {
@@ -102,7 +101,7 @@ export default {
       this.isIndeterminate = checkedCount > 0 && checkedCount < this.types.length;
       this.isIndeterminate = checkedCount > 0 && checkedCount < this.types.length;
     },
     },
     pageChange(currentPage){
     pageChange(currentPage){
-      this.page = currentPage;
+      this.page = currentPage - 1;
       this.fetchData();
       this.fetchData();
     },
     },
     sortChange(){
     sortChange(){

+ 9 - 9
src/views/CommunicationPage/components/ExploreItem.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-    <el-card class="explore-item" shadow="never" @click="this.$router.push('/communication/communicationDetail/' + this.communicationVO.id)">
+    <el-card class="explore-item" shadow="never">
 
 
         <div class="explore-item-star" >
         <div class="explore-item-star" >
           <el-tooltip placement="top-start" effect="light">
           <el-tooltip placement="top-start" effect="light">
@@ -7,20 +7,19 @@
               <p style="max-width:500px;">{{starersListString}}收藏了本交流</p>
               <p style="max-width:500px;">{{starersListString}}收藏了本交流</p>
             </template>
             </template>
             <div>
             <div>
-              <el-icon v-if="starred===true" style="font-size: 20px" @click="star()"><Star /></el-icon>
-              <el-icon v-if="starred===false" style="font-size: 20px;color: orange" @click="cancelStar()">
+              <el-icon v-if="starred===false" style="font-size: 20px" @click="star()"><Star /></el-icon>
+              <el-icon v-if="starred===true" style="font-size: 20px;color: orange" @click="cancelStar()">
                 <StarFilled />
                 <StarFilled />
               </el-icon>
               </el-icon>
             </div>
             </div>
           </el-tooltip>
           </el-tooltip>
         </div>
         </div>
 
 
-        <div class="explore-item-description">
+        <div class="explore-item-description"  @click="this.$router.push('/communication/communicationDetail/' + this.communicationVO.id)">
             <h1 class="description-title">{{ title}}</h1>
             <h1 class="description-title">{{ title}}</h1>
             <div style="font-size: 14px;margin-top: 5px">
             <div style="font-size: 14px;margin-top: 5px">
-                <span style="color: var(--el-color-danger)" v-if="type==='puzzle'">难题</span>
-              <span style="color: var(--el-color-success)" v-if="type==='event'">活动</span>
-              <span style="color: var(--el-color-primary)" v-if="type==='other'">其他</span>
+              <span style="color: var(--el-color-danger)" v-if="type==='PROBLEM'">难题</span>
+              <span style="color: var(--el-color-success)" v-if="type==='NOTICE'">通知</span>
                 <span style="margin-left: 14px">{{ publisherName }}</span>
                 <span style="margin-left: 14px">{{ publisherName }}</span>
                 <span style="margin-left: 14px">{{ organization }}</span>
                 <span style="margin-left: 14px">{{ organization }}</span>
                 <span style="margin-left: 14px">{{ email }}</span>
                 <span style="margin-left: 14px">{{ email }}</span>
@@ -71,10 +70,10 @@ export default {
       return this.communicationVO.photos === null ? this.$variables.noImgUrl : this.communicationVO.photos;
       return this.communicationVO.photos === null ? this.$variables.noImgUrl : this.communicationVO.photos;
     },
     },
     publishTime(){
     publishTime(){
-      return this.communicationVO.publishTime;
+      return this.communicationVO.publishTime.substring(0,9);
     },
     },
     deadline(){
     deadline(){
-      return this.communicationVO.deadline;
+      return this.communicationVO.deadline.substring(0,9);
     },
     },
     starred: {
     starred: {
       get(){
       get(){
@@ -111,6 +110,7 @@ export default {
   },
   },
   mounted() {
   mounted() {
     this.fetchData();
     this.fetchData();
+    console.log(this.communicationVO.starred);
   }
   }
 };
 };
 </script>
 </script>