对接论文评价接口

master
pan 4 years ago
parent 6fb923b8a1
commit f342e408b8
  1. 2
      nuxt.config.js
  2. 43
      pages/index/read.vue

@ -212,6 +212,7 @@ export default {
"rating_1": "本文对您的科研工作是否有帮助", "rating_1": "本文对您的科研工作是否有帮助",
"rating_2": "本文的内容是否科学严谨", "rating_2": "本文的内容是否科学严谨",
"rating_3": "您对本文的推荐程度", "rating_3": "您对本文的推荐程度",
"rating_ok": "评价成功",
"search_next": "查找下一个", "search_next": "查找下一个",
"search_prev": "查找上一个", "search_prev": "查找上一个",
"search_zero": "正文中没有 ‘{keyword}’" "search_zero": "正文中没有 ‘{keyword}’"
@ -373,6 +374,7 @@ export default {
"rating_1": "", "rating_1": "",
"rating_2": "", "rating_2": "",
"rating_3": "", "rating_3": "",
"rating_ok": "",
"search_next": "", "search_next": "",
"search_prev": "", "search_prev": "",
"search_zero": "" "search_zero": ""

@ -178,8 +178,8 @@
disabled: true, disabled: true,
// //
replace: {}, replace: {},
stars: [{ value: 0 }, { value: 0 }, { value: 0 }], stars: [],
show_star_button: true show_star_button: false
} }
}, },
computed: { computed: {
@ -228,6 +228,22 @@
}, },
methods: { 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) { scrollContent(e) {
this.$store.commit('read/scroll', e.target.scrollTop) this.$store.commit('read/scroll', e.target.scrollTop)
@ -366,6 +382,20 @@
// //
submitRating() { submitRating() {
console.info(this.stars) 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) { highlighting(item: any) {
@ -493,9 +523,16 @@
} }
}, },
mounted() { mounted() {
let that = this
this.$nextTick(() => {
if(this.activeContent) {
that.queryRating()
}
})
this.activeName = this.$store.state.read.activeName this.activeName = this.$store.state.read.activeName
let that = this
addEventListener('keyup', function(event) { addEventListener('keyup', function(event) {
// //
if (event.shiftKey && 'F' === event.key.toUpperCase()) { if (event.shiftKey && 'F' === event.key.toUpperCase()) {

Loading…
Cancel
Save