Files
nuttyreading-html/pages/eBook/bookType.vue
徐哼唧L 3b2ee990d2 555
2023-03-03 13:47:55 +08:00

230 lines
4.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<z-nav-bar :title="title"></z-nav-bar>
<view class="book_list">
<view class="bl_tioa" v-for="(item,index) in bookList" @click="onBookJump(item)">
<image :src="item.images"></image>
<b v-if="item.isVip==1" style="background: #c79119;">VIP</b>
<b v-if="item.isVip==2" style="background: #c74119;">付费</b>
<view>
<text class="bok_name">{{item.name}}</text>
</view>
<view>
<text>作者<text style="color: #333;">{{item.authorName}}</text></text>
</view>
<view>
<text>出版商<text style="color: #333;">{{item.publisherName}}</text></text>
</view>
<view>
<text style="line-height: 20rpx;">{{item.title}}</text>
</view>
</view>
<view style="height: 1px;"></view>
</view>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top>
</view>
</view>
</template>
<script>
export default {
data() {
return {
scrollTop: 0,
status: 3,
bookScreen: {
type: '',
page: 1, //当前页码数
limit: 5, //单页数据数量
},
totalPage: 0,
totalCount: 0,
bookList: [],
bgiStyle: {
background: '#2ab58833'
},
iconStyle: {
fontSize: '40rpx',
fontWeight: 'bold',
color: '#54a966',
},
urList: '',
title: '',
}
},
// 返回顶部
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 下拉刷新
onReachBottom() {
this.status = 0
if (this.bookScreen.page < this.totalPage) {
this.bookScreen.page = this.bookScreen.page + 1
setTimeout(() => {
if (this.bookScreen.type == 'Sale') {
this.$http
.post(this.urList + '?page=' + this.bookScreen.page + '&limit=' + this.bookScreen
.limit)
.then(res => {
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
for (let i in res.page.list) {
this.bookList.push(res.page.list[i])
}
});
} else {
this.$http
.post(this.urList, this.bookScreen)
.then(res => {
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
for (let i in res.page.list) {
this.bookList.push(res.page.list[i])
}
});
}
}, 1000)
} else {
this.status = 1
}
},
//第一次加载
onLoad(e) {
this.bookScreen.type = e.Type
if (this.bookScreen.type == 'New') {
this.urList = 'book/book/getSaleBook'
this.title = '新书上架'
} else if (this.bookScreen.type == 'Sale') {
this.urList = 'book/book/getNewBook'
this.title = '限时特价'
} else if (this.bookScreen.type == 'Best') {
this.urList = 'book/book/getBestBook'
this.title = '精选书单'
}
this.getData();
},
//页面显示
onShow() {
// this.getData();
},
// 下拉刷新
onPullDownRefresh() {
this.getData()
uni.stopPullDownRefresh()
},
//方法
methods: {
// 获取列表数据
getData() {
console.log(this.urList)
this.bookList = []
if (this.bookScreen.type == 'Sale') {
this.$http
.post(this.urList + '?page=' + this.bookScreen.page + '&limit=' + this.bookScreen.limit)
.then(res => {
this.bookList = res.page.list
this.totalPage = res.page.totalPage
this.status = 3
});
} else {
this.$http
.post(this.urList, this.bookScreen)
.then(res => {
this.bookList = res.page.list
this.totalPage = res.page.totalPage
this.status = 3
});
}
},
// 电子书内容跳转
onBookJump(e) {
uni.navigateTo({
url: './bookContent?Id=' + e.id
});
},
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.book_list {
margin: 50rpx 30rpx 0 30rpx;
.bl_tioa {
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
position: relative;
padding: 0 25upx 10upx 220upx;
margin: 0 0 60rpx 0;
border-radius: 15rpx;
min-height: 250rpx;
view {
// margin: 0 0 10rpx 0;
text {
color: #9b9b9b;
font-size: 24rpx;
line-height: 36rpx;
}
.bok_name {
font-weight: bold;
color: #333;
font-size: 28rpx;
}
}
image {
position: absolute;
left: 30upx;
top: -20upx;
width: 160upx;
height: 240upx;
}
b {
display: block;
padding: 5rpx 10rpx;
border-radius: 10rpx;
text-align: center;
color: #fff;
font-weight: normal;
background: #27b386;
position: absolute;
left: -1upx;
top: -10upx;
font-size: 16rpx;
}
}
}
</style>