Browse Source

增加配置文件/区分和东西湖的img取值方法

master
xuhuajiao 1 month ago
parent
commit
ea994d9fcc
  1. 1
      public/index.html
  2. 4
      public/static/config.js
  3. 4
      src/main.js
  4. 3
      src/utils/request.js
  5. 178
      src/views/bookRackList-dxh.vue
  6. 9
      src/views/bookRackList.vue
  7. 191
      src/views/index-dxh.vue
  8. 20
      src/views/index.vue
  9. 103
      src/views/mixins/booklist-dxh.js
  10. 36
      src/views/mixins/booklist.js
  11. 97
      src/views/module/homeListItem-dxh.vue
  12. 9
      src/views/module/homeListItem.vue

1
public/index.html

@ -6,6 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<script type="text/javascript" src="/static/config.js"></script>
<script>
window.onload = function() {
document.addEventListener('touchstart', function(event) {

4
public/static/config.js

@ -0,0 +1,4 @@
window.g = {
AXIOS_TIMEOUT: 10000,
ApiUrl: 'http://192.168.3.5:8080', // 配置服务器地址
}

4
src/main.js

@ -18,9 +18,9 @@ import './assets/fonts/fonts.css'
import axios from 'axios'
Vue.prototype.$axios = axios
// 馆代码 1201为东西湖馆代码 / 本地测试用FTZN
// 馆代码 1201为东西湖馆代码 1501 江夏 / 本地测试用FTZN
// Vue.prototype.libcode = 'FTZN'
Vue.prototype.libcode = '1201'
Vue.prototype.libcode = '1501'
// 引入echart
import echarts from 'echarts'

3
src/utils/request.js

@ -3,7 +3,8 @@ 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
// baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
baseURL: process.env.NODE_ENV === 'production' ? window.g.ApiUrl : '/', // api 的 base_url
timeout: 1000 * 30, // 请求超时时间
headers: {
'Content-Type': 'application/json'

178
src/views/bookRackList-dxh.vue

@ -0,0 +1,178 @@
<template>
<div id="bookshelf">
<div class="bookshelf-header" style="height:120px">
<!-- <router-link to="/">
<span class="icon iconfont icon-l">&#xe631;</span>
</router-link> -->
<span class="icon iconfont icon-l" @click="goBack()">&#xe631;</span>
<h2>本架图书</h2>
<div class="rack-direct">
<span :class="classnameL" @click="handleDirect(-1)"></span>
<span :class="classnameR" @click="handleDirect(1)"></span>
</div>
</div>
<div v-loading="loading" class="rack-box">
<div v-for="(item, index) in listData" :key="index" class="rack-item">
<div :class="['swiper'+index,'rack-box-list']">
<div class="swiper-wrapper">
<div v-for="eitem in bookList[item]" :key="eitem.id" class="list-item swiper-slide" @click="handleDetails(eitem)">
<div class="box-txt">
<span class="book-name">{{ eitem.bookName }}</span>
<span class="book-writer">{{ eitem.bookAuthor }}</span>
</div>
</div>
</div>
</div>
<div class="rack-floor">
<span :class="['icon','iconfont','icon-l'+index]" @click="handlePage(-1)">&#xe631;</span>
<p><span style="margin-right:25px">{{ index+1 }}</span><span>({{ bookList[item]?bookList[item].length:0 }})</span></p>
<span :class="['icon','iconfont','icon-r'+index]" @click="handlePage(1)">&#xe62f;</span>
</div>
</div>
</div>
<BookDetails ref="detailDom" />
</div>
</template>
<script>
import { initBookshelfDetails, getBookDetailsByISBN } from '@/api/bookshelf'
import BookDetails from './module/bookDetails.vue'
import { Swiper } from 'vue-awesome-swiper'
import 'swiper/swiper-bundle.css'
export default {
name: 'CurrentRackBook',
components: {
BookDetails
},
data() {
return {
loading: false,
listData: [],
bookList: {},
classnameL: 'rack-direct-active',
classnameR: null
}
},
created() {
this.initBookshelfDetails(-1)
},
mounted() {
},
methods: {
initSwiper() {
this.$nextTick(() => {
for (const key in this.bookList) {
this.bookList[key].forEach((el, index) => {
new Swiper('.swiper' + index, {
slidesPerView: 'auto',
slidesPerGroup: 15,
observer: true,
navigation: {
nextEl: '.icon-r' + index,
prevEl: '.icon-l' + index
}
})
})
}
})
},
// swiper
setSwiperInit() {
setTimeout(() => {
this.listData.forEach((item, index) => {
document.getElementsByClassName('swiper-wrapper')[index].style.transform = 'translate3d(0px, 0px, 0px)'
})
}, 50)
},
handleDetails(itemData) {
const params = {
isbn: itemData.isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
this.$refs.detailDom.dialogVisible = true
if (res) {
this.$refs.detailDom.bookData = res
} else {
this.$refs.detailDom.bookData = {
srcUrl: itemData.bookAuthor,
bookName: itemData.bookName,
bookAuthor: itemData.bookAuthor ? itemData.bookAuthor : '暂无信息',
gist: '暂无简介',
Publish: '暂无信息',
places: [
{ shelfName: '' }
]
}
}
})
},
//
handlePage(page) {
if (page === 1) {
//
} else {
//
}
},
//
handleDirect(n) {
if (n === -1) { //
this.classnameR = null
this.classnameL = 'rack-direct-active'
} else { //
this.classnameL = null
this.classnameR = 'rack-direct-active'
}
this.initBookshelfDetails(n)
},
goBack() {
this.$router.go(-1)
},
initBookshelfDetails(n) {
this.loading = true
const params = {}
if (n === -1) { //
params.shelfNo = this.$route.query.leftShelfNo
} else { //
params.shelfNo = this.$route.query.rightShelfNo
}
initBookshelfDetails(params).then((res) => {
console.log(this.listData)
// if (res.shelfs.length === 0) {
// res.shelfs.push('firstShelf', 'secondShelf', 'thirdShelf', 'fourthShelf', 'fivethShelf')
// for (let index = 0; index < res.shelfs.length; index++) {
// const shelfNo = res.shelfs[index]
// res.shelfBook[shelfNo] = []
// }
// }
this.listData.splice(0, this.listData.length, ...res.shelfAll)
if (res.shelfs.length !== 0) {
for (let index = 0; index < res.shelfs.length; index++) {
const shelfNo = res.shelfs[index]
this.$set(this.bookList, shelfNo, res.shelfBook[shelfNo])
}
}
if (this.listData.length > 0) {
this.initSwiper()
this.setSwiperInit()
}
setTimeout(() => {
this.loading = false
}, 1000)
})
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
.swiper-container {
position: relative;
width: 100%;
}
.swiper-slide {
width: 65px !important;
}
</style>

9
src/views/bookRackList.vue

@ -86,13 +86,22 @@ export default {
}, 50)
},
handleDetails(itemData) {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = {
isbn: itemData.isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
this.$refs.detailDom.dialogVisible = true
if (res) {
// this.$refs.detailDom.bookData = res
console.log('res', res)
Object.keys(res).forEach(key => {
if (key === 'srcUrl' && res[key]) {
res[key] = linkSrc + '/downloadFile' + res[key]
}
})
this.$refs.detailDom.bookData = res
console.log('ddd', this.$refs.detailDom.bookData)
} else {
this.$refs.detailDom.bookData = {
srcUrl: itemData.bookAuthor,

191
src/views/index-dxh.vue

@ -0,0 +1,191 @@
<template>
<div id="bookshelf">
<div class="bookshelf-header">
<h2>RFID智慧书架</h2>
<span class="shelf-num">{{ shelfName }}</span>
</div>
<!-- 本架分类 -->
<div class="book-category">
<p>{{ leftShelfMsg }}</p>
<p>{{ rightShelfMsg }}</p>
</div>
<!-- 智慧书架导航 -->
<ul class="book-nav">
<li @click="toSearch">
<img src="~@/assets/images/home/nav1.png" />
<p>图书检索</p>
</li>
<li @click="toPath('/HotBook?bookType=hot')">
<img src="~@/assets/images/home/nav2.png" />
<p>热门图书</p>
</li>
<li @click="toPath('/AuthorRecommend')">
<img src="~@/assets/images/home/nav3.png" />
<p>作者推荐</p>
</li>
<li @click="toPath('/DigitalResource')">
<img src="~@/assets/images/home/nav4.png" />
<p>数字资源</p>
</li>
<li @click="toRoomNav">
<img src="~@/assets/images/home/nav5.png" />
<p>场馆导航</p>
</li>
</ul>
<!-- 本架图书 -->
<div class="book-rack">
<div class="list-top">
<div class="list-top-title">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-benjiatushu" />
</svg>
<p>本架图书</p>
</div>
<span class="more" @click="toPath('/CurrentRackBook')">更多<i class="iconfont icon-zuo rotate"></i></span>
</div>
<div class="rack-list">
<BookListItem :list-data.sync="rackList" />
<div class="other-list">
<BookListItem :list-data.sync="otherList" :is-other-book="true" />
</div>
</div>
</div>
<!-- 新书推荐 -->
<div class="book-rack new-recommend">
<div class="list-top">
<div class="list-top-title">
<p>新书推荐</p>
</div>
<span class="more" @click="toPath('/NewBook?bookType=new')">更多<i class="iconfont icon-zuo rotate"></i></span>
</div>
<BookListItem :list-data.sync="newList" :is-new-book="true" />
</div>
</div>
</template>
<script>
import BookListItem from '@/views/module/homeListItem.vue'
import { FetchNewBookRecommend, FetchCoverByISBN, initSmartBookshelf } from '@/api/bookshelf'
export default {
name: 'Home',
components: {
BookListItem
},
data() {
return {
shelfName: '1',
leftShelfMsg: '',
rightShelfMsg: '',
// leftShelfNo: '1201-03-001-A-01',
// rightShelfNo: '1201-03-001-B-01',
leftShelfNo: '',
rightShelfNo: '',
rackList: [], //
otherList: [], //
newList: [] //
}
},
created() {
this.getNewBookList()
// +
this.initSmartBookshelf()
},
mounted() {
},
methods: {
toSearch() {
window.location.href = 'https://opac.whlib.org.cn/opac'
},
toPath(path) {
if (path === '/CurrentRackBook') {
const query = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
this.$router.push({ path: path, query: query })
} else {
this.$router.push(path)
}
},
toRoomNav() {
const linkSrc = process.env.VUE_APP_BASE_API
window.location.href = linkSrc + '/anchoring/initVenueNavigation.do?libcode=' + this.libcode
},
// -
getNewBookList() {
const params = {
libcode: this.libcode,
pageNo: 1,
pageSize: 4
}
FetchNewBookRecommend(params).then(res => {
let data = []
data = res.newbookList
data.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
})
}).catch(() => {
this.$message.error('接口错误')
})
},
// isbn
getCoverByISBN(isbn, item) {
const params = {
isbn: isbn
}
console.log(params)
FetchCoverByISBN(params).then((res) => {
// item.cover = window.URL.createObjectURL(res)
if (res) {
item.cover = res
} else {
item.cover = ''
}
this.newList.push(item)
})
},
//
initSmartBookshelf() {
this.leftShelfNo = this.$route.query.leftShelfNo
this.rightShelfNo = this.$route.query.rightShelfNo
const params = { leftShelfNo: this.leftShelfNo, rightShelfNo: this.rightShelfNo }
// const _this = this
initSmartBookshelf(params).then((res) => {
this.shelfName = res.shelfName
this.leftShelfMsg = res.leftShelf.sortMsg
this.rightShelfMsg = res.rightShelf.sortMsg
Promise.all(this.initBookData(res.bookList.splice(0, 1))).then((res) => {
this.rackList = res
console.log('rackList', this.rackList)
})
Promise.all(this.initBookData(res.bookList.splice(-2))).then((res) => {
this.otherList = res
console.log('otherList', this.otherList)
})
})
},
//
initBookData(bookList) {
return bookList.map(async(item, index) => {
const newItem = {
cover: item.srcUrl,
ranking: item.bookUID,
nbName: item.bookName,
isOtherBook: index !== 0,
nbAuthor: item.bookAuthor ? item.bookAuthor : '',
isNewBook: false,
num: item.heat ? item.heat : '0',
isbn: item.isbn
}
// const params = {
// isbn: item.isbn
// }
// const res = await FetchCoverByISBN(params)
// newItem.cover = window.URL.createObjectURL(res)
return newItem
})
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
</style>

20
src/views/index.vue

@ -110,16 +110,25 @@ export default {
},
// -
getNewBookList() {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = {
libcode: this.libcode,
pageNo: 1,
pageSize: 4
}
FetchNewBookRecommend(params).then(res => {
let data = []
data = res.newbookList
data.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
// let data = []
// data = res.newbookList
// data.forEach(item => {
// this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
// })
this.newList = res.newbookList.map((item, index) => {
if (item.nbImgPath) {
item.cover = linkSrc + '/downloadFile' + item.nbImgPath
} else {
item.cover = null
}
return item
})
}).catch(() => {
this.$message.error('接口错误')
@ -164,8 +173,9 @@ export default {
//
initBookData(bookList) {
return bookList.map(async(item, index) => {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const newItem = {
cover: item.srcUrl,
cover: linkSrc + '/downloadFile' + item.srcUrl,
ranking: item.bookUID,
nbName: item.bookName,
isOtherBook: index !== 0,

103
src/views/mixins/booklist-dxh.js

@ -0,0 +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)
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() {
}
}

36
src/views/mixins/booklist.js

@ -21,6 +21,7 @@ export const bookListCrud = {
methods: {
// 获取热门/新书图书list
getBookData() {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
this.bookLoading = true
const bookType = this.$route.query.bookType
const params = {
@ -31,17 +32,35 @@ export const bookListCrud = {
if (bookType === 'hot') {
FetchHotBookRecommend(params).then(res => {
this.pageCount = res.page.totalPages
res.hotbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
// res.hotbookList.forEach(item => {
// this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
// })
this.bookData = res.hotbookList.map((item, index) => {
if (item.nbImgPath) {
item.cover = linkSrc + '/downloadFile' + item.nbImgPath
} else {
item.cover = null
}
return item
})
this.bookLoading = false
}).catch(() => {
this.$message.error('接口错误')
})
} else {
FetchNewBookRecommend(params).then(res => {
res.newbookList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
this.bookData = res.newbookList.map((item, index) => {
if (item.nbImgPath) {
item.cover = linkSrc + '/downloadFile' + item.nbImgPath
} else {
item.cover = null
}
return item
})
this.bookLoading = false
// res.newbookList.forEach(item => {
// this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
// })
}).catch(() => {
this.$message.error('接口错误')
})
@ -82,12 +101,21 @@ export const bookListCrud = {
},
// 点击查看详情
handleDetails(index) {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = {
isbn: this.bookData[index].isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
if (res) {
// this.$refs.detailDom.bookData = res
console.log('res', res)
Object.keys(res).forEach(key => {
if (key === 'srcUrl' && res[key]) {
res[key] = linkSrc + '/downloadFile' + res[key]
}
})
this.$refs.detailDom.bookData = res
console.log('ddd', this.$refs.detailDom.bookData)
this.$refs.detailDom.dialogVisible = true
} else {
this.$message.error('暂无图书内容~')

97
src/views/module/homeListItem-dxh.vue

@ -0,0 +1,97 @@
<template>
<div>
<div :class="[isNewBook ? 'list-small' : (isOtherBook ? 'list-middle' : 'list-big') ]">
<div v-for="(item,index) in listData" :key="item.ranking" class="list-item" @click="handleDetails(index)">
<div class="book-img">
<img :src="item.cover ? item.cover : ''" :onerror="defaultImg" />
</div>
<div class="book-info">
<h4 :class="['book-title', {'title-item': !isOtherBook}]">{{ item.nbName }}</h4>
<p class="book-author">{{ item.nbAuthor }}</p>
<div v-if="!isNewBook" class="book-num">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-remen" />
</svg>
<p>{{ item.num }}</p>
</div>
</div>
</div>
</div>
<BookDetails ref="detailDom" />
</div>
</template>
<script>
import { getBookDetailsByISBN } from '@/api/bookshelf'
import BookDetails from './bookDetails.vue'
export default {
name: 'BookListItem',
components: { BookDetails },
props: {
listData: {
type: Array,
default: function() {
return []
}
},
isOtherBook: {
type: Boolean,
default: function() {
return false
}
},
isNewBook: {
type: Boolean,
default: function() {
return false
}
}
},
data() {
return {
defaultImg: 'this.src="' + require('@/assets/images/default-img.png') + '"'
}
},
watch: {
listData: function(newValue, oldValue) {
},
isOtherBook: function(newValue, oldValue) {
},
isNewBook: function(newValue, oldValue) {
}
},
created() {
},
mounted() {
},
methods: {
handleDetails(index) {
const params = {
isbn: this.listData[index].isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
this.$refs.detailDom.dialogVisible = true
if (res) {
this.$refs.detailDom.bookData = res
} else {
this.$refs.detailDom.bookData = {
srcUrl: this.listData[index].cover,
bookName: this.listData[index].nbName,
bookAuthor: this.listData[index].nbAuthor ? this.listData[index].nbAuthor : '暂无信息',
gist: '暂无简介',
Publish: '暂无信息',
places: [
{ shelfName: '' }
]
}
}
})
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
</style>

9
src/views/module/homeListItem.vue

@ -67,13 +67,22 @@ export default {
},
methods: {
handleDetails(index) {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = {
isbn: this.listData[index].isbn.replace(/\-/g, '')
}
getBookDetailsByISBN(params).then(res => {
this.$refs.detailDom.dialogVisible = true
if (res) {
// this.$refs.detailDom.bookData = res
console.log('res', res)
Object.keys(res).forEach(key => {
if (key === 'srcUrl' && res[key]) {
res[key] = linkSrc + '/downloadFile' + res[key]
}
})
this.$refs.detailDom.bookData = res
console.log('ddd', this.$refs.detailDom.bookData)
} else {
this.$refs.detailDom.bookData = {
srcUrl: this.listData[index].cover,

Loading…
Cancel
Save