Browse Source

大屏bug

master
x_ying 3 years ago
parent
commit
1ccd69b994
  1. 3
      src/api/inquiryMachine.js
  2. 2
      src/utils/request.js
  3. 25
      src/views/newBookRecommend.vue
  4. 2
      vue.config.js

3
src/api/inquiryMachine.js

@ -42,7 +42,8 @@ export function FetchCoverByISBN(params) {
return request({ return request({
url: '/dxhtsg/getCoverByISBN', url: '/dxhtsg/getCoverByISBN',
method: 'get', method: 'get',
params: params
params: params,
responseType: 'blob'
}) })
} }

2
src/utils/request.js

@ -32,7 +32,7 @@ service.interceptors.response.use(
const errorMsg = response.data.errMsg const errorMsg = response.data.errMsg
if (response.status === 200) { if (response.status === 200) {
// console.log(response.data.data) // console.log(response.data.data)
return response.data.data
return response.data
} else { } else {
Message.error({ Message.error({
message: errorMsg, message: errorMsg,

25
src/views/newBookRecommend.vue

@ -6,7 +6,7 @@
<div v-for="(item,index) in rankingList" :key="index" class="swiper-slide"> <div v-for="(item,index) in rankingList" :key="index" class="swiper-slide">
<div class="book-list-item"> <div class="book-list-item">
<div class="book-img"> <div class="book-img">
<img :src="item.coverUrl" :onerror="defaultImg">
<img :src="item.cover" :onerror="defaultImg">
</div> </div>
<div class="book-info"> <div class="book-info">
<h4 class="title-item">{{ item.nbName }}</h4> <h4 class="title-item">{{ item.nbName }}</h4>
@ -17,8 +17,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="icon iconfont prev-btn">&#xe638;</div> -->
<!-- <div class="icon iconfont next-btn">&#xe635;</div> -->
<div class="icon iconfont prev-btn"> <div class="icon iconfont prev-btn">
<svg class="icon svg-icon" aria-hidden="true"> <svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-zuohua" /> <use xlink:href="#icon-zuohua" />
@ -73,33 +71,24 @@ export default {
}, },
getBookList() { getBookList() {
FetchNewBookRecommend().then(res => { FetchNewBookRecommend().then(res => {
this.rankingList = res
console.log(res, 'res')
this.rankingList = res.data
this.rankingList.forEach(item => { this.rankingList.forEach(item => {
this.getCoverByISBN(item.isbn.replace(/\-/g, ''))
if (this.coverUrl) {
item.coverUrl = this.coverUrl
} else {
item.coverUrl = ''
}
this.coverUrl = null
this.getCoverByISBN(item.isbn.replace(/\-/g, ''), item)
}) })
}).catch(() => { }).catch(() => {
this.$message.error('接口错误') this.$message.error('接口错误')
}) })
}, },
getCoverByISBN(isbn) {
getCoverByISBN(isbn, item) {
const params = { const params = {
isbn: isbn isbn: isbn
} }
FetchCoverByISBN(params).then((res) => { FetchCoverByISBN(params).then((res) => {
try {
this.coverUrl = res
} catch (error) {
this.coverUrl = window.URL.createObjectURL(res)
}
console.log(res, 'blob')
item.cover = window.URL.createObjectURL(res)
}) })
} }
} }
} }
</script> </script>

2
vue.config.js

@ -16,7 +16,7 @@ module.exports = {
warnings: false, warnings: false,
errors: true errors: true
}, },
host: 'localhost',
// host: 'localhost',
proxy: { proxy: {
'/dxhtsg': { '/dxhtsg': {
target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,

Loading…
Cancel
Save