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({
url: '/dxhtsg/getCoverByISBN',
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
if (response.status === 200) {
// console.log(response.data.data)
return response.data.data
return response.data
} else {
Message.error({
message: errorMsg,

25
src/views/newBookRecommend.vue

@ -6,7 +6,7 @@
<div v-for="(item,index) in rankingList" :key="index" class="swiper-slide">
<div class="book-list-item">
<div class="book-img">
<img :src="item.coverUrl" :onerror="defaultImg">
<img :src="item.cover" :onerror="defaultImg">
</div>
<div class="book-info">
<h4 class="title-item">{{ item.nbName }}</h4>
@ -17,8 +17,6 @@
</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">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-zuohua" />
@ -73,33 +71,24 @@ export default {
},
getBookList() {
FetchNewBookRecommend().then(res => {
this.rankingList = res
console.log(res, 'res')
this.rankingList = res.data
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(() => {
this.$message.error('接口错误')
})
},
getCoverByISBN(isbn) {
getCoverByISBN(isbn, item) {
const params = {
isbn: isbn
}
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>

2
vue.config.js

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

Loading…
Cancel
Save