270 lines
5.4 KiB
Vue
270 lines
5.4 KiB
Vue
<template>
|
||
<view>
|
||
<z-nav-bar title="电子书列表"></z-nav-bar>
|
||
|
||
<view class="book_class">
|
||
<view class="bc_list">
|
||
<view class="bc_con" v-for="(item,index) in classFen" @click="FenBook(item)"
|
||
:class="bookScreen.type == item.id ? 'bc_con bc_con_style' : 'bc_con'">{{item.sort}}</view>
|
||
</view>
|
||
<view class="bc_list">
|
||
<view class="bc_con" v-for="(item,index) in classMian" @click="MianBook(item)"
|
||
:class="bookScreen.is_charge == item.id ? 'bc_con bc_con_style' : 'bc_con'">{{item.sort}}</view>
|
||
</view>
|
||
</view>
|
||
|
||
|
||
<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,
|
||
classFen: [{
|
||
sort: '全部',
|
||
id: ''
|
||
}, {
|
||
sort: '医学',
|
||
id: 1
|
||
}, {
|
||
sort: '国学',
|
||
id: 2
|
||
}, {
|
||
sort: '文学',
|
||
id: 3
|
||
}, {
|
||
sort: '古籍',
|
||
id: 4
|
||
}],
|
||
classMian: [{
|
||
sort: '免费',
|
||
id: 1
|
||
}, {
|
||
sort: 'VIP',
|
||
id: 0
|
||
}],
|
||
bookScreen: {
|
||
authorName: '', //作者
|
||
publisherName: '', //出版社
|
||
type: '', //电子书类型
|
||
bookName: '', //关键词
|
||
is_charge: 1, //是否收费(0收费1免费),
|
||
state: 1,
|
||
page: 1, //当前页码数
|
||
limit: 5, //单页数据数量
|
||
},
|
||
totalPage: 0,
|
||
totalCount: 0,
|
||
bookList: [],
|
||
bgiStyle: {
|
||
background: '#2ab58833'
|
||
},
|
||
iconStyle: {
|
||
fontSize: '40rpx',
|
||
fontWeight: 'bold',
|
||
color: '#54a966',
|
||
},
|
||
}
|
||
},
|
||
|
||
// 返回顶部
|
||
onPageScroll(e) {
|
||
this.scrollTop = e.scrollTop;
|
||
},
|
||
|
||
// 下拉刷新
|
||
onReachBottom() {
|
||
this.status = 0
|
||
if (this.bookScreen.page < this.totalPage) {
|
||
this.bookScreen.page = this.bookScreen.page + 1
|
||
setTimeout(() => {
|
||
this.$http
|
||
.post('book/book/list', 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) {
|
||
if (e.id) {
|
||
this.bookScreen.type = e.id
|
||
}
|
||
this.getData();
|
||
},
|
||
//页面显示
|
||
onShow() {
|
||
// this.getData();
|
||
},
|
||
// 下拉刷新
|
||
onPullDownRefresh() {
|
||
this.getData()
|
||
uni.stopPullDownRefresh()
|
||
},
|
||
//方法
|
||
methods: {
|
||
// 获取列表数据
|
||
getData() {
|
||
this.bookList = []
|
||
this.$http
|
||
.post('book/book/list', this.bookScreen)
|
||
.then(res => {
|
||
this.bookList = res.page.list
|
||
this.totalPage = res.page.totalPage
|
||
this.status = 3
|
||
});
|
||
},
|
||
|
||
// 分类选择
|
||
FenBook(e) {
|
||
if (e.id == 0) {
|
||
this.bookScreen.type = ''
|
||
} else {
|
||
this.bookScreen.type = e.id
|
||
}
|
||
this.bookScreen.page = 1
|
||
this.getData();
|
||
},
|
||
MianBook(e) {
|
||
this.bookScreen.is_charge = e.id
|
||
this.bookScreen.page = 1
|
||
this.getData();
|
||
},
|
||
|
||
// 电子书内容跳转
|
||
onBookJump(e) {
|
||
uni.navigateTo({
|
||
url: './bookContent?Id=' + e.id
|
||
});
|
||
},
|
||
},
|
||
|
||
};
|
||
</script>
|
||
<style lang="scss" scoped>
|
||
@import '@/style/mixin.scss';
|
||
|
||
|
||
.book_class {
|
||
margin: 20rpx 30rpx 60rpx 30rpx;
|
||
|
||
.bc_list {
|
||
|
||
margin-bottom: 10rpx;
|
||
|
||
.bc_con {
|
||
display: inline-block;
|
||
font-size: 28rpx;
|
||
margin-right: 20rpx;
|
||
border-radius: 20rpx;
|
||
padding: 6rpx 12rpx;
|
||
}
|
||
|
||
.bc_con_style {
|
||
color: #27b386;
|
||
background-color: #2ab58833;
|
||
}
|
||
}
|
||
}
|
||
|
||
.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>
|