-
-
- {{item.username}}
-
-
-
-
{{item.username}}
-
评分:
-
-
-
+
+
{{ commentNum }} 条精选评论
+
+
+
+
+
+
+
+ 最新
+
+
+
+ {{item.username}}
+
+
+
+ {{item.username}}
+ 评分:
+
+
+
没用过
用过
-
-
-
- {{item.content}}
-
+
+
+
+ {{item.content}}
+
+
+
+
{{item.commentTime}}
+
+ {{ formatNumber(item.likeNum) }}
+ 点赞
+
+
+
+
+
-
-
{{item.time}}
+
+
+ 最热
+
+
+
+ {{item.username}}
+
+
+
+ {{item.username}}
+ 评分:
+
+
+
+
+ 没用过
+ 用过
+
+
+
+
+ {{item.content}}
+
+
+
+
+
{{item.commentTime}}
+
+ {{ formatNumber(item.likeNum) }}
+ 点赞
+
+
+
+
+
-
-
+
+
+
+
@@ -247,6 +299,7 @@ export default {
starValue:null,
activeNames: ['1'],
activeName:'first',
+ activeCommentName:'last',
loginDialogVisible:false,
editorOption: {
theme: 'bubble',
@@ -283,12 +336,19 @@ export default {
new OrderedList(),
],
isRouterAlive:true,
+ isDisabled:false,
+ isDisabled2:false,
+ Like:null,
+ checked:false,
+ tabCheckedLast:true,
+ tabCheckedHot:false,
+
}
},
mounted() {
this.getProjectDetail();
- this.getComment();
-
+ this.getLastComment();
+ this.isStart();
},
watch: {
$route () {
@@ -328,24 +388,32 @@ export default {
},
reload() {
this.isRouterAlive = false;
- this.$nextTick(function () {
+ this.$nextTick( ()=> {
this.isRouterAlive = true;
});
},
- getComment(){
+ getComment(tab){
var that=this;
axios({
method: 'post',
// 请求的地址
- url: 'http://localhost:8082/helloGithub_war_exploded/selectCommentByPro',
+ url: 'http://localhost:8082/helloGithub_war_exploded/selectCommentBy',
// URL 中的查询参数
params: {
- id:this.$route.query.id
+ id:this.$route.query.id,
+ trait:tab.name
}
}).then(function (res) {
that.commentContent=res.data;
that.commentNum=Object.keys(that.commentContent).length;
+ if(tab.name==='last'){
+ that.tabCheckedLast=true;
+ that.tabCheckedHot=false;
+ }else if(tab.name==='hot'){
+ that.tabCheckedHot=true;
+ that.tabCheckedLast=false;
+ }
});
},
publishComment(){
@@ -370,7 +438,7 @@ export default {
type: 'success',
offset: 50
});
- that.getComment();
+ that.getLastComment();
that.reload();
} else {
Vue.prototype.$notify.error({
@@ -390,6 +458,141 @@ export default {
},
+ formatNumber(num) {
+ return num >= 1e3 && num < 1e4 ? (num / 1e3).toFixed(1) + 'k' : num >= 1e4 ? (num / 1e4).toFixed(1) + 'w' : num
+ },
+
+ addLike(id){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/addLike',
+ // URL 中的查询参数
+ params: {
+ id:id
+ }
+ }).then((res)=>{
+ if(res.data.code===500){
+ Vue.prototype.$notify.error({
+ title: '错误',
+ message: res.data.msg,
+ offset: 50
+ });
+ return;
+ }else{
+ if(!that.tabCheckedLast){
+ that.getHotComment();
+ }else{
+ that.getLastComment();
+ }
+ }
+ })
+ },
+ getHotComment(){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/selectCommentBy',
+ // URL 中的查询参数
+ params: {
+ id:this.$route.query.id,
+ trait:'hot'
+ }
+ }).then(function (res) {
+ that.commentContent=res.data;
+ });
+ },
+ getLastComment(){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/selectCommentBy',
+ // URL 中的查询参数
+ params: {
+ id:this.$route.query.id,
+ trait:'last'
+ }
+ }).then(function (res) {
+ that.commentContent=res.data;
+ that.commentNum=Object.keys(that.commentContent).length;
+
+ });
+ },
+ isStart(){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/whetherLike',
+ // URL 中的查询参数
+ params: {
+ proId:this.$route.query.id,
+
+ }
+ }).then(function (res) {
+ that.Like=res.data;
+ });
+ },
+ addStar(){
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/whetherAddLike',
+ // URL 中的查询参数
+ params: {
+ proId:this.$route.query.id,
+ }
+ }).then((res)=>{
+ if (res.data.code === 500) {
+ Vue.prototype.$notify.error({
+ title: '错误',
+ message: res.data.msg,
+ offset: 50
+ });
+ } else {
+ this.isStart();
+ this.$router.push({
+ path:'/ProjectDetail',
+ query: {
+ id: this.projectId, refresh: true
+ }
+ })
+ }
+ })
+ },
+ cancleStar(){
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/whetherCancelLike',
+ // URL 中的查询参数
+ params: {
+ proId:this.$route.query.id,
+ }
+ }).then((res)=>{
+ if (res.data.code === 500) {
+ Vue.prototype.$notify.error({
+ title: '错误',
+ message: res.data.msg,
+ offset: 50
+ });
+ } else {
+ this.isStart();
+ // window.location.reload()
+ this.$router.push({
+ path:'/ProjectDetail',
+ query: {
+ id: this.projectId, refresh: true
+ }
+ })
+ }
+ })
+ }
+
+
}
@@ -430,4 +633,7 @@ export default {
padding: 8px;
display: none;
}
+::v-deep .el-card__header{
+ border-bottom: none;
+}
\ No newline at end of file
diff --git a/src/components/Ranking.vue b/src/components/Ranking/Ranking.vue
similarity index 96%
rename from src/components/Ranking.vue
rename to src/components/Ranking/Ranking.vue
index 4f2626a..efad09c 100644
--- a/src/components/Ranking.vue
+++ b/src/components/Ranking/Ranking.vue
@@ -47,13 +47,17 @@