Browse Source

0830

master
xuhuajiao 1 year ago
parent
commit
f9044bcaea
  1. 28
      .env.development
  2. 192
      src/api/bookshelf.js
  3. 105
      src/utils/request.js
  4. 3
      src/views/digitalResource.vue
  5. 8
      src/views/index.vue
  6. 201
      src/views/mixins/booklist.js
  7. 2
      src/views/module/bookList.vue

28
.env.development

@ -1,14 +1,14 @@
ENV = 'development'
# 接口地址
#内网服务地址
#VUE_APP_BASE_API = 'http://120.76.47.59:8080'
#VUE_APP_WS_API = 'ws://120.76.47.59:8080'
# 许镇-本地服地址
VUE_APP_BASE_API = 'http://192.168.99.84:8080'
VUE_APP_WS_API = 'ws://192.168.99.84:8080'
# 是否启用 babel-plugin-dynamic-import-node插件
VUE_CLI_BABEL_TRANSPILE_MODULES = true
ENV = 'development'
# 接口地址
#内网服务地址
#VUE_APP_BASE_API = 'http://120.76.47.59:8080'
#VUE_APP_WS_API = 'ws://120.76.47.59:8080'
# 许镇-本地服地址
VUE_APP_BASE_API = 'http://192.168.99.67:8080'
VUE_APP_WS_API = 'ws://192.168.99.67:8081'
# 是否启用 babel-plugin-dynamic-import-node插件
VUE_CLI_BABEL_TRANSPILE_MODULES = true

192
src/api/bookshelf.js

@ -1,96 +1,96 @@
import request from '@/utils/request'
// import qs from 'qs'
// 数字资源
export function initNumberResoures(params) {
return request({
url: '/dxhtsg/initNumberResoures',
method: 'get',
params: params
})
}
// 新书推荐
export function FetchNewBookRecommend(params) {
return request({
url: '/dxhtsg/newBookRecommend',
method: 'get',
params: params
})
}
// 热门图书
export function FetchHotBookRecommend(params) {
return request({
url: '/dxhtsg/hotBookRecommend',
method: 'get',
params: params
})
}
// 通过isbn获取图书封面
export function FetchCoverByISBN(params) {
return request({
url: '/dxhtsg/getCoverByISBN',
method: 'get',
params: params,
responseType: 'blob'
})
}
// 图书详情
export function getBookDetailsByISBN(params) {
return request({
url: '/dxhtsg/getBookDetailsByISBN',
method: 'get',
params: params
})
}
// 获取首页书架基本信息
export function initSmartBookshelf(params) {
return request({
url: '/dxhtsg/initSmartBookshelf',
method: 'get',
params
})
}
// 智能书架-书架详情
export function FetchInitBookshelfDetails(params) {
return request({
url: '/dxhtsg/initBookshelfDetails',
method: 'get',
params
})
}
// 作者推荐
export function FetchProposeAuthor(params) {
return request({
url: '/dxhtsg/proposeAuthor',
method: 'get',
params: params
})
}
// 作者推荐
export function initBookshelfDetails(params) {
return request({
url: '/dxhtsg/initBookshelfDetails',
method: 'get',
params
})
}
export default {
FetchNewBookRecommend,
FetchCoverByISBN,
initNumberResoures,
getBookDetailsByISBN,
initSmartBookshelf,
FetchInitBookshelfDetails,
FetchHotBookRecommend,
FetchProposeAuthor,
initBookshelfDetails
}
import request from '@/utils/request'
// import qs from 'qs'
// 数字资源
export function initNumberResoures(params) {
return request({
url: '/dxhtsg/initNumberResoures',
method: 'get',
params: params
})
}
// 新书推荐
export function FetchNewBookRecommend(params) {
return request({
url: '/dxhtsg/newBookRecommend',
method: 'get',
params: params
})
}
// 热门图书
export function FetchHotBookRecommend(params) {
return request({
url: '/dxhtsg/hotBookRecommend',
method: 'get',
params: params
})
}
// 通过isbn获取图书封面
export function FetchCoverByISBN(params) {
return request({
url: '/dxhtsg/getCoverByISBN',
method: 'get',
params: params
// responseType: 'blob'
})
}
// 图书详情
export function getBookDetailsByISBN(params) {
return request({
url: '/dxhtsg/getBookDetailsByISBN',
method: 'get',
params: params
})
}
// 获取首页书架基本信息
export function initSmartBookshelf(params) {
return request({
url: '/dxhtsg/initSmartBookshelf',
method: 'get',
params
})
}
// 智能书架-书架详情
export function FetchInitBookshelfDetails(params) {
return request({
url: '/dxhtsg/initBookshelfDetails',
method: 'get',
params
})
}
// 作者推荐
export function FetchProposeAuthor(params) {
return request({
url: '/dxhtsg/proposeAuthor',
method: 'get',
params: params
})
}
// 作者推荐
export function initBookshelfDetails(params) {
return request({
url: '/dxhtsg/initBookshelfDetails',
method: 'get',
params
})
}
export default {
FetchNewBookRecommend,
FetchCoverByISBN,
initNumberResoures,
getBookDetailsByISBN,
initSmartBookshelf,
FetchInitBookshelfDetails,
FetchHotBookRecommend,
FetchProposeAuthor,
initBookshelfDetails
}

105
src/utils/request.js

@ -1,52 +1,53 @@
import axios from 'axios'
import { Message } from 'element-ui'
// 创建axios实例
const service = axios.create({
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
timeout: 1000 * 30, // 请求超时时间
headers: {
'Content-Type': 'application/json'
}
})
// request拦截器
service.interceptors.request.use(
config => {
// if (getToken()) {
// config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
// }
const token = '' // 登录后生成用于识别用户身份,项目不需要直接去掉
config.headers['Authorization'] = token || ''
return config
},
error => {
console.error('error: ', error)
Promise.reject(error)
}
)
// response 拦截器
service.interceptors.response.use(
response => {
const errorMsg = response.data.errMsg
if (response.status === 200) {
// console.log(response.data.data)
if (response.data instanceof Blob) {
return response.data
} else {
return response.data.data
}
} else {
Message.error({
message: errorMsg,
duration: 5000
})
Promise.reject()
}
},
error => {
return Promise.reject(error)
}
)
export default service
import axios from 'axios'
import { Message } from 'element-ui'
// 创建axios实例
const service = axios.create({
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
timeout: 1000 * 30, // 请求超时时间
headers: {
'Content-Type': 'application/json'
}
})
// request拦截器
service.interceptors.request.use(
config => {
// if (getToken()) {
// config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
// }
const token = '' // 登录后生成用于识别用户身份,项目不需要直接去掉
config.headers['Authorization'] = token || ''
return config
},
error => {
console.error('error: ', error)
Promise.reject(error)
}
)
// response 拦截器
service.interceptors.response.use(
response => {
const errorMsg = response.data.errMsg
if (response.status === 200) {
if (response.data instanceof Blob) {
return response.data
} else if (response.data.data) {
return response.data.data
} else {
return response.data
}
} else {
Message.error({
message: errorMsg,
duration: 5000
})
Promise.reject()
}
},
error => {
return Promise.reject(error)
}
)
export default service

3
src/views/digitalResource.vue

@ -9,7 +9,7 @@
<div class="main"> <div class="main">
<div v-for="(item,index) in srcList" :key="index" class="main-item" @click="jump(item.nrsUrl)"> <div v-for="(item,index) in srcList" :key="index" class="main-item" @click="jump(item.nrsUrl)">
<img :src="'data:image/png;base64,' + item.nrsImages" /> <img :src="'data:image/png;base64,' + item.nrsImages" />
<div class="title">
<div class="title" :style="{ fontSize: item.nrsTitle.length >6 ? '60px' : '80px'}">
{{ item.nrsTitle }} {{ item.nrsTitle }}
</div> </div>
</div> </div>
@ -75,6 +75,7 @@ export default {
-webkit-line-clamp: 3; -webkit-line-clamp: 3;
line-clamp: 3; line-clamp: 3;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
text-align: center;
} }
} }
} }

8
src/views/index.vue

@ -130,8 +130,14 @@ export default {
const params = { const params = {
isbn: isbn isbn: isbn
} }
console.log(params)
FetchCoverByISBN(params).then((res) => { FetchCoverByISBN(params).then((res) => {
item.cover = window.URL.createObjectURL(res)
// item.cover = window.URL.createObjectURL(res)
if (res) {
item.cover = res
} else {
item.cover = ''
}
this.newList.push(item) this.newList.push(item)
}) })
}, },

201
src/views/mixins/booklist.js

@ -1,98 +1,103 @@
import { FetchHotBookRecommend, FetchNewBookRecommend, FetchCoverByISBN, getBookDetailsByISBN } from '@/api/bookshelf'
export const bookListCrud = {
// 组件共用属性
data() {
return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
bookData: [],
page: 1,
pageSize: 13,
pageCount: 1,
bookLoading: false
}
},
computed: {
bookList() {
const arr = this.bookData.slice(1)
return arr
}
},
// 组件共用方法
methods: {
// 获取热门/新书图书list
getBookData() {
this.bookLoading = true
const bookType = this.$route.query.bookType
const params = {
libcode: this.libcode,
pageNo: this.page,
pageSize: this.pageSize
}
if (bookType === 'hot') {
FetchHotBookRecommend(params).then(res => {
this.pageCount = res.page.totalPages
res.hotbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
}).catch(() => {
this.$message.error('接口错误')
})
} else {
FetchNewBookRecommend(params).then(res => {
res.newbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
}).catch(() => {
this.$message.error('接口错误')
})
}
},
// 根据isbn查找封面
getCoverByISBN(isbn, item) {
const params = {
isbn: isbn
}
FetchCoverByISBN(params).then((res) => {
item.cover = window.URL.createObjectURL(res)
this.bookData.push(item)
this.bookLoading = false
})
},
// 滚动加载
lazyLoading(e) {
const scrollTop = e.target.scrollTop
const windowHeight = e.target.clientHeight
const scrollHeight = e.target.scrollHeight
// 滚动条到底部
if (scrollTop + windowHeight === scrollHeight) {
this.bookLoading = true
this.page++
if (this.page > this.pageCount) {
this.bookLoading = false
this.$message.success('暂无更多数据~')
return
}
this.getBookData()
}
},
// 点击查看详情
handleDetails(index) {
const params = {
isbn: this.bookData[index].isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
if (res) {
this.$refs.detailDom.bookData = res
this.$refs.detailDom.dialogVisible = true
} else {
this.$message.error('暂无图书内容~')
}
}).catch(() => {
this.$message.error('接口错误')
})
}
},
// 组件挂载时的共用方法
mounted() {
}
}
import { FetchHotBookRecommend, FetchNewBookRecommend, FetchCoverByISBN, getBookDetailsByISBN } from '@/api/bookshelf'
export const bookListCrud = {
// 组件共用属性
data() {
return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"',
bookData: [],
page: 1,
pageSize: 13,
pageCount: 1,
bookLoading: false
}
},
computed: {
bookList() {
const arr = this.bookData.slice(1)
return arr
}
},
// 组件共用方法
methods: {
// 获取热门/新书图书list
getBookData() {
this.bookLoading = true
const bookType = this.$route.query.bookType
const params = {
libcode: this.libcode,
pageNo: this.page,
pageSize: this.pageSize
}
if (bookType === 'hot') {
FetchHotBookRecommend(params).then(res => {
this.pageCount = res.page.totalPages
res.hotbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
}).catch(() => {
this.$message.error('接口错误')
})
} else {
FetchNewBookRecommend(params).then(res => {
res.newbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
}).catch(() => {
this.$message.error('接口错误')
})
}
},
// 根据isbn查找封面
getCoverByISBN(isbn, item) {
const params = {
isbn: isbn
}
FetchCoverByISBN(params).then((res) => {
// item.cover = window.URL.createObjectURL(res)
if (res) {
item.cover = res
} else {
item.cover = ''
}
this.bookData.push(item)
this.bookLoading = false
})
},
// 滚动加载
lazyLoading(e) {
const scrollTop = e.target.scrollTop
const windowHeight = e.target.clientHeight
const scrollHeight = e.target.scrollHeight
// 滚动条到底部
if (scrollTop + windowHeight === scrollHeight) {
this.bookLoading = true
this.page++
if (this.page > this.pageCount) {
this.bookLoading = false
this.$message.success('暂无更多数据~')
return
}
this.getBookData()
}
},
// 点击查看详情
handleDetails(index) {
const params = {
isbn: this.bookData[index].isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
if (res) {
this.$refs.detailDom.bookData = res
this.$refs.detailDom.dialogVisible = true
} else {
this.$message.error('暂无图书内容~')
}
}).catch(() => {
this.$message.error('接口错误')
})
}
},
// 组件挂载时的共用方法
mounted() {
}
}

2
src/views/module/bookList.vue

@ -102,7 +102,7 @@ export default {
// justify-content: space-between; // justify-content: space-between;
li{ li{
margin-bottom: 20px; margin-bottom: 20px;
margin-left: 48px;
margin-left: 20px;
width: 300px; width: 300px;
overflow: hidden; overflow: hidden;
.other-list-img{ .other-list-img{

Loading…
Cancel
Save