diff --git a/.env.development b/.env.development index b1ab04f..a5806b2 100644 --- a/.env.development +++ b/.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 diff --git a/src/api/bookshelf.js b/src/api/bookshelf.js index a1e377f..ee26a5c 100644 --- a/src/api/bookshelf.js +++ b/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 +} diff --git a/src/utils/request.js b/src/utils/request.js index 1ec0cde..1d76223 100644 --- a/src/utils/request.js +++ b/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 diff --git a/src/views/digitalResource.vue b/src/views/digitalResource.vue index 6803c90..5421e76 100644 --- a/src/views/digitalResource.vue +++ b/src/views/digitalResource.vue @@ -9,7 +9,7 @@
-
+
{{ item.nrsTitle }}
@@ -75,6 +75,7 @@ export default { -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; + text-align: center; } } } diff --git a/src/views/index.vue b/src/views/index.vue index c10eee8..b20a95e 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -130,8 +130,14 @@ export default { const params = { isbn: isbn } + console.log(params) 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) }) }, diff --git a/src/views/mixins/booklist.js b/src/views/mixins/booklist.js index c2985e0..dee8aff 100644 --- a/src/views/mixins/booklist.js +++ b/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() { + } +} diff --git a/src/views/module/bookList.vue b/src/views/module/bookList.vue index 6a32166..4db6002 100644 --- a/src/views/module/bookList.vue +++ b/src/views/module/bookList.vue @@ -102,7 +102,7 @@ export default { // justify-content: space-between; li{ margin-bottom: 20px; - margin-left: 48px; + margin-left: 20px; width: 300px; overflow: hidden; .other-list-img{