diff --git a/nuxt.config.js b/nuxt.config.js index 0e3440b..cee2a00 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -212,6 +212,7 @@ export default { "rating_1": "本文对您的科研工作是否有帮助", "rating_2": "本文的内容是否科学严谨", "rating_3": "您对本文的推荐程度", + "rating_ok": "评价成功", "search_next": "查找下一个", "search_prev": "查找上一个", "search_zero": "正文中没有 ‘{keyword}’" @@ -373,6 +374,7 @@ export default { "rating_1": "", "rating_2": "", "rating_3": "", + "rating_ok": "", "search_next": "", "search_prev": "", "search_zero": "" diff --git a/pages/index/read.vue b/pages/index/read.vue index 6454029..2f1f088 100644 --- a/pages/index/read.vue +++ b/pages/index/read.vue @@ -178,8 +178,8 @@ disabled: true, //替换目标 replace: {}, - stars: [{ value: 0 }, { value: 0 }, { value: 0 }], - show_star_button: true + stars: [], + show_star_button: false } }, computed: { @@ -228,6 +228,22 @@ }, methods: { + //查找评价记录 + queryRating(){ + let that=this + this.GLOBAL.fetchGet('/v1/api/paper/findRating', { paperId:this.activeContent.id },function(res) { + if(res.code==='200'){ + if(res.data===null){ + that.stars=[{ value: 0 }, { value: 0 }, { value: 0 }] + }else{ + that.stars=[{ value: res.data.score1 }, { value: res.data.score2 }, { value: res.data.score3 }] + } + that.show_star_button=res.data===null + }else{ + that.$message.error(that.$t('error_500').toString()) + } + }) + }, //滚动正文 scrollContent(e) { this.$store.commit('read/scroll', e.target.scrollTop) @@ -366,6 +382,20 @@ //提交评分 submitRating() { console.info(this.stars) + let that=this + this.GLOBAL.fetchJSON('/v1/api/paper/rating','POST',{ + paperId:this.activeContent.id, + score1:this.stars[0].value, + score2:this.stars[1].value, + score3:this.stars[2].value, + },function(res) { + if(res.code==='200'){ + that.queryRating() + that.$message.info(that.$t('read.tip.rating_ok').toString()) + }else{ + that.$message.error(that.$t('error_500').toString()) + } + }) }, //高亮笔记 highlighting(item: any) { @@ -493,9 +523,16 @@ } }, mounted() { + let that = this + this.$nextTick(() => { + if(this.activeContent) { + that.queryRating() + } + }) + this.activeName = this.$store.state.read.activeName - let that = this + addEventListener('keyup', function(event) { //监听查找操作 if (event.shiftKey && 'F' === event.key.toUpperCase()) {