更新推荐接口

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 { export default {
server: { server: {
host: '127.0.0.1',
port: 5000, port: 5000,
}, },
/* /*

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

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

Loading…
Cancel
Save