xuhuajiao
1 year ago
7 changed files with 276 additions and 263 deletions
-
28.env.development
-
192src/api/bookshelf.js
-
105src/utils/request.js
-
3src/views/digitalResource.vue
-
8src/views/index.vue
-
201src/views/mixins/booklist.js
-
2src/views/module/bookList.vue
@ -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 |
@ -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 |
||||
|
} |
@ -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 |
@ -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() { |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue