更新推荐接口

master
pan 4 years ago
parent d900487db2
commit d9e79c2c78
  1. 1
      nuxt.config.js
  2. 35
      pages/index/document.vue
  3. 42
      plugins/global.js

@ -1,5 +1,6 @@
export default {
server: {
host: '127.0.0.1',
port: 5000,
},
/*

@ -43,6 +43,10 @@
</el-form-item>
</el-collapse>
</el-form>
<el-pagination
layout="prev, pager, next"
:total="total" class="center mt1" @current-change="query">
</el-pagination>
<el-row class="mt3">
<el-col :span="18">
<template v-if="docList.length===0">
@ -60,7 +64,7 @@
<el-col :span="16" class="doc-title"><span>{{item.title}}</span></el-col>
</el-row>
<el-row type="flex" align="middle" class="center mt1">
<el-col :span="2"><span>[{{item.type}}]</span></el-col>
<el-col :span="2"><span>{{item.type}}</span></el-col>
<el-col :span="1"><span>{{item.author}}</span></el-col>
<el-col :span="3"><span>{{item.profession}}</span></el-col>
<el-col :span="3"><span>{{item.school}}&nbsp{{item.year}}</span></el-col>
@ -106,10 +110,10 @@
</template>
<script lang="ts">
import Vue from 'vue'
import { Loading } from 'element-ui'
import Vue from 'vue'
import { Loading } from 'element-ui'
export default Vue.extend({
export default Vue.extend({
name: 'document',
data() {
return {
@ -128,14 +132,15 @@
activeNames: [],
docList: [],
recommend_list: [],
total:1
total:0,
currentPage:1
}
},
methods: {
read(item){
this.$read(item)
},
query(){
query(page=1){
let that=this
let loadingInstance =Loading.service({});
this.GLOBAL.fetchGet('/v1/api/paper/list', {
@ -144,11 +149,14 @@
tag: this.form.tag,
profession: this.form.profession,
startYear: this.form.start_year,
endYear: this.form.end_year
endYear: this.form.end_year,
page:page
}, function(res) {
if(res.code==='200'){
that.docList=res.data.data
that.total=res.data.total
that.docList=res.data.content
that.total=res.data.totalElements
that.currentPage=page
// console.info(that.total)
}else{
that.$message.error(that.$t('error_500').toString())
}
@ -158,7 +166,11 @@
recommend(){
let that=this
this.GLOBAL.fetchGet('/v1/api/paper/recommend',{},function(res) {
that.recommend_list=res.data
if(res.data) {
that.recommend_list = res.data
}else{
console.warn(res.msg)
}
})
}
},
@ -183,7 +195,8 @@
}
.recommend-list {
overflow-y: scroll;
height: 800px;
overflow-y: auto;
}
a{

@ -29,7 +29,7 @@ Vue.prototype.GLOBAL ={
})
},
//发送get请求
fetchGet(url,params,success){
fetchGet(url,params,success,json=true){
if (params) {
let paramsArray = [];
//拼接参数
@ -40,12 +40,20 @@ Vue.prototype.GLOBAL ={
url += '&' + paramsArray.join('&')
}
}
fetch(this.server_address + url, {
method:'GET',
credentials: "include"
}).then(res=>res.json()).then(res=>success(res)).catch(err=>{
console.error(err)
})
if(json) {
fetch(this.server_address + url, {
method: 'GET',
credentials: "include"
}).then(res => res.json()).then(res => success(res)).catch(err => {
console.error(err)
})
}else{
fetch(this.server_address + url, {
method: 'GET',
credentials: "include"
}).then(res=>res.text()).then(res=>success(res))
}
},
@ -54,20 +62,12 @@ Vue.prototype.GLOBAL ={
Vue.prototype.$read= function(item) {
let loadingInstance =Loading.service({});
let that=this
this.GLOBAL.fetchGet("/v1/api/file/find",{
paperId:item.id,
fileId:item.fileId
},function(res) {
if(res.code==='200'){
item.content=res.msg
that.$store.commit('menus/read')
that.$store.commit('read/open', item)
that.$router.push(that.localePath('/read'))
loadingInstance.close()
}else{
that.$message.error(that.$t('error_500').toString())
}
this.GLOBAL.fetchGet(`/v1/api/paper/content/${item.id}`,{},function(res) {
item.content=res
that.$store.commit('menus/read')
that.$store.commit('read/open', item)
that.$router.push(that.localePath('/read'))
loadingInstance.close()
})
},false)
}

Loading…
Cancel
Save