Browse Source

还原图片写法

master
xuhuajiao 2 weeks ago
parent
commit
7b8dc7a28f
  1. BIN
      src/assets/images/default-img.png
  2. BIN
      src/assets/images/default-img2.png
  3. 18
      src/views/bookRackList.vue
  4. 30
      src/views/index.vue
  5. 62
      src/views/mixins/booklist.js
  6. 18
      src/views/module/homeListItem.vue

BIN
src/assets/images/default-img.png

Before

Width: 440  |  Height: 526  |  Size: 51 KiB

After

Width: 440  |  Height: 526  |  Size: 35 KiB

BIN
src/assets/images/default-img2.png

After

Width: 440  |  Height: 526  |  Size: 51 KiB

18
src/views/bookRackList.vue

@ -86,22 +86,22 @@ export default {
}, 50) }, 50)
}, },
handleDetails(itemData) { handleDetails(itemData) {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
// const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = { const params = {
isbn: itemData.isbn.replace(/\-/g, '') isbn: itemData.isbn.replace(/\-/g, '')
} }
getBookDetailsByISBN(params).then(res => { getBookDetailsByISBN(params).then(res => {
this.$refs.detailDom.dialogVisible = true this.$refs.detailDom.dialogVisible = true
if (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 this.$refs.detailDom.bookData = res
console.log('ddd', this.$refs.detailDom.bookData)
// 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 { } else {
this.$refs.detailDom.bookData = { this.$refs.detailDom.bookData = {
srcUrl: itemData.bookAuthor, srcUrl: itemData.bookAuthor,

30
src/views/index.vue

@ -110,26 +110,26 @@ export default {
}, },
// - // -
getNewBookList() { getNewBookList() {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
// const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = { const params = {
libcode: this.libcode, libcode: this.libcode,
pageNo: 1, pageNo: 1,
pageSize: 4 pageSize: 4
} }
FetchNewBookRecommend(params).then(res => { FetchNewBookRecommend(params).then(res => {
// 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
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(() => { }).catch(() => {
this.$message.error('接口错误') this.$message.error('接口错误')
}) })
@ -173,9 +173,9 @@ export default {
// //
initBookData(bookList) { initBookData(bookList) {
return bookList.map(async(item, index) => { return bookList.map(async(item, index) => {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
// const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const newItem = { const newItem = {
cover: linkSrc + '/downloadFile' + item.srcUrl,
cover: item.srcUrl,
ranking: item.bookUID, ranking: item.bookUID,
nbName: item.bookName, nbName: item.bookName,
isOtherBook: index !== 0, isOtherBook: index !== 0,

62
src/views/mixins/booklist.js

@ -21,7 +21,7 @@ export const bookListCrud = {
methods: { methods: {
// 获取热门/新书图书list // 获取热门/新书图书list
getBookData() { getBookData() {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
// const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
this.bookLoading = true this.bookLoading = true
const bookType = this.$route.query.bookType const bookType = this.$route.query.bookType
const params = { const params = {
@ -32,35 +32,35 @@ export const bookListCrud = {
if (bookType === 'hot') { if (bookType === 'hot') {
FetchHotBookRecommend(params).then(res => { FetchHotBookRecommend(params).then(res => {
this.pageCount = res.page.totalPages this.pageCount = res.page.totalPages
// 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
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 this.bookLoading = false
}).catch(() => { }).catch(() => {
this.$message.error('接口错误') this.$message.error('接口错误')
}) })
} else { } else {
FetchNewBookRecommend(params).then(res => { FetchNewBookRecommend(params).then(res => {
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)
// 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(() => { }).catch(() => {
this.$message.error('接口错误') this.$message.error('接口错误')
}) })
@ -101,21 +101,21 @@ export const bookListCrud = {
}, },
// 点击查看详情 // 点击查看详情
handleDetails(index) { handleDetails(index) {
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
// const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiUrl : process.env.VUE_APP_BASE_API
const params = { const params = {
isbn: this.bookData[index].isbn.replace(/\-/g, '') isbn: this.bookData[index].isbn.replace(/\-/g, '')
} }
getBookDetailsByISBN(params).then(res => { getBookDetailsByISBN(params).then(res => {
if (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 this.$refs.detailDom.bookData = res
console.log('ddd', this.$refs.detailDom.bookData)
// 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 this.$refs.detailDom.dialogVisible = true
} else { } else {
this.$message.error('暂无图书内容~') this.$message.error('暂无图书内容~')

18
src/views/module/homeListItem.vue

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

Loading…
Cancel
Save